repo_name
stringclasses
5 values
pr_number
int64
1.52k
15.5k
pr_title
stringlengths
8
143
pr_description
stringlengths
0
10.2k
author
stringlengths
3
18
date_created
unknown
date_merged
unknown
previous_commit
stringlengths
40
40
pr_commit
stringlengths
40
40
query
stringlengths
11
10.2k
filepath
stringlengths
6
220
before_content
stringlengths
0
597M
after_content
stringlengths
0
597M
label
int64
-1
1
libgdx/libgdx
7,270
Update missing build.gradle files with new syntax for registering tasks
Some Gradle build files were still using old syntax after https://github.com/libgdx/libgdx/pull/7134.
obigu
"2023-11-05T15:31:03Z"
"2023-11-13T11:04:33Z"
8e3b2ef2af2e1c1765b3441cb15cfbeddf4046fa
a25ceaddd8e9ea740b7e50e486ea4f815d2a3f58
Update missing build.gradle files with new syntax for registering tasks. Some Gradle build files were still using old syntax after https://github.com/libgdx/libgdx/pull/7134.
./tests/gdx-tests/src/com/badlogic/gdx/tests/PngTest.java
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.tests; import java.io.IOException; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.Pixmap; import com.badlogic.gdx.graphics.PixmapIO.PNG; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.tests.utils.GdxTest; public class PngTest extends GdxTest { SpriteBatch batch; Texture badlogic, screenshot; public void create () { batch = new SpriteBatch(); badlogic = new Texture(Gdx.files.internal("data/badlogic.jpg")); } public void render () { Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); batch.begin(); if (screenshot == null) { int width = Gdx.graphics.getWidth(), height = Gdx.graphics.getHeight(); for (int i = 0; i < 100; i++) batch.draw(badlogic, MathUtils.random(width), MathUtils.random(height)); batch.flush(); FileHandle file = FileHandle.tempFile("screenshot-"); System.out.println(file.file().getAbsolutePath()); Pixmap pixmap = Pixmap.createFromFrameBuffer(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); try { PNG writer = new PNG((int)(pixmap.getWidth() * pixmap.getHeight() * 1.5f)); // writer.setCompression(Deflater.NO_COMPRESSION); writer.write(file, pixmap); writer.write(file, pixmap); // Write twice to make sure the object is reusable. writer.dispose(); } catch (IOException ex) { throw new RuntimeException(ex); } screenshot = new Texture(file); } batch.draw(screenshot, 0, 0); batch.end(); } }
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.tests; import java.io.IOException; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.Pixmap; import com.badlogic.gdx.graphics.PixmapIO.PNG; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.tests.utils.GdxTest; public class PngTest extends GdxTest { SpriteBatch batch; Texture badlogic, screenshot; public void create () { batch = new SpriteBatch(); badlogic = new Texture(Gdx.files.internal("data/badlogic.jpg")); } public void render () { Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); batch.begin(); if (screenshot == null) { int width = Gdx.graphics.getWidth(), height = Gdx.graphics.getHeight(); for (int i = 0; i < 100; i++) batch.draw(badlogic, MathUtils.random(width), MathUtils.random(height)); batch.flush(); FileHandle file = FileHandle.tempFile("screenshot-"); System.out.println(file.file().getAbsolutePath()); Pixmap pixmap = Pixmap.createFromFrameBuffer(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); try { PNG writer = new PNG((int)(pixmap.getWidth() * pixmap.getHeight() * 1.5f)); // writer.setCompression(Deflater.NO_COMPRESSION); writer.write(file, pixmap); writer.write(file, pixmap); // Write twice to make sure the object is reusable. writer.dispose(); } catch (IOException ex) { throw new RuntimeException(ex); } screenshot = new Texture(file); } batch.draw(screenshot, 0, 0); batch.end(); } }
-1
libgdx/libgdx
7,270
Update missing build.gradle files with new syntax for registering tasks
Some Gradle build files were still using old syntax after https://github.com/libgdx/libgdx/pull/7134.
obigu
"2023-11-05T15:31:03Z"
"2023-11-13T11:04:33Z"
8e3b2ef2af2e1c1765b3441cb15cfbeddf4046fa
a25ceaddd8e9ea740b7e50e486ea4f815d2a3f58
Update missing build.gradle files with new syntax for registering tasks. Some Gradle build files were still using old syntax after https://github.com/libgdx/libgdx/pull/7134.
./tests/gdx-tests-android/assets/data/maps/tiled-animations/test-load-animations.tmx
<?xml version="1.0" encoding="UTF-8"?> <map version="1.0" orientation="orthogonal" renderorder="right-down" width="16" height="16" tilewidth="32" tileheight="32" nextobjectid="18"> <tileset firstgid="1" name="Test" tilewidth="256" tileheight="256" tilecount="3" columns="0"> <tile id="0"> <image width="32" height="32" source="Start.bmp"/> <animation> <frame tileid="0" duration="500"/> <frame tileid="1" duration="500"/> </animation> </tile> <tile id="1"> <image width="32" height="32" source="../../badlogicsmall.jpg"/> </tile> <tile id="2"> <image width="256" height="256" source="../../badlogic.jpg"/> </tile> <tile id="3"> <image width="32" height="32" source="Start.bmp"/> <animation> <frame tileid="0" duration="200"/> <frame tileid="1" duration="200"/> </animation> </tile> </tileset> <objectgroup name="Objects"> <object id="3" name="Ellipse" x="59.3333" y="335" width="130" height="87"> <ellipse/> </object> <object id="5" name="Polygon" x="238.667" y="351.333"> <polygon points="0,0 78,-4 32,73"/> </object> <object id="9" name="Rectangle" x="340" y="341.333" width="118.667" height="100"/> <object id="12" name="Texture" gid="4" x="128" y="298.667" width="256" height="33.667"/> <object id="14" gid="1073741825" x="384" y="256" width="64" height="32"/> <object id="17" name="Polyline" x="364" y="155"> <polyline points="0,0 29,-60 57,4 91,-63"/> </object> </objectgroup> </map>
<?xml version="1.0" encoding="UTF-8"?> <map version="1.0" orientation="orthogonal" renderorder="right-down" width="16" height="16" tilewidth="32" tileheight="32" nextobjectid="18"> <tileset firstgid="1" name="Test" tilewidth="256" tileheight="256" tilecount="3" columns="0"> <tile id="0"> <image width="32" height="32" source="Start.bmp"/> <animation> <frame tileid="0" duration="500"/> <frame tileid="1" duration="500"/> </animation> </tile> <tile id="1"> <image width="32" height="32" source="../../badlogicsmall.jpg"/> </tile> <tile id="2"> <image width="256" height="256" source="../../badlogic.jpg"/> </tile> <tile id="3"> <image width="32" height="32" source="Start.bmp"/> <animation> <frame tileid="0" duration="200"/> <frame tileid="1" duration="200"/> </animation> </tile> </tileset> <objectgroup name="Objects"> <object id="3" name="Ellipse" x="59.3333" y="335" width="130" height="87"> <ellipse/> </object> <object id="5" name="Polygon" x="238.667" y="351.333"> <polygon points="0,0 78,-4 32,73"/> </object> <object id="9" name="Rectangle" x="340" y="341.333" width="118.667" height="100"/> <object id="12" name="Texture" gid="4" x="128" y="298.667" width="256" height="33.667"/> <object id="14" gid="1073741825" x="384" y="256" width="64" height="32"/> <object id="17" name="Polyline" x="364" y="155"> <polyline points="0,0 29,-60 57,4 91,-63"/> </object> </objectgroup> </map>
-1
libgdx/libgdx
7,270
Update missing build.gradle files with new syntax for registering tasks
Some Gradle build files were still using old syntax after https://github.com/libgdx/libgdx/pull/7134.
obigu
"2023-11-05T15:31:03Z"
"2023-11-13T11:04:33Z"
8e3b2ef2af2e1c1765b3441cb15cfbeddf4046fa
a25ceaddd8e9ea740b7e50e486ea4f815d2a3f58
Update missing build.gradle files with new syntax for registering tasks. Some Gradle build files were still using old syntax after https://github.com/libgdx/libgdx/pull/7134.
./tests/gdx-tests-android/assets/data/garuda.ttf
FFTMIR{7GDEF GPOSOӈ,tGSUB٩4OS/2{PVcmap7^pDcvt 1; P$fpgm2Jf glyfW8ݔhead뙞46hheaT$hmtx~locaH tmaxpx name2,)postGprepb3 |z_<[ [ mBQmB^a @ 1 /P PfEd@ H`O _MTVb., ,#y:+,L=L= G7SL Z,),m,,), ,),%,0,(,)ZSG7G7G7,,6J3MPbS 6P^J,J@JM 1M +N,bN bC,L+,#,@&,",% , ,BBB@@B,B, ,B,#L@,@ N\NG+(ozm:7AmC~t  <0Eh$)) `\[r(eO %' TZ  "#/42 f%6t,$||Ta.=nV bQ4!bC#79#"@` ;uTT]X]j5JMWOcQcPcc(c0c*c:c c<cCqQ` 4Lp*4**#*\*(Lq*@G7L '?$&L LLm>NZL4L4l*CA4A4AbM3PPPP^M 1 1 1 1 1GN (NNNNMbK,#,#,#,#,#,#y &,%,%,%,% [*#,B, , , , , $&b@,@,@,@,@*Ba?(,*L LLPL4L"*#*#L,L?nTT*     :< ~1Sax:[      " & 0 :!"""% 1R`x?     & 0 9!"""%'po:TeA 1X:      !"#$%&'()*+,-./0123456789:;<=>?@]^_`stLuvMNOwbcdefhijklmnopqrz{|}~TU   !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`a "!#%$&(*)+,.-/0243576;:<=Nw S'9GgBCxyuvst8@FQRYZOLMP    AHKJI,K*PXJvY#?+X=YK*PX}Y ԰.-, /+\X G#Faj X db8!!Y!Y-,KRXE#Y!-,i @PX!@Y-,+X!#!zXYKRXXY#!+XFvYXYYY-, \Z-,"PX \\Y-,$PX@\\Y-, 9/-KPXYF+X!YKRX!Y+\X E+D EN++D E 6++D E ++D E r++D E ++D Ed++D E++D E+D E 3+Fv+D E +Fv+D E"+Fv+D E+Fv+DYHT17=BHLE7EY_....`l>l(T$b>ph"T p  l , L  Z P<l|,|6|80&,\N@t8@HPXf\4Plt~  !T!"#$ $%&@'():*,+*,-./0&012,23Z34<45F567 78l9 9:Z:;b<4==>?n?@ApB BnBBBC0CD DZDDE.E.FFG`GHLHIJ2JfKKKL*LMMzMN,NNOPjQ QSSTUtV`W2XX$X.X8XRXXYZ&ZxZ[H[p\\z\\\]]]^8^^__f___`&`l`aab:bbbbbbbc4c@cLcXcdcpc|ccccd dd"d.d:dFdeee e,e8eDefff(f4f@fLfXggg(g4g@gLgXgdgpg|ghhh h,h8hDhxhiiii&i2iiij2jjjjkBkpkkl*l^llmmmn ndndnnnnnnnnnnnn_1+5+/5+/ֱ+ +013!%!!_@!_JV 8+(++ /ֱ +99990175353qmPf|dd.4 G+3+2 /ִ + . +99  9901'533'53Gdkdψuuuu  C+3 + 3+ 33 22+33 22 /!+017#537#53733733#3##7#37#3+S`%*I++I)Tc%+J**9% HHHH#!'| /"3 2/3 2(/ֱ ְ2+ 222"222ֱ%ֱ)+ 9@  !%&'$901%#5&'7&546753&'>54'v\2Ylj]2ZV88p25Av`uYX+Xf **c,+H(Z"J:]#:< $,+3 )/ 2ֱ% ֱ -/ִ A++ A++' A+++" A+.+@  $9+'@ $ %)$9%)#"'+$9  $901"&54632"32543!"&54632"3254IORDHU')IMMLLF{HPV@JSRHLLM]kXUcdXQ3;?|}Jh[VbjUTh=}}+&.+* + //ֱ'ֱ$+0+'99$@ &"*+-$9,$9* 9@  "$%.'(,-$901267&'#"&547&546"654&327'7OX \*69:5:WvmvPfH4"&\/O6[:y[>fG,7WDE'G"C`NS\AEZH%+#&-6=&-:;O[I,)++/ֱ+9901'53Bdυxx=.) + /ֱ +01&5473뮮>=.) + /ֱ +014&'3#6FL??ȃ bC++2/ֱ +999@  $9017&5367&''67& U E )JA85;#':78HGW"ZGB)0:H")E 7tM 2++ְ2 2 /ְ2 2 +0175#53533#StQQSsd:/ + /ֱ. +9999901353'67YeS4ddj#%R .///+0175! XXZd+(+/ֱ+01353Zfdd++/+013F )G+ + /ֱ ++  $9  $90132#"32#")[anm%&mt1++ /ֱ +999901!#5673tWEk58.C(VFmU++ /ֱ+2+ $9@  $901!!4>7654&#"'6329Y^Z_'IUkhN9AL[c}5gVMS"T2sNZeJ7EMC l)#+ + ++ $/ֱֱ  ֱ%+9@  "$9 $9#"99!9 $901%"&'732654&#"732654&#"'632u YpBQM?* ;OC2mW"^tdhxo[ V@>M LB64<hRd-  E+++ 332/ְ 2 2+9 901!5!533#'CHHaaY߬Q1QB)u+ +  + /ֱ++ 99@  $9 99@ $9 901%4.#"'!!632#"&'7326 @+T/RFd%@Fgyoa{ \uAW54E uU.fmj_a%!{+ + + "/ֱ ֱ ֱ#+ @  !$9 9@  $9  9901%#"!2&#"632'"32654&zeWaTN<q^u)<RA>ISm\p{_5 31Ja^IUJ0 1++ /ֱ+ 99015!#67670lPI [FKfwUDtq(++& + + ,/ֱ#ֱֱ)ֱ-+@ + !&'$9) 9 &#$)*$9999$901"&547&54632"32654&"32654&hklcx:he,IA54?C3?QV=AQU yb#)jKmV)<g)+cv9h@=24>V:ENQ?AR)#v + +  + $/ֱ!ֱֱ  .%+@  #$999 !"$9017"&54632!"&'732>='2654&"^wyivTk Tb1G!<YAJK~RTgi^Tq6QD/_N\EG_cIHSZ1+(++(+/ְ22 +015353Zfffdd^ddSs 6+(+ /ְ22. +  99015353'67YeeeS4dd^ddj#%R7nT;++/ִ+2+9$9015% 7x9RWX7*///ְ2+2 +01!5!!5!&&QS7nT;++/ְ2++9$9015-5&x9XW,q+(++ /ֱֱֱ+ +999 999@  $9014&#"'632#5&67>53O;x[c7U $V U0d9H g\+QR-W*ONBdd6.7D+3B 2+ +. +; /5 .'2E/ֱ1 +?8+%%+++ F+?98@ ./5;<BC$9%! 99+ "'(6$979B799;@ %+1D89?@$9!",99901%# '&547632#"'#"'&5463273327654&#"3274&#"326.}B~۱u|TW{\FPU/,`]6WG !6BEÙb{h>3N0+:.Me evaؗfi{nuRRG:[yZKA KKwU+4@LXJS=P++3++ /+ 901#3#'!3'&'f&mSNiJ 4&EP9PJg f + + + / ֱ2ֱֱ !+9 $99$9012)2654&#4&+326V+MI,eZIUZZNg\M&L4g0*64D,=?@3X++/ ֱ++ $999@  $901327#"&54632&#"tt'_?롮=]0uzkǰM9++/ֱ ++ 99901332!'32654&+Mnr̰TPe 2+ ++ /ֱ2 +013!!!!!PWsTTTS6 &+/ /ֱ2 +013!!!!SzPTV6w ++ +/ֱֱֱ +@  $99 99999$9013275#5!#"'&547632&#"~R0\c]a3V+2VN.hITpbfcg=vP ;+3+3 + /ֱ 2+2 +0133!3#!P_t__&4Q^++/ֱ+0133^_4@ ++/ ֱ ++  $9 990172>53#"?$,_TH/-& J 3+3+3 /ֱ 2 + $901333 #J_c:|tdVjrJ !++/ֱ+0133!J_`TJ G+ 33+3 /ֱ ++  $9 99901333##JZVe4WbM ?+3+3 /ֱ+ +999901333#M`x\b1431 R++!/ֱ+ "+@  $9 $901"&54632"32654.Cyb9/H^W*Gd4qs-LP Λ/Y[UP44[b:zRw>Mp B+++/ֱ2 ++ 999013!2!#4&+32MbSWanH6+"k++!#/ֱ+$+@  !$9 9 99!@"$9014632&'#"&7327&'7654&"+m?<IROabt6)/.O7Tgƭh+B>,˨ E-NNY+ 3+ +/ֱ2++9 99999013!2#'.+3254+N=xGB|x].+@(o̰UneÕ =0yu,g'z+ +(/ֱֱֱ ֱ)+9@   !"$9 9 @' !"$901%#"&'732>54&'.54632&#"gs[)J?^}ypmyZ N\<?;.bt{w:.:3\O^fmjk1/")BP$++2/ֱ +01!#5!#9xTTN;+ +3/ֱ + + $901%2>53#"&53b%9( __QJ "$2.bcup!++3/+901!33f`l4  *+ 3+33 /+ 999013333# ʾas_[HH4v )+ 3+3 /+ $9013303# qguvV *4++3 /ֱ +999901!33sn/GcJ )++2 / +90135!5!!vBYTTTC9#+ / /ֱ +013#3CjjHI++/+013G 9#+ / /ֱ +01#53#53llIHQ;++2/ִ++$9901#3#tZGYwQy#99y/ /+015!H@@+F++/+01#'3GqvF#$+ ++ + %/ֱ#ֱ+2 &+#9!$9  99 9 !#$99 99901"'632#&'#"&547>7542=@9T!n[[ [eNdK + T-6 Qs73$LOET,io! (,R@f+ ++ + /ֱ2+ +@  $9$9  901#"'#3632'"32>54&wi\4SY7XevCK,+(; B {L@EGmU=U)(@?Vq&[+ + /ֱ ֱֱ+  $99  $9014>32&#"327#"&&,IN+!V_pUoYq}Np9 iƁ Wh"b+ + ++ 2/ֱ+ 2 +@  $9 $901"&546323#54.#"32>gypl[4WQ46 ;)W64C vyF4@L$D@'j\CP%L+ + + / ֱ2+99 9 9017327#"&54632%!&#"QH`)Z.ushz" AOQ`j }}m:HS 9>+++ 3 2/ ְ 22+901"3###5354632&+eeXNN?P%.$-1C=C9IPN ."+ + 2+/ #/ֱֱ ֱ."W+2$+9 @   $9 99 9"$901%#"&732765#"&5463253"3264eaoT kO&:Vfzwi]<PIFIGTS S,'zCtxI=<kSmBN+3+ + /ֱ2++ 999 9 901"#3632#4#M;YY<_bQYXSFbhHB/++(++/ְ22 +01533BYYYgee.?+(++/ /ְ22+  9 90153#"'732>'3@YB@#""Ygee|hM J& B 5+3++ /ֱ 2 + $9013373#BYsm=h <@++/ֱ+0133@X4Bn+33 +3 2+/ִ A++++ 999 9999 9901"#3632632#4#"#4J5YN7gq!=dW]~YaWHTZZFQuBJ+3+ +/ִW+ ++  99 90133632#4#"BP5pWmHT<  Q+ + /ֱ+ +@  $9 $901".54632"32>54Ee3sr+N10,>! 4UX.zumZ;S(%>A%WB9 e+ + +/ִW+ 2++@  $99 $901#"'#3632"32654&{hS4YP9]iq@NBIEHGBCOEq\Too\Wn#9h + + +/ֱ ֱ. A+2+ @  $9  9$901463253#5#"&"32>54&#shb6NW1Wg{CEW7'9 KwQE3C;qWm[%=> Yw@Z>++ 2+/ִW++990133632&#"@P3=--"D NZSP(1-d+ +# ./ֱ%!ֱ  ֱ/+%99! #*$9# @-  !%&*$901%#"'73254&'.54>32&#"+CB WyvZ0@ (O68P,W fp*&Y!5>/D#lR!1 //,. TC  >C+ +3 2/ְ 2 2+ 99901%#"'&5#53573#326 $S AAWXX NN1T+C5C9 @U + ++3/ֱֱ. A++ 9 $9901%2653#5#"&53N<WN;j`QX-@YXMYdn@]J 9++3/ִ++$9901333^Zp *+ 3+33 /+ 999013333# [qn[fxT[fierq G+3+ 3 /ִ+ +@  $9 $901;737#'#imhzxo.J+3//ִ++@  $99 99901'327673673#"? :]mnY! 2Q+8?:R$.'*?  2+ + /+  99990135+5!6;I6,5;G|F9zK.7/Y)+* / /0/ ְ221+ 99 $99* /$901;#"'&/&'52>456&>76;#"+ g ;H!&a" ,7 8,*~M 1P &,1 #%%M:\."++/ִ A++013\MV.3%W + /! /&/ְ22'+9!%$99 $9017>7&'&'.+532+53265{2/U  -U!##.E ::3"WFO*Z<"M((&P=#V%)M(=+0 ֱ2ְ 2/+9 901"&#"5632327+!8G3T.@@;BBc;BCh7(M;E+0 + <+#A+)ֱ F/&ֱD!ֱ, ,.?2+ G+!D@ ;#$)E<=AB$9?9,*$920999 $9#0-.99<!9A',&?D$9 )67$999012326?#"&#"2#"&=#"&5463232=4'&#>264&#"r   "n#1  :r'9@2-='79*41'{lX0FM6 "(E+74(K4+,4;+3Q ',&&o0sy;m4@7#vp+33 +22/ִ+ + ++++999  99999  99901!"'42#"'432#"'4324t2:;2:;:<<::<<::<<:%wm<n9Rqo9A*pLmqCw/ֱ 01#53xEE~'j/.+/#.+(/ִ&%+!+%+&9!@'#$$999# !&$90126767#"'67>5#"&546264&#"/*5d9BW4<?>) $  "51.?#9N 34HjO +/($6&&tq.84/%?+//?+/+3 29/(ִ%+7+"+-22+(&97@ %+/013452$9" ,99.$9994% 999/"#278$9(999)$9 -$90126765+>54&#".#"632#"&546326"32654$.02 hS # &'//+)Jq8$**-&<+Ae :$) ##?,.C$$  @&/<3 :22A/9ְ=2 ?2201#3#5#5353"RttERRE2BTBTT@!,d%/.+/+.+-/ֱ" (+%+ 2"99( %&+$9+%@ !,"#()$99901#"&547>72>?363232654&"a8$2AaY& K# #1*)1J2>0 * 0&Q;E'+ 3<7+ +'. 2!'7+BF/*ֱD12 ?+$%+ +; +2 G+D*(99?!"'<=B$9$7999  8999 <%9B$?@DE$9!914$901%2503#!534#"2"632#"&=47>?.'>322654&"N%E6*#= 1'!>8,41Uc\b,,B) .)B{W  1 |,1-6;,!" " JT=Q+ +++/ִ++@  $9 999901"&5467632l.EE )&+2;k( %! +<B+ +/ִ ++@  $9  $901256765#"&5460EG )0(2<l( &!("0$z+.++++2 ++%/ֱ + &+9@ $ !"#$9 9"#$9901"&54>7632%"&5467632a/B0. -)/ED. *#(2#HA (9 %")*29n(9&!-E$y++ 2+/.+%/ֱ + +&+9@  $99 $9"#$901256765#"&546'25>5#"&546y/DE *00FF- .0*4;j(!&!("(1:o(9"%("hb6/+/ִ+ +9999901$"&462^XXXbddd) F/ /ִ++01!5! D)F/ /ִ++01!5!D `y+Eo]ɝ,ʝ\ˠ[̤{͛{Q(T +"3+ )/#ֱ" + *+"#99 $9 $901.'>32#4#""#4767VYi|E   W 'E#M[PZr9 1 B!" Q'/+ 2+ +"+-0/%ֱ++.2ֱ ֱ + 1++%#9'"()-$9$99" 9-@ %&()+/$90123253+5354654&#"#"&546"2641I&-T4EiJ-9& 543-5O,,,Q,. c6(vB4U.'?':;-2V]&&(6K2: + 2+(+*+3 + @+8 +;/#ֱ: 26++ ְ21 ֱ- + <+6:@  !(348$9  )$9 *983#6:$9 $1$9)$901%253+537654&#'632#"&54>77&264&"3EA)G&ID 4,3)+E2#PQ(> ..B5.A5B` %%%! ;%)3?G,<8..G!!((Q+3 +$3+ , + 1 +4/ֱ %ֱ# ֱ3/+ + 5+*9/#@ ! ,-1$99 9, #*9991+/3$999014>32#4&#"54632#"/#54'.264&"7iGevEVO4J$11+97' E 4,,y$FD*nVs@J"62*D@#D5-)5b _U:&& Q2<+%3+133+9+=/.ֱ +%6+%++ >+ .,9&'(9996%@ !12349:;<$999#$,$93!999@  .67;<$9 /2$901#4''&54>32"/#4.'.54672654&"Q7SE?OS-B 4$(;33 H (OjC$00Q YNb^ ??V<T-%@<#51(4 J^<%)_X/Nu'4QCKV+3L +=+?+.  +Q D +6I +0W/9ֱK .2ֱT323.G+ ֱ(P22 2%ֱC + X+K*067=DEI$9TG1>)$9 VLM$9%#?99 C999QTU$9 9ID493GK$90#.:$9 %&'()*>C$9013653#"/#"&546354>54&#'632#"&547677264&"2>="* E*&2$2;;C&ID 4*4)+D?PQ3 .."*!7:"+ $yI#3F21U $%% ;#*3?G5.? ..2(( ^)%%Q#+ + +) + ! +$,/ֱ+ֱ .'-++9@ !"$%)$9'999$!9)#'+$9014632#"'.'.'52325#"&264&":*41)-!5 D&)"&8N,,.4;,T& ?IA14*3&& Q$, + + % +* +-/ֱ,ֱ .(!+ .+,9%&*$9(99 99!$ $999%9*(,$99901"'632#"&=#"&546323254&264&"';>`q@2.<)79*51'K,,bZM+74(4+-5;-356:&&RQ1>H +3 ++& /ֱ5?ֱD ++I/ֱGֱ .B+/ 822+J+G)9@ '(H?@DE$9B 99@ "#$&+,$9/9256<=$9 ;<=$95@ 1 >23$9/"99D?BG$9&()9901%#"&=#"&=#"&463232>76754&#"'63224&#"#326%264&#"R6+)0)7:#3(7:*32 %$R>|14Cay-M< bp<7/$HAX+2t4X4<+-+: 4>_YL:F0V&&+~6C,+- <2+5 ,+D/ֱ+2 .ֱ< 2ֱ7 ?+( E+9 $9 ,-5$9<2979?$#99 -:95@ "#$1237$9901"2647#"&54632>7>5#2+5354654&#"32=4'&w,,4/7/4OSx* N!7O $hJ-:%-T4&&=<$><,2VN4E "1vB4U.'I "_62 b~ N)+ *2F+H3?)F+)F+9O/Aֱ+<++22 +% P+@ 4679?F$9<)*3:G$9+-H99 "#$9<=A$99,7B$9F@ !#-234"G$901"264&2=4'&/67>5#2+537&'&/'632#"54>372s,'2.!H/!6O PiJ. BA 4-01j#-!QP+  &62 34E "?8vBj/ ""1 >$&=0P*""QNV`0+'33Q +; "+.W'. Lֱ\28ֱJU2a/ֱJ ^2Z+3+O8+T2 ,2"+# b+ 9J?9Z@ <LM`WX\]$9;D99O31980QR999"'()*$9QW)99\*3OZ_$9JN4,$98L9; ?@DE$901%#"&=47>?.'>723253#"'&/#"&54>754#"2"632326="264&#"9*42V\el )E &0 + ,4#%9 -'';A 0`-5<+!" "GNB @'95" P-E1$2 V   1 |/6 j&&Q;E_i.'+ 3<W+I 7+ +`W<+R]2'. 2!'7+Bj/*ֱD12 ?+$%+Z+c ֱI :2hִF%+RֱS ְ2 k+D*(99?!"'<=B$9$7999cZ 8 999h X`af$9FIMW99RNPQ999IWLMN999`@ _GFZ[cdefhi$9 <%9B$?@DE$9!914$901%2503#!534#"2"632#"&=47>?.'>322654&"#3276?3#"&54672&"2654N%E6*#= 1'!>8,41Uc\b,,l E#BhUF`--*3F((B) .)B{W  1 |,1-6;,!" " JT=#G$$ ]w@@%74",QHP[+8+I+$ /QW/>+N\/;ֱPֱZ Aֱ4 4.L!+ ]+ZP9IN$9A>?8J[QX$9LW94*R$9!@  $%/STU$9WQ  TUZ$9!99NI65<;LP$9>A9$*+/04$901.'>32&'#"&4632>5374#"2"#"&5463254>7264&"2654&#"UYek:(EN&?G:":E HO-3(24):6)   k,,P 51!L^QJS)^;MN=H8u   2!+<5,+4 &&3"#+QKS_+>+L+, / 33W]/D+Q`/AֱR2ֱTGֱ: :.O)+ a+T?LQ$9G@ >DEMWX]^$9:O0[$9)@ ! $%&#,-5$9]W@ #&_TU$[$9%99QL<;BAOS$9DG9,0156:$901.'>72''#"&54672>537>74#"2"#"&546325467264&"326?&#"TYei <-DF45/(2'2=IL&A 1&23+97( a,,  KOG+S^_I!)?&+E Wy#kt (W\   1 +<6-*34 &&% #M;Emw+0 + S/hִv.+{ְf2Yq/F.+<+#A+)ֱ /Vֱ~&+D]ֱ^!ֱ, ,.?kִs%+Ld222ֱK 2K.e+~VT799&{|999DSYZxy$9]$EBP[\$9!@ ;#)<=ANab$9^9k?*Mc$9s,mi$920Fhq$9eGv99K wno$9SPM99hKaVcdeb~$9v{W[99qYkst999F]^l999#0-.99<!9A',&?D$9 )67$999012326?#"&#"2#"&=#"&5463232=4'&#>264&#"2'&'#"&54632673775#"&5464&"264&#"32>7r   "n#1  :r'9@2-='79*41'{lX0F jDO  $%-3&:<B4  *+? M6 "(E+74(K4+,4;+3Q ',&& ,&bG.. 2"'.*?$Y ) + (H K Q>F+3+ .+0+?+'D+!G/*ֱF 2B+$+ְ2 ֱ4 + H+BF!'(.?@D$9$"/99909989994> $99'99D?%*$BF$9!+8$9 4$9/$9012#4&#"#4>54&#'632#"&54767767>264&"` >EI&ID 3+4(.B>PQ3  F&@0..N@' ;5 $%%  :$*3CD4.? ..2 ! A~+<=((SS[c$ +3a F++R3+. [ +8W +?- +S d/Mֱ1 <+G2Y%+Tֱ-S22B%+#ֱ^(+\2 2+ e+1MK9<39Y456999T@ .8?@CEFRW[$9^B!,999( a99 $98 @ #$3456CK\^_$9['(99W@ 21=BMTU<Y$9?N9S-,.990132653#".'.'#"&54>754&''67#"&54632#4'.54>74&"2325h&2  %EJ(%)+7& +TW=0.5 $35+,7` I 379)N,,6S(>#4@g!P1J5$5 +5>>].=`Ag2)':9L2 (E$^P-5Q7"<,,R=( 5QBMU'+3K +6+ A+'.N!'6+SV/*ֱU Q+$+: 2@+ H2C+W+U*(9099Q!"'NOS$9$99@ 999KN%9S$C:QU$9! D999@ 03?@GH$9012#.=+4#"2"632#"&=476?.'>72>7>334.#;2264&"4K;-.+1KC&@ /9&!>8,41UYfh.2EE #,,>J;@4$`\;Y  + 1 |,1-6;,!" "KPC<T&" e#&&%N*4+#3+ ++1+5/ֱ)2'+#.+%++ 6+#'234$9.@ !"+,1$9 99@  !"&'()$91+@ *./34$9 9014632#4&#267.54632#4654.2654&"%[k|EXGKg/2+#=7-*:%R<:;00oc|fMe9G]S7U]R7+)85*-> 7 f6S2> +3+33 +-9 +" + ?/ֱ%0ְ 2 <%+6+%++ @+%90'9<()*999 2#996@ "->349:$9!99- '()*$93.99@ %&1067<=$9"9!#99012#&'.54677#4'&''3767.5462654&#"+7 8 J6(`gCK:')EPS|/$ :09,4* Pj ,A*\_1Kz44 .,Ma7! ::.ALN56A"*6 Q5?-+ 36+ '-+;@/0ֱ>% 29+* + A+>0.9%9999@ '(-?67;<$9*$9 9;6+*9>$9'%9@  $901.'>32#4&#"2"632#"&=4767264&#"SZi{ERF   -'(79+32: M[PZ;7  1 |3*-6<+"! &&,EP*4 +3+'30! ++5/$ֱ3ֱ 2..+ 6+3!"'4+,01$9.(9$9! 9+90$%.3$901>32#<.#"##"&54632264&#"N`8+ E 2D E!>9+41e+.< H;:VJ,1,7;,(&&N$/ + ,2+3"2) +ֱ 20/ ֱ+ &+ 1++ "#999&!99 999 &+999$901#!53/"547>3227#"&#"5.'&'326eM$'&4$C5<H;)y-8653. .%n#( #6Bq#$ 9#$^P!)1+ 3( +3/+3 %2 +*2/ֱ1 ֱ 2.-+2 "+ 3+ 1 *+/$9-9%&'999"(99(!"#$9*  9/-1$901%#"="##"&5463267>3324&#32264&"A*X,E'89+41&D#U E7G@& %,,CAt\}R4*-5:-6-?JI2"[:&&P!} + 2+3 +"/ֱ! 2 ֱ .+ #+ !$99 9!999901%2653#!53#"&54632264&"E6%I&4:$12x**B )0BT2*5/<+Y&&v!z + 2+ +"/ֱ! 2 ֱ .+ #+ !$99 9!999901%2653#!53#"&54632264&"E6%I&4:$12x**B)0BT2*5/<+Y&&TP&+3+3$ + +'/ֱ& 2"+ +2 (+" $$9  99 999$"&$9901#"/>73#.'#4672264&"2' ]32fBB^,%ZB2/"<s**)3u#" 0!yL'?/`&&av&+3+$ + +'/ֱ& 2"+ +2 (+" $$9  99 999$"&$9901#"/>73#.'#4672264&"2' ^12fBB^,%ZA1/#;s**)3w!" 0!yL'?0_&&JP'/+!3+ 33-%+(0/ֱ/"ֱ !2.+ + +2 1+"/%&()-$9+9 99 99999%$9('#99-+/$99014632>'33#&'./##"&6264&":$13*JE1EEDI! !* G;I**5/<+RK@ d1i.n5F}.,&&Jv'/+!3+ 3-%+(0/ֱ/"ֱ !2.+ + +2 1+"/%&()-$9+9 99 99999%$9('#99-+/$99014632>'33#&'./##"&6264&":$13*JE1EEDI! !* G;I**5/<+RK@ d1i.n5F}.,&&.VQ,6+ 3-+ %+27/"ֱ42(ֱ .0 + 8+(@  %&6-.23$9099 $92-#"05$9%(9$901.'>32#4&#"2"#"&546325467264&#"TZh}ESFW6 1&23+97( J"M[PZ:8"  1 +<6-*34 &&=!P*2<+33+30. %+7 (++=/ֱ2 ֱ:%ְ62 2..+ >+:2)99%@ (+,0<34$9.9997  !:;$9%9+(&90*.2$90146323653#"/#"&54>35#"&264&"26="=8,41u (E,!n4#2< 5$(7N,,0 #-6;,#7:!, %yI#3G2*+3&&[^)%VN/7+ -+35 -+.+-+08/ְ)27 23++ 9+3$-.015$9 99 $9095/37$901#"/"32653#!54767&'.=4632264&"8&  $%?  E>22. 41+9z,,+3! ''?)#7:Bo(?5Y&& O-7++.+++3ֱ8/ֱ6ֱ' '.19+699@ +,7./34$9'1$93.-16$999 "999999017463254&'.'632326?#"&#"#"&264&#">! A@!P:>#g! #k!7pQ/14+9c`2,'4  } 4  170,;5&&)Q5?-+6+ '-+;@/0ֱ>% 29+* + A+>0.9%9999@ '(-?67;<$9*$9 9;6+*9>$9'%9@  $901.'>32#4&#"2"632#"&=4767264&#"SZi{ERF   -'(79+329 M[Py;7  1 |3*-6<+"! &&4O1;+32+. +7+#</ֱ: 5+ +*2 =+:1995@ #$/;2378$9.99 9725:$99*9.#19901>32#54.#"632#"&=4>3254&#"264&#"4!eUM.WEFh$)69)43 / +&;AOET W7@2fd?#|4+,5;,$%#M:?<!|&&).Q,6+-+ %+27/"ֱ42(ֱ .0 + 8+(@  %&6-.23$9099 $92-#"05$9%(9$901.'>32#4&#"2"#"&546325467264&#"TZh}ESFW6 1&23+97( J"M[Py:8"  1 +<6-*34 &&Q$l ++  + %/ ֱ#ֱ .&+#@  $ !$9  #$999901>32#"&5463254&#"264&#"jV_q23+97( LG<P  7T`H+<6-*3B7?)&&"k(=G+!3+9 +>+C+0H/ֱ) "ֱ ,ֱFA+%+ֱ ֱ I+)'9A @ 019:G>?CD$929994999 99> ',999C@ ()*AF$90=2$9949999014>32>7#4'##"/#54'.75463267'.#"264&#"5fFo5? 1 EN7& E 5@08$85 3#3K$w%GD*:8-?>sn9>*3b`U#*B@&A ; !63u&&P8CK+ ,2(+3I ֱ5ֱ1 ִ>.+Dֱ"L/%ִK%+2ֱ, ,.G+A%+<+++02 2+M+K"#(DEI$9,G)9<AC:9$956999 9 19>@ 8C9:<AB$9"9 9ID%GK999(&901463226?3>7#!53#"&54632326=#".7264&#&264&"/,#+ E*4=/< J;;"22 $E;W**G&40!'5 ? L1(BT,24.<+Yx4$&&#%V6;C+ 3<4++ +4+A4+#D/ֱC ?+%2 +72 E+C.99?@ #,<=A$9$+4999 ()59$99A<?C$999;99#%799+()./$9490167#54.#"632#"&=4632>3&#"'>32264&"*3(EFh$)69)436=1##8rCM32J-Qb!1.>!,,#6+#0 S?"|4+,5;,*I#B:##$&=x$FG&&Y :B+3)+@7+#7+;C/&ֱB ֱ- 2-.>4+ֱ ֱ D+ B#$);<@$9->*9 07$9899#-99; !0$9@@ : '4&>B$959014&#">7#4&'##"&54632>7.54632264&"2  7  #E 9AFE)6:)42'h&53(2A,,/  ' #:44*:fkv4+,5<+G )6''J&& 5=,+/3+;+ +3,+62,+ >/ ִ=%+0ֱ .9%+++ ?+0=3467;$9@ -./$9+ #$$93,.99965199  +9=$9; 9$$9(9014&#"32646323#"&54632>7# ##"&6264&"": !96#$75(\2A5ZRD.!,$ AXU 7H** '!/.5f?l =K @*L N/&&9Q(0 + +& ) +. +1/ ֱ0 ,+"+ 2+0 (9,&)*.$99"9)9.,0$9&(9901632+"&=4632#';2>54&"264&"99Tk5"65/!=5&"BzR9**t_N1+/3(@.5)5f.5>/(&&W8DL+" 3+<+E3+J3+-3+BM/0ִ+? ֱL Hֱ(ֱ N+H@ .=EFJ$9-3<B$9(+49C$9999E9JHL999B-+9<019?@$93901>7+"&=4632#"/;2>54'#"&54632.#"326264&" 1' &262(33& CXMoL"5#-!. 7]V*.1**+!< (6,(>7T5#  (?E  & &&"O.6++34@++'+/7/ֱ6 2+%+*+ 2 8+26/04$9'99* (999.999 99'9/9426$9*+99012'276=#"&5462#"'32654&56264&"'++)$Y<UYGT35' O_,,O ~I$#5 +%5iIB@/(*8  Y &&@ <"*2(+2+/+3 /30/#3 3/ְ 2*12&+-2%+24+&*@ "#$(+,0$9990 !.2$9( &*$9012>7#"&546267#"&54>264&"264&"$= :eQ;Q9*#> wEP;P9....;,3R0dR75+6-3"ndQ76+6((((N"^/ / #/ ִ"%++%+"  $9 $9 @   "$99012>7#"&546322&264&"3aD( ,UZR40+4t00%5*m(;L-)=8& **gP+++ /ֱ + 99012#4&#"'>7K$E*;% 4 !6P49%^E9 $$gE&s  ///  9901.#">32632&#"pB]Cop{e_GLIW-pf*a| c8/3// ֱ  999 901.#"&63253%632&#"bC_Jjk^&=EFNON+qg)] 0d!*$//) /@++/ְ2!%++%+!%99&$999$"&99)9!$9$901.#"46323&54632264&"632.#"h6 %?Y@Gd<`  .-*3q**FQ=]R5go=X@d}43S$&/3 K// !/ֱ + 9 9999 990146325353.#"7632.#"y] D$C AY@zlNDT<]Q5i_wEQt# ,)K/3 Z/ // ֱֱ .  9 $9 9 $9 9012#5#"&5462654&"[E 8+  #\s',&/u  `s////ִ%++ + 9$999999999 999014632326=3+5#"&6264&"`1#,,- @# ".A  z%-1% =n. <2/+/ִ+9999901"&4628 8!$2$$2I// /ִ+ +%+   $9  $901"&462264&#"z`55`6f<T<=R!.!!.! PC '/5>JV_gr/`3c.+.+(ִ-.+ִ#.+0ִ3.+W/\.+/.+ ְm2.+m.h.+s/^ִ%+Y2%.!+ִ+ִ+ִ +p+e2k+a2HִB+/ִ++<ְ428+1T22T.N+t+%^W\99!@ '#$9@   $9kp@ g`cdrhimn$9/HJF99B)-(?@E$98<03>6:$9NVKLQR$9cf9-+/$93#!9%&99\0PQR999W@ VLNOTUKYZ^$99:;999>678<=$9DEF999 @ J?@BCHI$9hkpq999012#"&4672#"&462#"&46'2#"5462"&472#"42#"546'2#"&5462#"&546%2"&542#"&462#"&546T  l    [  z  e W      0      Z   0   Z   P  h$$  Z      $     :s+TC ;++.3 2/3 20/43 2<//ֱ 2+-1222 +3222ֱ: ֱ% =+9  9 %&$9 99:999015#5#732654.#32654.+#5#35332ggg9B;3) DA ?M%"&74VFF079&L4!0.A,$' 32P+^^UU%H.j]&N b++ +/ֱ ++9 $9 $9  901%#"&53632264&"&:)42E)6y,,_,5<+j4Y&&]1N #++3$2+3 +3!(2,/ֱ +'+ֱ #+-++9'$%)$9#9 !$99!#'+$9  99901%#"&53632#"&53632264&"264&"1>%42E!>:)42E)6,,,,b5/<+j+4,5<+j4Y&&&&a,4#+-/2ֱ 2ֱ5/ִ +&ֱ4 0ֱ 6+&$94 $9990@  #-.2$9 992-!& 04$99 '(99 9999016323267#"&#"2632#"&54&'.264&"<Ck&g!0j  J )6:)42!1!M,,]" 2+ +"4+,5<+"#&&^",6+- /2#/.+ /).+/ 7/ִ+%+&++ֱ 50+8++9& #$)$9 995990 !6-.23$92-05$9 "99)#&'+,$9 9 9901%#"&54&"7232#"&546326322654&"264&#"^9+41". <#!.F@9@!>a,7;,0$N&1-9EY@1(,&&+5+,)/1#/3 26/ֱ' 4/+7+4$99/')*5,-12$9,91/4$9)+'99 @  $901%#"&554#"#"&/4&+526327>32632264&#">$32 . 1  ;8#)"";b`4.<+B <$+9)4#-, ,a&&i&N+/ֱ +01#4#".>32DO:0   !?-):u|') #2'J N,4+3/-/'/25/ִ +# 0ִ*%+ . 6+#90@ , '(-.234$9*9999992-+*04$9'$%999 !#$9017"&54772'267654'&#'"632&264&"?AGC ="6I H#!JC4)012G.._I$11 9P/!3:0&&7#@#":.((066++ֱ ֱ32+ֱ(ֱ 7/%ֱ 1+%+1 @  !"#()*+3456$9,-./$969 99 %999 &901#"&#"632>32#".#"&54632326=34#"3@:'_6(.5/&-+ 0(;]RC_/%Jr # +'**& (N$`DA 44M/ֱ 01#53qBB$ִ +ִ .+. .+%/ִ+#+ִ+#9@  $ !$99 99 #$99901#"'67#"&46>72654&#"1 9D"*.-(PDwP")+B-M =i1mN.8// ?+/4;+&/*3229/#ִ%+2++(22 +-#!92@  &8/04567$9'99   *$9-+99/  $9427$9 #999$-999&(9901>5#"&#>54#".#"632#"&54632632264&#"9$4/ cN 1" $%.)0%01  S@*?b<!? #":,*E##.-/+ ,/ 3 2 /ִ +ְ2 201##5#53533 P?TT?PMM>RR{##.c$/.+!/*.+//ֱ, '++ 2,99'!".$%*$9*$#'(,-$9!9901#"&547>32>?36322654&"m4-:YP# B !  ,Q&&+D-8,   *LyEI// /ִ+ +%+   $9  $901"&462264&#"z`55`6fy<T<=R!.!!.!:)#s+.+/+ /=+$/ֱִ A+999"9!$999 $9 901"5463.54>32&#""327jKL '"N5&&8&"9F& +P'D!   #+"#O %+ A+/C+/#.+/?+&/ִ++%+!+++ +'+%9!@  #$9 99#@  !%$901!"&54632'264&#"6"&462264&"6mzzmlzzl]hh]^jj|GG|D^44^4]^^]vvvvENjNNj0:P::PQ&H+ / /ֱ + +  999   $901.4624&"26&|}~7TTUU-vtrDVVDCTTP:+5&+ ,/ /1/6/)ֱ +4/+# + 7+4+$9/@  ,-12$9#! 99  99,$9991@ #)/45$9  9*9012'654&#"327#"&54>32#.546264&#"?v!- 'odJLeG*% ':1&19PJ][M*m2W5-15S_UJHD3**%C,<gqVhp$VfKU+1L/I/Q /3:B2)/# V/ֱ- +TO+7+ W+T9O@ CIULMGQR$9 BJ9997:;=>?@$991./999L9QKOT$9I?>99:9 9# !-99901%#"&54632>32#!"54&#"526323!2>=4#"#4&#"632264&#"e5(*:J> %37UQ' 8/, -1%!  '1\+8J9Ab A2Wa<0%o=':  3Q  (V5@1+6+++/</3$ 2A/ֱ> )29+. + + B+>&'(9999%+12@67<$9.$,999 9 99$961/9<.9:>?$9+(5)999$ '$90174>327>32#4&#"#4&#"632#".2654&"( &@)?B ?KD&$-E730,-29&%2 y*48*?    O;)3:%!;V: ;+(4"AEr0<E+5+ ִ:.+'/B/ F/ֱ $+E@+)+ G+$9E<$9@@ => BC$9)' +;$9 145:$9:49B @ $%)*+1=>@E$9'9999 99901"&54763232767#"&#"326;".5462'.#"6264&#"WaHDxRj+2B<,8bJC3H =B5\52I3$ 4!((zMc?==Fa2!*?M E)(=:(5 6 "$*dnx+F+ >+%ִC.+-/tRֱ Oֱ m/\ b/hy/Jֱ *+w_ֱj rֱ0Q2Tֱ ֱ z+*G9w! EF$9_@ "-OPxotu$9r%p99j.]29990D9T@8CRVWXY\bcehm$9d>999<=999 C<=99t%@*+0128JKxoprw$9\O9mTUVXWY$9h_ejk$9b`990107>5#"&#"326;".54632'.#"#"'&54>323254&543#"&54632.#"32264&#"& A"]o.G) D4 G(2&4.-52J$ 3!$N0:3iHbk9".><4%=!$3*H 6 )!0 "-'@M  9 (<9(6  6 4:X#FG-*/&%37 "$:0(2+ /,/ 3/ ֱ.)++ 4+.  !$9)(& ',12$9$999,@   )*./012$999999'9012#"&546232654&#"#54'764&"32b:V+v^Iq7V6&BSS?4?m<08*+ED"]rG>+;7);WB?U /'Ê$<DT6$$ ZIU0+J+++0+P0+$3:>2V/5ֱ' M+.+A + W+M'@%$)+01:UJKPQRST$9.,9@  ;<>$9A?CE999 99PJ.ECMNST$9+()B999@ '56<AI$9:9 99014>73#>54#"#4.#"632#"'.547>32632>52654&#"@ H)eF=> 8%)74%54,3B4E$$K7=5$#Su0N1!;$@Z"/&!L^- ,_;:L<]3C502BB[DpO7`><bJT?+63% Kֱ* ֱ; 0/Qֱ HֱU/Bֱ -+SNֱ3ֱ V+-@ !#9:;<=>?HI$9S+J7$9N@ %&)*06KL'Q$919993 9%?>@99;*#49=$9 K-3NOST$9Q.B9990C9012654./3#"&#"4>32325"#"&54632#".#".54>322654&"A:E[W!=] !?3B .84/53<9%N50 Tk !2V6n ((7J hP GR( #+,6,4)':G4>Z)1)'/-uT49, CNjGR7+%+K/+1/QFֱ Cְ=2 =. S/:ֱ" .+HN+4@2+ T+."89H ,%7=$9N@ &)+1>KLQR$9429@ CDEFG$9 999%799K+)599Q@ #"/4HI.NO$91:9 ;999@9CF 99014.53#"&#"4&'.#"32>7#"&54632#"&5463246323232654&#" H",8;f8J"()1201 "*'-0)D<OR[J,@> XQ-AYW$bu:'!<b=;W 5$!<B.=[~W[t+*+ >e K++3,2E/4 /@ְ 2$ ְ:2L/7ֱ +=%+1+ &2!+ M+@  5:;@AB$9=4E991K+,FIJ$9  999!$%$99@E19 B9$ &=>$9J99014&#"32672>32'>54#"'276=#"&5>32#"'327>76 '('/7* -*+#"A1V[D-/04*.0?-t !-A6+&N#$6"-:#p_.C5'+8 )*[ 6:0B#LT2/ 3'/A/H.+"/Q/-U/ֱ/ +S%+O+%%+*+V+S -99OM"Q$9%#'2$9*939299'09HLJK$9A&<9TMN$9Q@  %/> OS$9" *999-+:;=?$9789901%".'''#'#"&54632#"'&46322654&"327>7373773236;"#%254#"t 4097&:/'=\_ogPMSBA/ (,&,6lM_;],> 6&044'@(,4*_EL0KcfjNEq).@1*',P48IyJXnh0&龽) !"` (4+/ִ+01!!44p: 1+(+ /ִ+ + $901#5#5fOnddz49#++ / $/ֱ!+%+!9@ #$9 9999@   !"#$9990146327&'327#"''7&#&4ym767XT #krYzO:67HI;}!o 6 _dAcf+.+32*+ -+'+ֱ -+"3 $2//'ֱ ֱ 2-+,0+ '"%999 9 $9-@ .*$9,+99999 99 !$9-9(,99901"3#632327#"/&#"'654'#53&54632&#4I X(*"<I- OD"paL}`WC53ZI`[ P$.U?%IO2^n ~#sS$+3 //%/ִW+"+ &+$9"@ $ $9  $9 $9@ "#$9 $901'76327'#"''7&47"2654&hE9C5@A2E9E##E9E2A@5C9E#5JGpFJC;E##E;C33B:E%%E:B5|AF95JK47H)V+ +3 +3 2 +3 2/ְ22+ 9  90135#535#5336?33#3#ʥchŧ˟DEI[)"((IED\.(++/ְ2 A+2 +01##MMM~(.-9+ / :/ִ6W+ֱֱ!ֱ ֱ0ֱ*;+699!@  &.2348$90 ,9'99@- !"&'*+,.01234678$901#"'732654.'&547&54632&#"'654'&'mUYh+>H\j7n?gKZW-8%4:\8nNzH30HzI3GX s/%F5E6Aj ;@CV k-!0$% <5B^.;\%5<Q #'8;H,m/-+3)+2/ֱ+ +0153353\Y[mcccc4+ + #+(+05/ ֱ-+! %+&+ P+6+!- 999%@ 4#$()03$9&12$9#(9@  !%&-.23$90 9012#"&5476"327654'&"327#".54632&skjklikZYYXZY~=C|_<%$@;"i]$:!jkkk֚ij<ZYYYY\TG_.U:`ptKm_!o+  /"/ֱ ֱ +2 #+   $9999 $9 @  $901#"547>74#"'632#&'32 ;BxG MH DH  6%*@f4kEK=evB  1@# I/ 3+2 /ִ+ 2 +@  $9 $901#'73#'73GG?II7!ִ+/ֱ+01%#5!5!SyQ .///+0175! XX3:+ + 4+.:+1;/ ֱ0+. 427+ + P+<+.0 9997#$9'999&99.&'/0$94 "#$9:7$91 9012#"&5476"327654'&#'.+#323254+skjklikZYYXZY( &61P##%ANagHjkkk֚ij<ZYYYY\/  WM?#=:7</ /+015!F???N N+ //ֱ++@  $9  $901"&5462'"3264&9NPnQR6#/0"!22P86QQ6;M1"$/2B2&Y A ++ + 32/ְ2 2+ 990175#53533#!5!S(SSS e=Y+/ /ֱ + @++ $9999 $9013!>7654#"'632:<l7>@(D;J|q+FL<E0.#78j]<++//ֱ ֱ ִ A+ ִ A++9@  $9 9 $9999$901#"'73254##7254#"'632<Z;F:MN L:5F kDU5;i7B643,2 \Z;mF ++/+0173m@skFN9T + ++3/ֱ2 + @++ @  $9  9901%2>=3#5#"'#3(4 VO+WJ0XX+C CK8=I@0B=$91+ 2/ִ + . ++01463!####"&zm6FSmQUqckT?sZ./(+/ֱ+0153Zf.ee43 H/ / / ְ2+  9999  99 9901#"'754#73O>--OLBSq-/8( V4 4e6++ֱ  /ֱ +99015673.?K46e#>BjW J+ / /ֱ + + $9  $9014632#"&7"3254VKLUULJWWWXSfdTScdxvyuC# I/3+ 2 /ְ 2+ +@  $9 $901'3#/3#HH=LL44 q+ +/32/ /ֱ +2 2+  99 $999 $9901356735#5733#'5{K&.?K46ҽ:44Eq #>BK=5K41 #+ +/ "// $/ֱ + A+2%+  99@  "$9  $9" 99901356733!4>54#"'632pO.?K46F&+V.BC.B8Iy #>Bh<%@;<51146j4 +.+++'/,3")2 /%2// ֱ ֱ ִ A+ִ A+!+,2& *20+ 9@  $99!#$.$9&%99'$-99   $9 999$9013#"'732547254#"'6325#5733#'5{LuZ;F:MM L:5F kDU<44Eq 5;i7B743,2 \Z;K=5KM.u+(+ /  /ְֱֱ2 + !+ $9 99 9@  $901#5327#"'&54767653ec[S9x[^AHl/U (Jdd8H 35\Y^(##@ 7!-A"$Cx"$"$H"$K"$"$JE+ 3 +2+ +/ ְ22+011!!!!!!5!3#YKNu,bHTVT"V33"&Pe"(CPe"(Pe"(HPe"(",C^",!",H",]+++3 2 /ְ22+ !+99 999013#5332!'32767654'&+3#MOOp>M/1M48j/aEBE TTTBFa5BMw"1K1"2C1"21"2H1"2K1"2N7 N/3 + 2 /ְ2+2 + $9  $901?'77'N:::Ǜ<;<(&++'/ֱ"+ (+99"@& $%$9 9999@  "#$%$9990146327#"''7&"&2654'.xcS/ULY[uhQ1WQYGe4-kKYt+KdN\(aockK\)az6Z^4cR?|]Vh:N"8CN"8N"8HN"8"<Mp J + + + + / ֱ 22++999012!##34&+32\@_M(__bK_:,T<ْ̒>@KC)+ ++ */ֱ$ְ2'ֱ +++$$9' )"999 !$99@ !"$%&'($901"#432#"'732654.54654&D4WLhIHTgJy9L'=)1'88'O8UWM>((@= 4LYv#Q3#-&(6"+#"DCb#"Dy#"DHm#"DKm#"Dm#"DJh R$*9+!35 +3 (22%ֱ ֱ+ :/ֱ3ֱ ++2%2+2;+ 39@ $ -.56$9#999!"()$9&95@ #.3$9+-9%999  9901"&5476754&#"'632632!327#"'!&#"32676OcP,4?{U‹(?go;@j\7xIa>RVE*5 d7S RB ?1e FFKOmm bbBQt Q2&&3"Fj%"HCb%"Hq%"HHm%"Hm "AC["A!"AH"A#*+ +3+# +/ֱ& +,+ &@ * #$$99#@  !&'$99 $90174>32&''7&'37#"&2654&#"# /P344't(=j'iUns~INQGIJ//!CI8$<-?26')11*xEnXSnpY7P&B"QKq "RC\ "R{ "RHm "RKk "Rk&& 4 /(+//)+ /ְ2 2 +0153!5!53c(cccQdd@(&# + ++ +$/ֱ"+ %+999"@  $9 999 9@  "$9901746327#"''7&&#"%32654@tKE1.39tL>2.4>R..KO&0MO~+?!DKs~(B#CG #sTI2nXI@"XC\@"Xe@"XHm@"Xj."\\B9k+ + + /ִW+ 2++@  $99$9  901#"'#3632'"32654&{hM:YY8UitBLGDEHGwBBRvWVmo\Wn."\Va++/ֱ+0133aX?$+ +++ + %/ֱ+2  2&+@ $ !$9 $$9 999990166325!!!!!!5#"4.#"32>?C%MZ@L(O7`^7O(TmaTVTgsw2][67^`(&-+ 3 "2+3 *2+' ./ֱ%+'+2/+%@ & "#$9 99'@  *+,-$9 $9'99%99901%327#"'#"'&54632632%"3264&4&#" TGe X,CIxw??v@Dzvy3HMKGRQR;>TMbl bbKGwcc>V1[mroDRW?,g"6I"VIG"<.!K ++3 2 / "/#+ 99999 9017327#737>32&#"3##"> 5 Vb b =C%D+   c c^i,K KCBGKJ   3C F@;++2/ִ++$9901#73#8ej^lbUFH;+3+/ִ++$990173#'35dm]je~RP3 V +.+/+/ִ++++  $9  $901#"&46322654#"/*'00'*/W45 83N07V$646TJK+3+ 2 . /ֱ + + @  $901"&#"#4323273Z '@dY?V,.o()n4|eB/ + /ֱ..%+ +999901353'65=^Q6ePv#"L"| eV+ 3(+ 2/ֱ.%+ ֱ  .%++9 9901353'65353'65+]O7h_Q4ePw""LePv#"L#W &/3 2 /ְ2 2 +01#53533#YĩPNN#WI+ 3 2/3 2/ְ2 +2ֱ22 22+015#53#53533#3#YũNcNNN "*1+ +/-3 )22ְ%2! 02ֱ 2/ֱ + + + #++ /+' 3+  $9 !$9/+)%-0$9!#'+$9 $9013432#"73254#"432#"7324#"432#"7324#"%@ˌHG@BEJEBDCHGACE2»}}}|},#9/+/ִ +2+9999901#'73HH?#9/+/ְ2 ++9999901'3#HHn?gf+ 33+22222/ֱ ++ +99 $9 9901#5!#333##E`ec_<g=j?S::=sLSvB$+/ֱ + +015!#5#0J33 N&II &IL &IO &I'IL* &I'IO*X*=R  $        /  D 2Y     HtBGenerated by NECTEC for Public Domain Modified under GNU General Public License by TLWGGenerated by NECTEC for Public Domain Modified under GNU General Public License by TLWGGarudaGarudaBookBookGarudaGarudaGarudaGarudaVersion 2.58: 2008-05-16 Version 2.58: 2008-05-16 GarudaGarudaTLWGTLWGThis font is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This font is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this font; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA As a special exception, if you create a document which uses this font, and embed this font or unaltered portions of this font into the document, this font does not by itself cause the resulting document to be covered by the GNU General Public License. This exception does not however invalidate any other reasons why the document might be covered by the GNU General Public License. If you modify this font, you may extend this exception to your version of the font, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.This font is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This font is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this font; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA As a special exception, if you create a document which uses this font, and embed this font or unaltered portions of this font into the document, this font does not by itself cause the resulting document to be covered by the GNU General Public License. This exception does not however invalidate any other reasons why the document might be covered by the GNU General Public License. If you modify this font, you may extend this exception to your version of the font, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.http://www.gnu.org/licenses/gpl.htmlhttp://www.gnu.org/licenses/gpl.html'4  9!8H#9I427I5I8H@%)8 a  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`a      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxbcdefghjikmlnoqprsutvwxzy{}|~yz{|}~uni0E10.descless uni0E34.left uni0E35.left uni0E36.left uni0E37.leftuni0E48.low_leftuni0E49.low_leftuni0E4A.low_leftuni0E4B.low_leftuni0E4C.low_left uni0E48.low uni0E49.low uni0E4A.low uni0E4B.low uni0E4C.lowuni0E0D.descless uni0E31.left uni0E4D.left uni0E47.left uni0E48.left uni0E49.left uni0E4A.left uni0E4B.left uni0E4C.leftuni0E01uni0E02uni0E03uni0E04uni0E05uni0E06uni0E07uni0E08uni0E09uni0E0Auni0E0Buni0E0Cuni0E0Duni0E0Euni0E0Funi0E10uni0E11uni0E12uni0E13uni0E14uni0E15uni0E16uni0E17uni0E18uni0E19uni0E1Auni0E1Buni0E1Cuni0E1Duni0E1Euni0E1Funi0E20uni0E21uni0E22uni0E23uni0E24uni0E25uni0E26uni0E27uni0E28uni0E29uni0E2Auni0E2Buni0E2Cuni0E2Duni0E2Euni0E2Funi0E30uni0E31uni0E32uni0E33uni0E34uni0E35uni0E36uni0E37uni0E38uni0E39uni0E3A uni0E4D.highzerowidthspace dottedcircle uni0E47.highuni0E3Funi0E40uni0E41uni0E42uni0E43uni0E44uni0E45uni0E46uni0E47uni0E48uni0E49uni0E4Auni0E4Buni0E4Cuni0E4Duni0E4Euni0E4Funi0E50uni0E51uni0E52uni0E53uni0E54uni0E55uni0E56uni0E57uni0E58uni0E59uni0E5Auni0E5B uni0E38.low uni0E39.low uni0E3A.lowDELuniF71CuniF71Denspaceemspaceffffifflzerowidthnonjoinerzerowidthjoinerafii299afii300 RZ lmqr` mq JfDFLTthaiKUY PAL THA  RQDccmp:DLT\dlt| z,H\fr&0:DNXbl   2DVh           2DVh"4FXj|((hp bbrr rb."(  m n o p q  m n o p q   m n o p q  FbDFLTthaiKUY PAL THA markmkmk`R&0  *&XFv "(.4/ mnopq 6<BHNTZ`flrx~N>`  &,mm<3V$*06<BVmjfoByi*S
FFTMIR{7GDEF GPOSOӈ,tGSUB٩4OS/2{PVcmap7^pDcvt 1; P$fpgm2Jf glyfW8ݔhead뙞46hheaT$hmtx~locaH tmaxpx name2,)postGprepb3 |z_<[ [ mBQmB^a @ 1 /P PfEd@ H`O _MTVb., ,#y:+,L=L= G7SL Z,),m,,), ,),%,0,(,)ZSG7G7G7,,6J3MPbS 6P^J,J@JM 1M +N,bN bC,L+,#,@&,",% , ,BBB@@B,B, ,B,#L@,@ N\NG+(ozm:7AmC~t  <0Eh$)) `\[r(eO %' TZ  "#/42 f%6t,$||Ta.=nV bQ4!bC#79#"@` ;uTT]X]j5JMWOcQcPcc(c0c*c:c c<cCqQ` 4Lp*4**#*\*(Lq*@G7L '?$&L LLm>NZL4L4l*CA4A4AbM3PPPP^M 1 1 1 1 1GN (NNNNMbK,#,#,#,#,#,#y &,%,%,%,% [*#,B, , , , , $&b@,@,@,@,@*Ba?(,*L LLPL4L"*#*#L,L?nTT*     :< ~1Sax:[      " & 0 :!"""% 1R`x?     & 0 9!"""%'po:TeA 1X:      !"#$%&'()*+,-./0123456789:;<=>?@]^_`stLuvMNOwbcdefhijklmnopqrz{|}~TU   !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`a "!#%$&(*)+,.-/0243576;:<=Nw S'9GgBCxyuvst8@FQRYZOLMP    AHKJI,K*PXJvY#?+X=YK*PX}Y ԰.-, /+\X G#Faj X db8!!Y!Y-,KRXE#Y!-,i @PX!@Y-,+X!#!zXYKRXXY#!+XFvYXYYY-, \Z-,"PX \\Y-,$PX@\\Y-, 9/-KPXYF+X!YKRX!Y+\X E+D EN++D E 6++D E ++D E r++D E ++D Ed++D E++D E+D E 3+Fv+D E +Fv+D E"+Fv+D E+Fv+DYHT17=BHLE7EY_....`l>l(T$b>ph"T p  l , L  Z P<l|,|6|80&,\N@t8@HPXf\4Plt~  !T!"#$ $%&@'():*,+*,-./0&012,23Z34<45F567 78l9 9:Z:;b<4==>?n?@ApB BnBBBC0CD DZDDE.E.FFG`GHLHIJ2JfKKKL*LMMzMN,NNOPjQ QSSTUtV`W2XX$X.X8XRXXYZ&ZxZ[H[p\\z\\\]]]^8^^__f___`&`l`aab:bbbbbbbc4c@cLcXcdcpc|ccccd dd"d.d:dFdeee e,e8eDefff(f4f@fLfXggg(g4g@gLgXgdgpg|ghhh h,h8hDhxhiiii&i2iiij2jjjjkBkpkkl*l^llmmmn ndndnnnnnnnnnnnn_1+5+/5+/ֱ+ +013!%!!_@!_JV 8+(++ /ֱ +99990175353qmPf|dd.4 G+3+2 /ִ + . +99  9901'533'53Gdkdψuuuu  C+3 + 3+ 33 22+33 22 /!+017#537#53733733#3##7#37#3+S`%*I++I)Tc%+J**9% HHHH#!'| /"3 2/3 2(/ֱ ְ2+ 222"222ֱ%ֱ)+ 9@  !%&'$901%#5&'7&546753&'>54'v\2Ylj]2ZV88p25Av`uYX+Xf **c,+H(Z"J:]#:< $,+3 )/ 2ֱ% ֱ -/ִ A++ A++' A+++" A+.+@  $9+'@ $ %)$9%)#"'+$9  $901"&54632"32543!"&54632"3254IORDHU')IMMLLF{HPV@JSRHLLM]kXUcdXQ3;?|}Jh[VbjUTh=}}+&.+* + //ֱ'ֱ$+0+'99$@ &"*+-$9,$9* 9@  "$%.'(,-$901267&'#"&547&546"654&327'7OX \*69:5:WvmvPfH4"&\/O6[:y[>fG,7WDE'G"C`NS\AEZH%+#&-6=&-:;O[I,)++/ֱ+9901'53Bdυxx=.) + /ֱ +01&5473뮮>=.) + /ֱ +014&'3#6FL??ȃ bC++2/ֱ +999@  $9017&5367&''67& U E )JA85;#':78HGW"ZGB)0:H")E 7tM 2++ְ2 2 /ְ2 2 +0175#53533#StQQSsd:/ + /ֱ. +9999901353'67YeS4ddj#%R .///+0175! XXZd+(+/ֱ+01353Zfdd++/+013F )G+ + /ֱ ++  $9  $90132#"32#")[anm%&mt1++ /ֱ +999901!#5673tWEk58.C(VFmU++ /ֱ+2+ $9@  $901!!4>7654&#"'6329Y^Z_'IUkhN9AL[c}5gVMS"T2sNZeJ7EMC l)#+ + ++ $/ֱֱ  ֱ%+9@  "$9 $9#"99!9 $901%"&'732654&#"732654&#"'632u YpBQM?* ;OC2mW"^tdhxo[ V@>M LB64<hRd-  E+++ 332/ְ 2 2+9 901!5!533#'CHHaaY߬Q1QB)u+ +  + /ֱ++ 99@  $9 99@ $9 901%4.#"'!!632#"&'7326 @+T/RFd%@Fgyoa{ \uAW54E uU.fmj_a%!{+ + + "/ֱ ֱ ֱ#+ @  !$9 9@  $9  9901%#"!2&#"632'"32654&zeWaTN<q^u)<RA>ISm\p{_5 31Ja^IUJ0 1++ /ֱ+ 99015!#67670lPI [FKfwUDtq(++& + + ,/ֱ#ֱֱ)ֱ-+@ + !&'$9) 9 &#$)*$9999$901"&547&54632"32654&"32654&hklcx:he,IA54?C3?QV=AQU yb#)jKmV)<g)+cv9h@=24>V:ENQ?AR)#v + +  + $/ֱ!ֱֱ  .%+@  #$999 !"$9017"&54632!"&'732>='2654&"^wyivTk Tb1G!<YAJK~RTgi^Tq6QD/_N\EG_cIHSZ1+(++(+/ְ22 +015353Zfffdd^ddSs 6+(+ /ְ22. +  99015353'67YeeeS4dd^ddj#%R7nT;++/ִ+2+9$9015% 7x9RWX7*///ְ2+2 +01!5!!5!&&QS7nT;++/ְ2++9$9015-5&x9XW,q+(++ /ֱֱֱ+ +999 999@  $9014&#"'632#5&67>53O;x[c7U $V U0d9H g\+QR-W*ONBdd6.7D+3B 2+ +. +; /5 .'2E/ֱ1 +?8+%%+++ F+?98@ ./5;<BC$9%! 99+ "'(6$979B799;@ %+1D89?@$9!",99901%# '&547632#"'#"'&5463273327654&#"3274&#"326.}B~۱u|TW{\FPU/,`]6WG !6BEÙb{h>3N0+:.Me evaؗfi{nuRRG:[yZKA KKwU+4@LXJS=P++3++ /+ 901#3#'!3'&'f&mSNiJ 4&EP9PJg f + + + / ֱ2ֱֱ !+9 $99$9012)2654&#4&+326V+MI,eZIUZZNg\M&L4g0*64D,=?@3X++/ ֱ++ $999@  $901327#"&54632&#"tt'_?롮=]0uzkǰM9++/ֱ ++ 99901332!'32654&+Mnr̰TPe 2+ ++ /ֱ2 +013!!!!!PWsTTTS6 &+/ /ֱ2 +013!!!!SzPTV6w ++ +/ֱֱֱ +@  $99 99999$9013275#5!#"'&547632&#"~R0\c]a3V+2VN.hITpbfcg=vP ;+3+3 + /ֱ 2+2 +0133!3#!P_t__&4Q^++/ֱ+0133^_4@ ++/ ֱ ++  $9 990172>53#"?$,_TH/-& J 3+3+3 /ֱ 2 + $901333 #J_c:|tdVjrJ !++/ֱ+0133!J_`TJ G+ 33+3 /ֱ ++  $9 99901333##JZVe4WbM ?+3+3 /ֱ+ +999901333#M`x\b1431 R++!/ֱ+ "+@  $9 $901"&54632"32654.Cyb9/H^W*Gd4qs-LP Λ/Y[UP44[b:zRw>Mp B+++/ֱ2 ++ 999013!2!#4&+32MbSWanH6+"k++!#/ֱ+$+@  !$9 9 99!@"$9014632&'#"&7327&'7654&"+m?<IROabt6)/.O7Tgƭh+B>,˨ E-NNY+ 3+ +/ֱ2++9 99999013!2#'.+3254+N=xGB|x].+@(o̰UneÕ =0yu,g'z+ +(/ֱֱֱ ֱ)+9@   !"$9 9 @' !"$901%#"&'732>54&'.54632&#"gs[)J?^}ypmyZ N\<?;.bt{w:.:3\O^fmjk1/")BP$++2/ֱ +01!#5!#9xTTN;+ +3/ֱ + + $901%2>53#"&53b%9( __QJ "$2.bcup!++3/+901!33f`l4  *+ 3+33 /+ 999013333# ʾas_[HH4v )+ 3+3 /+ $9013303# qguvV *4++3 /ֱ +999901!33sn/GcJ )++2 / +90135!5!!vBYTTTC9#+ / /ֱ +013#3CjjHI++/+013G 9#+ / /ֱ +01#53#53llIHQ;++2/ִ++$9901#3#tZGYwQy#99y/ /+015!H@@+F++/+01#'3GqvF#$+ ++ + %/ֱ#ֱ+2 &+#9!$9  99 9 !#$99 99901"'632#&'#"&547>7542=@9T!n[[ [eNdK + T-6 Qs73$LOET,io! (,R@f+ ++ + /ֱ2+ +@  $9$9  901#"'#3632'"32>54&wi\4SY7XevCK,+(; B {L@EGmU=U)(@?Vq&[+ + /ֱ ֱֱ+  $99  $9014>32&#"327#"&&,IN+!V_pUoYq}Np9 iƁ Wh"b+ + ++ 2/ֱ+ 2 +@  $9 $901"&546323#54.#"32>gypl[4WQ46 ;)W64C vyF4@L$D@'j\CP%L+ + + / ֱ2+99 9 9017327#"&54632%!&#"QH`)Z.ushz" AOQ`j }}m:HS 9>+++ 3 2/ ְ 22+901"3###5354632&+eeXNN?P%.$-1C=C9IPN ."+ + 2+/ #/ֱֱ ֱ."W+2$+9 @   $9 99 9"$901%#"&732765#"&5463253"3264eaoT kO&:Vfzwi]<PIFIGTS S,'zCtxI=<kSmBN+3+ + /ֱ2++ 999 9 901"#3632#4#M;YY<_bQYXSFbhHB/++(++/ְ22 +01533BYYYgee.?+(++/ /ְ22+  9 90153#"'732>'3@YB@#""Ygee|hM J& B 5+3++ /ֱ 2 + $9013373#BYsm=h <@++/ֱ+0133@X4Bn+33 +3 2+/ִ A++++ 999 9999 9901"#3632632#4#"#4J5YN7gq!=dW]~YaWHTZZFQuBJ+3+ +/ִW+ ++  99 90133632#4#"BP5pWmHT<  Q+ + /ֱ+ +@  $9 $901".54632"32>54Ee3sr+N10,>! 4UX.zumZ;S(%>A%WB9 e+ + +/ִW+ 2++@  $99 $901#"'#3632"32654&{hS4YP9]iq@NBIEHGBCOEq\Too\Wn#9h + + +/ֱ ֱ. A+2+ @  $9  9$901463253#5#"&"32>54&#shb6NW1Wg{CEW7'9 KwQE3C;qWm[%=> Yw@Z>++ 2+/ִW++990133632&#"@P3=--"D NZSP(1-d+ +# ./ֱ%!ֱ  ֱ/+%99! #*$9# @-  !%&*$901%#"'73254&'.54>32&#"+CB WyvZ0@ (O68P,W fp*&Y!5>/D#lR!1 //,. TC  >C+ +3 2/ְ 2 2+ 99901%#"'&5#53573#326 $S AAWXX NN1T+C5C9 @U + ++3/ֱֱ. A++ 9 $9901%2653#5#"&53N<WN;j`QX-@YXMYdn@]J 9++3/ִ++$9901333^Zp *+ 3+33 /+ 999013333# [qn[fxT[fierq G+3+ 3 /ִ+ +@  $9 $901;737#'#imhzxo.J+3//ִ++@  $99 99901'327673673#"? :]mnY! 2Q+8?:R$.'*?  2+ + /+  99990135+5!6;I6,5;G|F9zK.7/Y)+* / /0/ ְ221+ 99 $99* /$901;#"'&/&'52>456&>76;#"+ g ;H!&a" ,7 8,*~M 1P &,1 #%%M:\."++/ִ A++013\MV.3%W + /! /&/ְ22'+9!%$99 $9017>7&'&'.+532+53265{2/U  -U!##.E ::3"WFO*Z<"M((&P=#V%)M(=+0 ֱ2ְ 2/+9 901"&#"5632327+!8G3T.@@;BBc;BCh7(M;E+0 + <+#A+)ֱ F/&ֱD!ֱ, ,.?2+ G+!D@ ;#$)E<=AB$9?9,*$920999 $9#0-.99<!9A',&?D$9 )67$999012326?#"&#"2#"&=#"&5463232=4'&#>264&#"r   "n#1  :r'9@2-='79*41'{lX0FM6 "(E+74(K4+,4;+3Q ',&&o0sy;m4@7#vp+33 +22/ִ+ + ++++999  99999  99901!"'42#"'432#"'4324t2:;2:;:<<::<<::<<:%wm<n9Rqo9A*pLmqCw/ֱ 01#53xEE~'j/.+/#.+(/ִ&%+!+%+&9!@'#$$999# !&$90126767#"'67>5#"&546264&#"/*5d9BW4<?>) $  "51.?#9N 34HjO +/($6&&tq.84/%?+//?+/+3 29/(ִ%+7+"+-22+(&97@ %+/013452$9" ,99.$9994% 999/"#278$9(999)$9 -$90126765+>54&#".#"632#"&546326"32654$.02 hS # &'//+)Jq8$**-&<+Ae :$) ##?,.C$$  @&/<3 :22A/9ְ=2 ?2201#3#5#5353"RttERRE2BTBTT@!,d%/.+/+.+-/ֱ" (+%+ 2"99( %&+$9+%@ !,"#()$99901#"&547>72>?363232654&"a8$2AaY& K# #1*)1J2>0 * 0&Q;E'+ 3<7+ +'. 2!'7+BF/*ֱD12 ?+$%+ +; +2 G+D*(99?!"'<=B$9$7999  8999 <%9B$?@DE$9!914$901%2503#!534#"2"632#"&=47>?.'>322654&"N%E6*#= 1'!>8,41Uc\b,,B) .)B{W  1 |,1-6;,!" " JT=Q+ +++/ִ++@  $9 999901"&5467632l.EE )&+2;k( %! +<B+ +/ִ ++@  $9  $901256765#"&5460EG )0(2<l( &!("0$z+.++++2 ++%/ֱ + &+9@ $ !"#$9 9"#$9901"&54>7632%"&5467632a/B0. -)/ED. *#(2#HA (9 %")*29n(9&!-E$y++ 2+/.+%/ֱ + +&+9@  $99 $9"#$901256765#"&546'25>5#"&546y/DE *00FF- .0*4;j(!&!("(1:o(9"%("hb6/+/ִ+ +9999901$"&462^XXXbddd) F/ /ִ++01!5! D)F/ /ִ++01!5!D `y+Eo]ɝ,ʝ\ˠ[̤{͛{Q(T +"3+ )/#ֱ" + *+"#99 $9 $901.'>32#4#""#4767VYi|E   W 'E#M[PZr9 1 B!" Q'/+ 2+ +"+-0/%ֱ++.2ֱ ֱ + 1++%#9'"()-$9$99" 9-@ %&()+/$90123253+5354654&#"#"&546"2641I&-T4EiJ-9& 543-5O,,,Q,. c6(vB4U.'?':;-2V]&&(6K2: + 2+(+*+3 + @+8 +;/#ֱ: 26++ ְ21 ֱ- + <+6:@  !(348$9  )$9 *983#6:$9 $1$9)$901%253+537654&#'632#"&54>77&264&"3EA)G&ID 4,3)+E2#PQ(> ..B5.A5B` %%%! ;%)3?G,<8..G!!((Q+3 +$3+ , + 1 +4/ֱ %ֱ# ֱ3/+ + 5+*9/#@ ! ,-1$99 9, #*9991+/3$999014>32#4&#"54632#"/#54'.264&"7iGevEVO4J$11+97' E 4,,y$FD*nVs@J"62*D@#D5-)5b _U:&& Q2<+%3+133+9+=/.ֱ +%6+%++ >+ .,9&'(9996%@ !12349:;<$999#$,$93!999@  .67;<$9 /2$901#4''&54>32"/#4.'.54672654&"Q7SE?OS-B 4$(;33 H (OjC$00Q YNb^ ??V<T-%@<#51(4 J^<%)_X/Nu'4QCKV+3L +=+?+.  +Q D +6I +0W/9ֱK .2ֱT323.G+ ֱ(P22 2%ֱC + X+K*067=DEI$9TG1>)$9 VLM$9%#?99 C999QTU$9 9ID493GK$90#.:$9 %&'()*>C$9013653#"/#"&546354>54&#'632#"&547677264&"2>="* E*&2$2;;C&ID 4*4)+D?PQ3 .."*!7:"+ $yI#3F21U $%% ;#*3?G5.? ..2(( ^)%%Q#+ + +) + ! +$,/ֱ+ֱ .'-++9@ !"$%)$9'999$!9)#'+$9014632#"'.'.'52325#"&264&":*41)-!5 D&)"&8N,,.4;,T& ?IA14*3&& Q$, + + % +* +-/ֱ,ֱ .(!+ .+,9%&*$9(99 99!$ $999%9*(,$99901"'632#"&=#"&546323254&264&"';>`q@2.<)79*51'K,,bZM+74(4+-5;-356:&&RQ1>H +3 ++& /ֱ5?ֱD ++I/ֱGֱ .B+/ 822+J+G)9@ '(H?@DE$9B 99@ "#$&+,$9/9256<=$9 ;<=$95@ 1 >23$9/"99D?BG$9&()9901%#"&=#"&=#"&463232>76754&#"'63224&#"#326%264&#"R6+)0)7:#3(7:*32 %$R>|14Cay-M< bp<7/$HAX+2t4X4<+-+: 4>_YL:F0V&&+~6C,+- <2+5 ,+D/ֱ+2 .ֱ< 2ֱ7 ?+( E+9 $9 ,-5$9<2979?$#99 -:95@ "#$1237$9901"2647#"&54632>7>5#2+5354654&#"32=4'&w,,4/7/4OSx* N!7O $hJ-:%-T4&&=<$><,2VN4E "1vB4U.'I "_62 b~ N)+ *2F+H3?)F+)F+9O/Aֱ+<++22 +% P+@ 4679?F$9<)*3:G$9+-H99 "#$9<=A$99,7B$9F@ !#-234"G$901"264&2=4'&/67>5#2+537&'&/'632#"54>372s,'2.!H/!6O PiJ. BA 4-01j#-!QP+  &62 34E "?8vBj/ ""1 >$&=0P*""QNV`0+'33Q +; "+.W'. Lֱ\28ֱJU2a/ֱJ ^2Z+3+O8+T2 ,2"+# b+ 9J?9Z@ <LM`WX\]$9;D99O31980QR999"'()*$9QW)99\*3OZ_$9JN4,$98L9; ?@DE$901%#"&=47>?.'>723253#"'&/#"&54>754#"2"632326="264&#"9*42V\el )E &0 + ,4#%9 -'';A 0`-5<+!" "GNB @'95" P-E1$2 V   1 |/6 j&&Q;E_i.'+ 3<W+I 7+ +`W<+R]2'. 2!'7+Bj/*ֱD12 ?+$%+Z+c ֱI :2hִF%+RֱS ְ2 k+D*(99?!"'<=B$9$7999cZ 8 999h X`af$9FIMW99RNPQ999IWLMN999`@ _GFZ[cdefhi$9 <%9B$?@DE$9!914$901%2503#!534#"2"632#"&=47>?.'>322654&"#3276?3#"&54672&"2654N%E6*#= 1'!>8,41Uc\b,,l E#BhUF`--*3F((B) .)B{W  1 |,1-6;,!" " JT=#G$$ ]w@@%74",QHP[+8+I+$ /QW/>+N\/;ֱPֱZ Aֱ4 4.L!+ ]+ZP9IN$9A>?8J[QX$9LW94*R$9!@  $%/STU$9WQ  TUZ$9!99NI65<;LP$9>A9$*+/04$901.'>32&'#"&4632>5374#"2"#"&5463254>7264&"2654&#"UYek:(EN&?G:":E HO-3(24):6)   k,,P 51!L^QJS)^;MN=H8u   2!+<5,+4 &&3"#+QKS_+>+L+, / 33W]/D+Q`/AֱR2ֱTGֱ: :.O)+ a+T?LQ$9G@ >DEMWX]^$9:O0[$9)@ ! $%&#,-5$9]W@ #&_TU$[$9%99QL<;BAOS$9DG9,0156:$901.'>72''#"&54672>537>74#"2"#"&546325467264&"326?&#"TYei <-DF45/(2'2=IL&A 1&23+97( a,,  KOG+S^_I!)?&+E Wy#kt (W\   1 +<6-*34 &&% #M;Emw+0 + S/hִv.+{ְf2Yq/F.+<+#A+)ֱ /Vֱ~&+D]ֱ^!ֱ, ,.?kִs%+Ld222ֱK 2K.e+~VT799&{|999DSYZxy$9]$EBP[\$9!@ ;#)<=ANab$9^9k?*Mc$9s,mi$920Fhq$9eGv99K wno$9SPM99hKaVcdeb~$9v{W[99qYkst999F]^l999#0-.99<!9A',&?D$9 )67$999012326?#"&#"2#"&=#"&5463232=4'&#>264&#"2'&'#"&54632673775#"&5464&"264&#"32>7r   "n#1  :r'9@2-='79*41'{lX0F jDO  $%-3&:<B4  *+? M6 "(E+74(K4+,4;+3Q ',&& ,&bG.. 2"'.*?$Y ) + (H K Q>F+3+ .+0+?+'D+!G/*ֱF 2B+$+ְ2 ֱ4 + H+BF!'(.?@D$9$"/99909989994> $99'99D?%*$BF$9!+8$9 4$9/$9012#4&#"#4>54&#'632#"&54767767>264&"` >EI&ID 3+4(.B>PQ3  F&@0..N@' ;5 $%%  :$*3CD4.? ..2 ! A~+<=((SS[c$ +3a F++R3+. [ +8W +?- +S d/Mֱ1 <+G2Y%+Tֱ-S22B%+#ֱ^(+\2 2+ e+1MK9<39Y456999T@ .8?@CEFRW[$9^B!,999( a99 $98 @ #$3456CK\^_$9['(99W@ 21=BMTU<Y$9?N9S-,.990132653#".'.'#"&54>754&''67#"&54632#4'.54>74&"2325h&2  %EJ(%)+7& +TW=0.5 $35+,7` I 379)N,,6S(>#4@g!P1J5$5 +5>>].=`Ag2)':9L2 (E$^P-5Q7"<,,R=( 5QBMU'+3K +6+ A+'.N!'6+SV/*ֱU Q+$+: 2@+ H2C+W+U*(9099Q!"'NOS$9$99@ 999KN%9S$C:QU$9! D999@ 03?@GH$9012#.=+4#"2"632#"&=476?.'>72>7>334.#;2264&"4K;-.+1KC&@ /9&!>8,41UYfh.2EE #,,>J;@4$`\;Y  + 1 |,1-6;,!" "KPC<T&" e#&&%N*4+#3+ ++1+5/ֱ)2'+#.+%++ 6+#'234$9.@ !"+,1$9 99@  !"&'()$91+@ *./34$9 9014632#4&#267.54632#4654.2654&"%[k|EXGKg/2+#=7-*:%R<:;00oc|fMe9G]S7U]R7+)85*-> 7 f6S2> +3+33 +-9 +" + ?/ֱ%0ְ 2 <%+6+%++ @+%90'9<()*999 2#996@ "->349:$9!99- '()*$93.99@ %&1067<=$9"9!#99012#&'.54677#4'&''3767.5462654&#"+7 8 J6(`gCK:')EPS|/$ :09,4* Pj ,A*\_1Kz44 .,Ma7! ::.ALN56A"*6 Q5?-+ 36+ '-+;@/0ֱ>% 29+* + A+>0.9%9999@ '(-?67;<$9*$9 9;6+*9>$9'%9@  $901.'>32#4&#"2"632#"&=4767264&#"SZi{ERF   -'(79+32: M[PZ;7  1 |3*-6<+"! &&,EP*4 +3+'30! ++5/$ֱ3ֱ 2..+ 6+3!"'4+,01$9.(9$9! 9+90$%.3$901>32#<.#"##"&54632264&#"N`8+ E 2D E!>9+41e+.< H;:VJ,1,7;,(&&N$/ + ,2+3"2) +ֱ 20/ ֱ+ &+ 1++ "#999&!99 999 &+999$901#!53/"547>3227#"&#"5.'&'326eM$'&4$C5<H;)y-8653. .%n#( #6Bq#$ 9#$^P!)1+ 3( +3/+3 %2 +*2/ֱ1 ֱ 2.-+2 "+ 3+ 1 *+/$9-9%&'999"(99(!"#$9*  9/-1$901%#"="##"&5463267>3324&#32264&"A*X,E'89+41&D#U E7G@& %,,CAt\}R4*-5:-6-?JI2"[:&&P!} + 2+3 +"/ֱ! 2 ֱ .+ #+ !$99 9!999901%2653#!53#"&54632264&"E6%I&4:$12x**B )0BT2*5/<+Y&&v!z + 2+ +"/ֱ! 2 ֱ .+ #+ !$99 9!999901%2653#!53#"&54632264&"E6%I&4:$12x**B)0BT2*5/<+Y&&TP&+3+3$ + +'/ֱ& 2"+ +2 (+" $$9  99 999$"&$9901#"/>73#.'#4672264&"2' ]32fBB^,%ZB2/"<s**)3u#" 0!yL'?/`&&av&+3+$ + +'/ֱ& 2"+ +2 (+" $$9  99 999$"&$9901#"/>73#.'#4672264&"2' ^12fBB^,%ZA1/#;s**)3w!" 0!yL'?0_&&JP'/+!3+ 33-%+(0/ֱ/"ֱ !2.+ + +2 1+"/%&()-$9+9 99 99999%$9('#99-+/$99014632>'33#&'./##"&6264&":$13*JE1EEDI! !* G;I**5/<+RK@ d1i.n5F}.,&&Jv'/+!3+ 3-%+(0/ֱ/"ֱ !2.+ + +2 1+"/%&()-$9+9 99 99999%$9('#99-+/$99014632>'33#&'./##"&6264&":$13*JE1EEDI! !* G;I**5/<+RK@ d1i.n5F}.,&&.VQ,6+ 3-+ %+27/"ֱ42(ֱ .0 + 8+(@  %&6-.23$9099 $92-#"05$9%(9$901.'>32#4&#"2"#"&546325467264&#"TZh}ESFW6 1&23+97( J"M[PZ:8"  1 +<6-*34 &&=!P*2<+33+30. %+7 (++=/ֱ2 ֱ:%ְ62 2..+ >+:2)99%@ (+,0<34$9.9997  !:;$9%9+(&90*.2$90146323653#"/#"&54>35#"&264&"26="=8,41u (E,!n4#2< 5$(7N,,0 #-6;,#7:!, %yI#3G2*+3&&[^)%VN/7+ -+35 -+.+-+08/ְ)27 23++ 9+3$-.015$9 99 $9095/37$901#"/"32653#!54767&'.=4632264&"8&  $%?  E>22. 41+9z,,+3! ''?)#7:Bo(?5Y&& O-7++.+++3ֱ8/ֱ6ֱ' '.19+699@ +,7./34$9'1$93.-16$999 "999999017463254&'.'632326?#"&#"#"&264&#">! A@!P:>#g! #k!7pQ/14+9c`2,'4  } 4  170,;5&&)Q5?-+6+ '-+;@/0ֱ>% 29+* + A+>0.9%9999@ '(-?67;<$9*$9 9;6+*9>$9'%9@  $901.'>32#4&#"2"632#"&=4767264&#"SZi{ERF   -'(79+329 M[Py;7  1 |3*-6<+"! &&4O1;+32+. +7+#</ֱ: 5+ +*2 =+:1995@ #$/;2378$9.99 9725:$99*9.#19901>32#54.#"632#"&=4>3254&#"264&#"4!eUM.WEFh$)69)43 / +&;AOET W7@2fd?#|4+,5;,$%#M:?<!|&&).Q,6+-+ %+27/"ֱ42(ֱ .0 + 8+(@  %&6-.23$9099 $92-#"05$9%(9$901.'>32#4&#"2"#"&546325467264&#"TZh}ESFW6 1&23+97( J"M[Py:8"  1 +<6-*34 &&Q$l ++  + %/ ֱ#ֱ .&+#@  $ !$9  #$999901>32#"&5463254&#"264&#"jV_q23+97( LG<P  7T`H+<6-*3B7?)&&"k(=G+!3+9 +>+C+0H/ֱ) "ֱ ,ֱFA+%+ֱ ֱ I+)'9A @ 019:G>?CD$929994999 99> ',999C@ ()*AF$90=2$9949999014>32>7#4'##"/#54'.75463267'.#"264&#"5fFo5? 1 EN7& E 5@08$85 3#3K$w%GD*:8-?>sn9>*3b`U#*B@&A ; !63u&&P8CK+ ,2(+3I ֱ5ֱ1 ִ>.+Dֱ"L/%ִK%+2ֱ, ,.G+A%+<+++02 2+M+K"#(DEI$9,G)9<AC:9$956999 9 19>@ 8C9:<AB$9"9 9ID%GK999(&901463226?3>7#!53#"&54632326=#".7264&#&264&"/,#+ E*4=/< J;;"22 $E;W**G&40!'5 ? L1(BT,24.<+Yx4$&&#%V6;C+ 3<4++ +4+A4+#D/ֱC ?+%2 +72 E+C.99?@ #,<=A$9$+4999 ()59$99A<?C$999;99#%799+()./$9490167#54.#"632#"&=4632>3&#"'>32264&"*3(EFh$)69)436=1##8rCM32J-Qb!1.>!,,#6+#0 S?"|4+,5;,*I#B:##$&=x$FG&&Y :B+3)+@7+#7+;C/&ֱB ֱ- 2-.>4+ֱ ֱ D+ B#$);<@$9->*9 07$9899#-99; !0$9@@ : '4&>B$959014&#">7#4&'##"&54632>7.54632264&"2  7  #E 9AFE)6:)42'h&53(2A,,/  ' #:44*:fkv4+,5<+G )6''J&& 5=,+/3+;+ +3,+62,+ >/ ִ=%+0ֱ .9%+++ ?+0=3467;$9@ -./$9+ #$$93,.99965199  +9=$9; 9$$9(9014&#"32646323#"&54632>7# ##"&6264&"": !96#$75(\2A5ZRD.!,$ AXU 7H** '!/.5f?l =K @*L N/&&9Q(0 + +& ) +. +1/ ֱ0 ,+"+ 2+0 (9,&)*.$99"9)9.,0$9&(9901632+"&=4632#';2>54&"264&"99Tk5"65/!=5&"BzR9**t_N1+/3(@.5)5f.5>/(&&W8DL+" 3+<+E3+J3+-3+BM/0ִ+? ֱL Hֱ(ֱ N+H@ .=EFJ$9-3<B$9(+49C$9999E9JHL999B-+9<019?@$93901>7+"&=4632#"/;2>54'#"&54632.#"326264&" 1' &262(33& CXMoL"5#-!. 7]V*.1**+!< (6,(>7T5#  (?E  & &&"O.6++34@++'+/7/ֱ6 2+%+*+ 2 8+26/04$9'99* (999.999 99'9/9426$9*+99012'276=#"&5462#"'32654&56264&"'++)$Y<UYGT35' O_,,O ~I$#5 +%5iIB@/(*8  Y &&@ <"*2(+2+/+3 /30/#3 3/ְ 2*12&+-2%+24+&*@ "#$(+,0$9990 !.2$9( &*$9012>7#"&546267#"&54>264&"264&"$= :eQ;Q9*#> wEP;P9....;,3R0dR75+6-3"ndQ76+6((((N"^/ / #/ ִ"%++%+"  $9 $9 @   "$99012>7#"&546322&264&"3aD( ,UZR40+4t00%5*m(;L-)=8& **gP+++ /ֱ + 99012#4&#"'>7K$E*;% 4 !6P49%^E9 $$gE&s  ///  9901.#">32632&#"pB]Cop{e_GLIW-pf*a| c8/3// ֱ  999 901.#"&63253%632&#"bC_Jjk^&=EFNON+qg)] 0d!*$//) /@++/ְ2!%++%+!%99&$999$"&99)9!$9$901.#"46323&54632264&"632.#"h6 %?Y@Gd<`  .-*3q**FQ=]R5go=X@d}43S$&/3 K// !/ֱ + 9 9999 990146325353.#"7632.#"y] D$C AY@zlNDT<]Q5i_wEQt# ,)K/3 Z/ // ֱֱ .  9 $9 9 $9 9012#5#"&5462654&"[E 8+  #\s',&/u  `s////ִ%++ + 9$999999999 999014632326=3+5#"&6264&"`1#,,- @# ".A  z%-1% =n. <2/+/ִ+9999901"&4628 8!$2$$2I// /ִ+ +%+   $9  $901"&462264&#"z`55`6f<T<=R!.!!.! PC '/5>JV_gr/`3c.+.+(ִ-.+ִ#.+0ִ3.+W/\.+/.+ ְm2.+m.h.+s/^ִ%+Y2%.!+ִ+ִ+ִ +p+e2k+a2HִB+/ִ++<ְ428+1T22T.N+t+%^W\99!@ '#$9@   $9kp@ g`cdrhimn$9/HJF99B)-(?@E$98<03>6:$9NVKLQR$9cf9-+/$93#!9%&99\0PQR999W@ VLNOTUKYZ^$99:;999>678<=$9DEF999 @ J?@BCHI$9hkpq999012#"&4672#"&462#"&46'2#"5462"&472#"42#"546'2#"&5462#"&546%2"&542#"&462#"&546T  l    [  z  e W      0      Z   0   Z   P  h$$  Z      $     :s+TC ;++.3 2/3 20/43 2<//ֱ 2+-1222 +3222ֱ: ֱ% =+9  9 %&$9 99:999015#5#732654.#32654.+#5#35332ggg9B;3) DA ?M%"&74VFF079&L4!0.A,$' 32P+^^UU%H.j]&N b++ +/ֱ ++9 $9 $9  901%#"&53632264&"&:)42E)6y,,_,5<+j4Y&&]1N #++3$2+3 +3!(2,/ֱ +'+ֱ #+-++9'$%)$9#9 !$99!#'+$9  99901%#"&53632#"&53632264&"264&"1>%42E!>:)42E)6,,,,b5/<+j+4,5<+j4Y&&&&a,4#+-/2ֱ 2ֱ5/ִ +&ֱ4 0ֱ 6+&$94 $9990@  #-.2$9 992-!& 04$99 '(99 9999016323267#"&#"2632#"&54&'.264&"<Ck&g!0j  J )6:)42!1!M,,]" 2+ +"4+,5<+"#&&^",6+- /2#/.+ /).+/ 7/ִ+%+&++ֱ 50+8++9& #$)$9 995990 !6-.23$92-05$9 "99)#&'+,$9 9 9901%#"&54&"7232#"&546326322654&"264&#"^9+41". <#!.F@9@!>a,7;,0$N&1-9EY@1(,&&+5+,)/1#/3 26/ֱ' 4/+7+4$99/')*5,-12$9,91/4$9)+'99 @  $901%#"&554#"#"&/4&+526327>32632264&#">$32 . 1  ;8#)"";b`4.<+B <$+9)4#-, ,a&&i&N+/ֱ +01#4#".>32DO:0   !?-):u|') #2'J N,4+3/-/'/25/ִ +# 0ִ*%+ . 6+#90@ , '(-.234$9*9999992-+*04$9'$%999 !#$9017"&54772'267654'&#'"632&264&"?AGC ="6I H#!JC4)012G.._I$11 9P/!3:0&&7#@#":.((066++ֱ ֱ32+ֱ(ֱ 7/%ֱ 1+%+1 @  !"#()*+3456$9,-./$969 99 %999 &901#"&#"632>32#".#"&54632326=34#"3@:'_6(.5/&-+ 0(;]RC_/%Jr # +'**& (N$`DA 44M/ֱ 01#53qBB$ִ +ִ .+. .+%/ִ+#+ִ+#9@  $ !$99 99 #$99901#"'67#"&46>72654&#"1 9D"*.-(PDwP")+B-M =i1mN.8// ?+/4;+&/*3229/#ִ%+2++(22 +-#!92@  &8/04567$9'99   *$9-+99/  $9427$9 #999$-999&(9901>5#"&#>54#".#"632#"&54632632264&#"9$4/ cN 1" $%.)0%01  S@*?b<!? #":,*E##.-/+ ,/ 3 2 /ִ +ְ2 201##5#53533 P?TT?PMM>RR{##.c$/.+!/*.+//ֱ, '++ 2,99'!".$%*$9*$#'(,-$9!9901#"&547>32>?36322654&"m4-:YP# B !  ,Q&&+D-8,   *LyEI// /ִ+ +%+   $9  $901"&462264&#"z`55`6fy<T<=R!.!!.!:)#s+.+/+ /=+$/ֱִ A+999"9!$999 $9 901"5463.54>32&#""327jKL '"N5&&8&"9F& +P'D!   #+"#O %+ A+/C+/#.+/?+&/ִ++%+!+++ +'+%9!@  #$9 99#@  !%$901!"&54632'264&#"6"&462264&"6mzzmlzzl]hh]^jj|GG|D^44^4]^^]vvvvENjNNj0:P::PQ&H+ / /ֱ + +  999   $901.4624&"26&|}~7TTUU-vtrDVVDCTTP:+5&+ ,/ /1/6/)ֱ +4/+# + 7+4+$9/@  ,-12$9#! 99  99,$9991@ #)/45$9  9*9012'654&#"327#"&54>32#.546264&#"?v!- 'odJLeG*% ':1&19PJ][M*m2W5-15S_UJHD3**%C,<gqVhp$VfKU+1L/I/Q /3:B2)/# V/ֱ- +TO+7+ W+T9O@ CIULMGQR$9 BJ9997:;=>?@$991./999L9QKOT$9I?>99:9 9# !-99901%#"&54632>32#!"54&#"526323!2>=4#"#4&#"632264&#"e5(*:J> %37UQ' 8/, -1%!  '1\+8J9Ab A2Wa<0%o=':  3Q  (V5@1+6+++/</3$ 2A/ֱ> )29+. + + B+>&'(9999%+12@67<$9.$,999 9 99$961/9<.9:>?$9+(5)999$ '$90174>327>32#4&#"#4&#"632#".2654&"( &@)?B ?KD&$-E730,-29&%2 y*48*?    O;)3:%!;V: ;+(4"AEr0<E+5+ ִ:.+'/B/ F/ֱ $+E@+)+ G+$9E<$9@@ => BC$9)' +;$9 145:$9:49B @ $%)*+1=>@E$9'9999 99901"&54763232767#"&#"326;".5462'.#"6264&#"WaHDxRj+2B<,8bJC3H =B5\52I3$ 4!((zMc?==Fa2!*?M E)(=:(5 6 "$*dnx+F+ >+%ִC.+-/tRֱ Oֱ m/\ b/hy/Jֱ *+w_ֱj rֱ0Q2Tֱ ֱ z+*G9w! EF$9_@ "-OPxotu$9r%p99j.]29990D9T@8CRVWXY\bcehm$9d>999<=999 C<=99t%@*+0128JKxoprw$9\O9mTUVXWY$9h_ejk$9b`990107>5#"&#"326;".54632'.#"#"'&54>323254&543#"&54632.#"32264&#"& A"]o.G) D4 G(2&4.-52J$ 3!$N0:3iHbk9".><4%=!$3*H 6 )!0 "-'@M  9 (<9(6  6 4:X#FG-*/&%37 "$:0(2+ /,/ 3/ ֱ.)++ 4+.  !$9)(& ',12$9$999,@   )*./012$999999'9012#"&546232654&#"#54'764&"32b:V+v^Iq7V6&BSS?4?m<08*+ED"]rG>+;7);WB?U /'Ê$<DT6$$ ZIU0+J+++0+P0+$3:>2V/5ֱ' M+.+A + W+M'@%$)+01:UJKPQRST$9.,9@  ;<>$9A?CE999 99PJ.ECMNST$9+()B999@ '56<AI$9:9 99014>73#>54#"#4.#"632#"'.547>32632>52654&#"@ H)eF=> 8%)74%54,3B4E$$K7=5$#Su0N1!;$@Z"/&!L^- ,_;:L<]3C502BB[DpO7`><bJT?+63% Kֱ* ֱ; 0/Qֱ HֱU/Bֱ -+SNֱ3ֱ V+-@ !#9:;<=>?HI$9S+J7$9N@ %&)*06KL'Q$919993 9%?>@99;*#49=$9 K-3NOST$9Q.B9990C9012654./3#"&#"4>32325"#"&54632#".#".54>322654&"A:E[W!=] !?3B .84/53<9%N50 Tk !2V6n ((7J hP GR( #+,6,4)':G4>Z)1)'/-uT49, CNjGR7+%+K/+1/QFֱ Cְ=2 =. S/:ֱ" .+HN+4@2+ T+."89H ,%7=$9N@ &)+1>KLQR$9429@ CDEFG$9 999%799K+)599Q@ #"/4HI.NO$91:9 ;999@9CF 99014.53#"&#"4&'.#"32>7#"&54632#"&5463246323232654&#" H",8;f8J"()1201 "*'-0)D<OR[J,@> XQ-AYW$bu:'!<b=;W 5$!<B.=[~W[t+*+ >e K++3,2E/4 /@ְ 2$ ְ:2L/7ֱ +=%+1+ &2!+ M+@  5:;@AB$9=4E991K+,FIJ$9  999!$%$99@E19 B9$ &=>$9J99014&#"32672>32'>54#"'276=#"&5>32#"'327>76 '('/7* -*+#"A1V[D-/04*.0?-t !-A6+&N#$6"-:#p_.C5'+8 )*[ 6:0B#LT2/ 3'/A/H.+"/Q/-U/ֱ/ +S%+O+%%+*+V+S -99OM"Q$9%#'2$9*939299'09HLJK$9A&<9TMN$9Q@  %/> OS$9" *999-+:;=?$9789901%".'''#'#"&54632#"'&46322654&"327>7373773236;"#%254#"t 4097&:/'=\_ogPMSBA/ (,&,6lM_;],> 6&044'@(,4*_EL0KcfjNEq).@1*',P48IyJXnh0&龽) !"` (4+/ִ+01!!44p: 1+(+ /ִ+ + $901#5#5fOnddz49#++ / $/ֱ!+%+!9@ #$9 9999@   !"#$9990146327&'327#"''7&#&4ym767XT #krYzO:67HI;}!o 6 _dAcf+.+32*+ -+'+ֱ -+"3 $2//'ֱ ֱ 2-+,0+ '"%999 9 $9-@ .*$9,+99999 99 !$9-9(,99901"3#632327#"/&#"'654'#53&54632&#4I X(*"<I- OD"paL}`WC53ZI`[ P$.U?%IO2^n ~#sS$+3 //%/ִW+"+ &+$9"@ $ $9  $9 $9@ "#$9 $901'76327'#"''7&47"2654&hE9C5@A2E9E##E9E2A@5C9E#5JGpFJC;E##E;C33B:E%%E:B5|AF95JK47H)V+ +3 +3 2 +3 2/ְ22+ 9  90135#535#5336?33#3#ʥchŧ˟DEI[)"((IED\.(++/ְ2 A+2 +01##MMM~(.-9+ / :/ִ6W+ֱֱ!ֱ ֱ0ֱ*;+699!@  &.2348$90 ,9'99@- !"&'*+,.01234678$901#"'732654.'&547&54632&#"'654'&'mUYh+>H\j7n?gKZW-8%4:\8nNzH30HzI3GX s/%F5E6Aj ;@CV k-!0$% <5B^.;\%5<Q #'8;H,m/-+3)+2/ֱ+ +0153353\Y[mcccc4+ + #+(+05/ ֱ-+! %+&+ P+6+!- 999%@ 4#$()03$9&12$9#(9@  !%&-.23$90 9012#"&5476"327654'&"327#".54632&skjklikZYYXZY~=C|_<%$@;"i]$:!jkkk֚ij<ZYYYY\TG_.U:`ptKm_!o+  /"/ֱ ֱ +2 #+   $9999 $9 @  $901#"547>74#"'632#&'32 ;BxG MH DH  6%*@f4kEK=evB  1@# I/ 3+2 /ִ+ 2 +@  $9 $901#'73#'73GG?II7!ִ+/ֱ+01%#5!5!SyQ .///+0175! XX3:+ + 4+.:+1;/ ֱ0+. 427+ + P+<+.0 9997#$9'999&99.&'/0$94 "#$9:7$91 9012#"&5476"327654'&#'.+#323254+skjklikZYYXZY( &61P##%ANagHjkkk֚ij<ZYYYY\/  WM?#=:7</ /+015!F???N N+ //ֱ++@  $9  $901"&5462'"3264&9NPnQR6#/0"!22P86QQ6;M1"$/2B2&Y A ++ + 32/ְ2 2+ 990175#53533#!5!S(SSS e=Y+/ /ֱ + @++ $9999 $9013!>7654#"'632:<l7>@(D;J|q+FL<E0.#78j]<++//ֱ ֱ ִ A+ ִ A++9@  $9 9 $9999$901#"'73254##7254#"'632<Z;F:MN L:5F kDU5;i7B643,2 \Z;mF ++/+0173m@skFN9T + ++3/ֱ2 + @++ @  $9  9901%2>=3#5#"'#3(4 VO+WJ0XX+C CK8=I@0B=$91+ 2/ִ + . ++01463!####"&zm6FSmQUqckT?sZ./(+/ֱ+0153Zf.ee43 H/ / / ְ2+  9999  99 9901#"'754#73O>--OLBSq-/8( V4 4e6++ֱ  /ֱ +99015673.?K46e#>BjW J+ / /ֱ + + $9  $9014632#"&7"3254VKLUULJWWWXSfdTScdxvyuC# I/3+ 2 /ְ 2+ +@  $9 $901'3#/3#HH=LL44 q+ +/32/ /ֱ +2 2+  99 $999 $9901356735#5733#'5{K&.?K46ҽ:44Eq #>BK=5K41 #+ +/ "// $/ֱ + A+2%+  99@  "$9  $9" 99901356733!4>54#"'632pO.?K46F&+V.BC.B8Iy #>Bh<%@;<51146j4 +.+++'/,3")2 /%2// ֱ ֱ ִ A+ִ A+!+,2& *20+ 9@  $99!#$.$9&%99'$-99   $9 999$9013#"'732547254#"'6325#5733#'5{LuZ;F:MM L:5F kDU<44Eq 5;i7B743,2 \Z;K=5KM.u+(+ /  /ְֱֱ2 + !+ $9 99 9@  $901#5327#"'&54767653ec[S9x[^AHl/U (Jdd8H 35\Y^(##@ 7!-A"$Cx"$"$H"$K"$"$JE+ 3 +2+ +/ ְ22+011!!!!!!5!3#YKNu,bHTVT"V33"&Pe"(CPe"(Pe"(HPe"(",C^",!",H",]+++3 2 /ְ22+ !+99 999013#5332!'32767654'&+3#MOOp>M/1M48j/aEBE TTTBFa5BMw"1K1"2C1"21"2H1"2K1"2N7 N/3 + 2 /ְ2+2 + $9  $901?'77'N:::Ǜ<;<(&++'/ֱ"+ (+99"@& $%$9 9999@  "#$%$9990146327#"''7&"&2654'.xcS/ULY[uhQ1WQYGe4-kKYt+KdN\(aockK\)az6Z^4cR?|]Vh:N"8CN"8N"8HN"8"<Mp J + + + + / ֱ 22++999012!##34&+32\@_M(__bK_:,T<ْ̒>@KC)+ ++ */ֱ$ְ2'ֱ +++$$9' )"999 !$99@ !"$%&'($901"#432#"'732654.54654&D4WLhIHTgJy9L'=)1'88'O8UWM>((@= 4LYv#Q3#-&(6"+#"DCb#"Dy#"DHm#"DKm#"Dm#"DJh R$*9+!35 +3 (22%ֱ ֱ+ :/ֱ3ֱ ++2%2+2;+ 39@ $ -.56$9#999!"()$9&95@ #.3$9+-9%999  9901"&5476754&#"'632632!327#"'!&#"32676OcP,4?{U‹(?go;@j\7xIa>RVE*5 d7S RB ?1e FFKOmm bbBQt Q2&&3"Fj%"HCb%"Hq%"HHm%"Hm "AC["A!"AH"A#*+ +3+# +/ֱ& +,+ &@ * #$$99#@  !&'$99 $90174>32&''7&'37#"&2654&#"# /P344't(=j'iUns~INQGIJ//!CI8$<-?26')11*xEnXSnpY7P&B"QKq "RC\ "R{ "RHm "RKk "Rk&& 4 /(+//)+ /ְ2 2 +0153!5!53c(cccQdd@(&# + ++ +$/ֱ"+ %+999"@  $9 999 9@  "$9901746327#"''7&&#"%32654@tKE1.39tL>2.4>R..KO&0MO~+?!DKs~(B#CG #sTI2nXI@"XC\@"Xe@"XHm@"Xj."\\B9k+ + + /ִW+ 2++@  $99$9  901#"'#3632'"32654&{hM:YY8UitBLGDEHGwBBRvWVmo\Wn."\Va++/ֱ+0133aX?$+ +++ + %/ֱ+2  2&+@ $ !$9 $$9 999990166325!!!!!!5#"4.#"32>?C%MZ@L(O7`^7O(TmaTVTgsw2][67^`(&-+ 3 "2+3 *2+' ./ֱ%+'+2/+%@ & "#$9 99'@  *+,-$9 $9'99%99901%327#"'#"'&54632632%"3264&4&#" TGe X,CIxw??v@Dzvy3HMKGRQR;>TMbl bbKGwcc>V1[mroDRW?,g"6I"VIG"<.!K ++3 2 / "/#+ 99999 9017327#737>32&#"3##"> 5 Vb b =C%D+   c c^i,K KCBGKJ   3C F@;++2/ִ++$9901#73#8ej^lbUFH;+3+/ִ++$990173#'35dm]je~RP3 V +.+/+/ִ++++  $9  $901#"&46322654#"/*'00'*/W45 83N07V$646TJK+3+ 2 . /ֱ + + @  $901"&#"#4323273Z '@dY?V,.o()n4|eB/ + /ֱ..%+ +999901353'65=^Q6ePv#"L"| eV+ 3(+ 2/ֱ.%+ ֱ  .%++9 9901353'65353'65+]O7h_Q4ePw""LePv#"L#W &/3 2 /ְ2 2 +01#53533#YĩPNN#WI+ 3 2/3 2/ְ2 +2ֱ22 22+015#53#53533#3#YũNcNNN "*1+ +/-3 )22ְ%2! 02ֱ 2/ֱ + + + #++ /+' 3+  $9 !$9/+)%-0$9!#'+$9 $9013432#"73254#"432#"7324#"432#"7324#"%@ˌHG@BEJEBDCHGACE2»}}}|},#9/+/ִ +2+9999901#'73HH?#9/+/ְ2 ++9999901'3#HHn?gf+ 33+22222/ֱ ++ +99 $9 9901#5!#333##E`ec_<g=j?S::=sLSvB$+/ֱ + +015!#5#0J33 N&II &IL &IO &I'IL* &I'IO*X*=R  $        /  D 2Y     HtBGenerated by NECTEC for Public Domain Modified under GNU General Public License by TLWGGenerated by NECTEC for Public Domain Modified under GNU General Public License by TLWGGarudaGarudaBookBookGarudaGarudaGarudaGarudaVersion 2.58: 2008-05-16 Version 2.58: 2008-05-16 GarudaGarudaTLWGTLWGThis font is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This font is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this font; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA As a special exception, if you create a document which uses this font, and embed this font or unaltered portions of this font into the document, this font does not by itself cause the resulting document to be covered by the GNU General Public License. This exception does not however invalidate any other reasons why the document might be covered by the GNU General Public License. If you modify this font, you may extend this exception to your version of the font, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.This font is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This font is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this font; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA As a special exception, if you create a document which uses this font, and embed this font or unaltered portions of this font into the document, this font does not by itself cause the resulting document to be covered by the GNU General Public License. This exception does not however invalidate any other reasons why the document might be covered by the GNU General Public License. If you modify this font, you may extend this exception to your version of the font, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.http://www.gnu.org/licenses/gpl.htmlhttp://www.gnu.org/licenses/gpl.html'4  9!8H#9I427I5I8H@%)8 a  !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`a      !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxbcdefghjikmlnoqprsutvwxzy{}|~yz{|}~uni0E10.descless uni0E34.left uni0E35.left uni0E36.left uni0E37.leftuni0E48.low_leftuni0E49.low_leftuni0E4A.low_leftuni0E4B.low_leftuni0E4C.low_left uni0E48.low uni0E49.low uni0E4A.low uni0E4B.low uni0E4C.lowuni0E0D.descless uni0E31.left uni0E4D.left uni0E47.left uni0E48.left uni0E49.left uni0E4A.left uni0E4B.left uni0E4C.leftuni0E01uni0E02uni0E03uni0E04uni0E05uni0E06uni0E07uni0E08uni0E09uni0E0Auni0E0Buni0E0Cuni0E0Duni0E0Euni0E0Funi0E10uni0E11uni0E12uni0E13uni0E14uni0E15uni0E16uni0E17uni0E18uni0E19uni0E1Auni0E1Buni0E1Cuni0E1Duni0E1Euni0E1Funi0E20uni0E21uni0E22uni0E23uni0E24uni0E25uni0E26uni0E27uni0E28uni0E29uni0E2Auni0E2Buni0E2Cuni0E2Duni0E2Euni0E2Funi0E30uni0E31uni0E32uni0E33uni0E34uni0E35uni0E36uni0E37uni0E38uni0E39uni0E3A uni0E4D.highzerowidthspace dottedcircle uni0E47.highuni0E3Funi0E40uni0E41uni0E42uni0E43uni0E44uni0E45uni0E46uni0E47uni0E48uni0E49uni0E4Auni0E4Buni0E4Cuni0E4Duni0E4Euni0E4Funi0E50uni0E51uni0E52uni0E53uni0E54uni0E55uni0E56uni0E57uni0E58uni0E59uni0E5Auni0E5B uni0E38.low uni0E39.low uni0E3A.lowDELuniF71CuniF71Denspaceemspaceffffifflzerowidthnonjoinerzerowidthjoinerafii299afii300 RZ lmqr` mq JfDFLTthaiKUY PAL THA  RQDccmp:DLT\dlt| z,H\fr&0:DNXbl   2DVh           2DVh"4FXj|((hp bbrr rb."(  m n o p q  m n o p q   m n o p q  FbDFLTthaiKUY PAL THA markmkmk`R&0  *&XFv "(.4/ mnopq 6<BHNTZ`flrx~N>`  &,mm<3V$*06<BVmjfoByi*S
-1
libgdx/libgdx
7,270
Update missing build.gradle files with new syntax for registering tasks
Some Gradle build files were still using old syntax after https://github.com/libgdx/libgdx/pull/7134.
obigu
"2023-11-05T15:31:03Z"
"2023-11-13T11:04:33Z"
8e3b2ef2af2e1c1765b3441cb15cfbeddf4046fa
a25ceaddd8e9ea740b7e50e486ea4f815d2a3f58
Update missing build.gradle files with new syntax for registering tasks. Some Gradle build files were still using old syntax after https://github.com/libgdx/libgdx/pull/7134.
./gdx/src/com/badlogic/gdx/utils/FloatArray.java
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.utils; import java.util.Arrays; import com.badlogic.gdx.math.MathUtils; /** A resizable, ordered or unordered float array. Avoids the boxing that occurs with ArrayList<Float>. If unordered, this class * avoids a memory copy when removing elements (the last element is moved to the removed element's position). * @author Nathan Sweet */ public class FloatArray { public float[] items; public int size; public boolean ordered; /** Creates an ordered array with a capacity of 16. */ public FloatArray () { this(true, 16); } /** Creates an ordered array with the specified capacity. */ public FloatArray (int capacity) { this(true, capacity); } /** @param ordered If false, methods that remove elements may change the order of other elements in the array, which avoids a * memory copy. * @param capacity Any elements added beyond this will cause the backing array to be grown. */ public FloatArray (boolean ordered, int capacity) { this.ordered = ordered; items = new float[capacity]; } /** Creates a new array containing the elements in the specific array. The new array will be ordered if the specific array is * ordered. The capacity is set to the number of elements, so any subsequent elements added will cause the backing array to be * grown. */ public FloatArray (FloatArray array) { this.ordered = array.ordered; size = array.size; items = new float[size]; System.arraycopy(array.items, 0, items, 0, size); } /** Creates a new ordered array containing the elements in the specified array. The capacity is set to the number of elements, * so any subsequent elements added will cause the backing array to be grown. */ public FloatArray (float[] array) { this(true, array, 0, array.length); } /** Creates a new array containing the elements in the specified array. The capacity is set to the number of elements, so any * subsequent elements added will cause the backing array to be grown. * @param ordered If false, methods that remove elements may change the order of other elements in the array, which avoids a * memory copy. */ public FloatArray (boolean ordered, float[] array, int startIndex, int count) { this(ordered, count); size = count; System.arraycopy(array, startIndex, items, 0, count); } public void add (float value) { float[] items = this.items; if (size == items.length) items = resize(Math.max(8, (int)(size * 1.75f))); items[size++] = value; } public void add (float value1, float value2) { float[] items = this.items; if (size + 1 >= items.length) items = resize(Math.max(8, (int)(size * 1.75f))); items[size] = value1; items[size + 1] = value2; size += 2; } public void add (float value1, float value2, float value3) { float[] items = this.items; if (size + 2 >= items.length) items = resize(Math.max(8, (int)(size * 1.75f))); items[size] = value1; items[size + 1] = value2; items[size + 2] = value3; size += 3; } public void add (float value1, float value2, float value3, float value4) { float[] items = this.items; if (size + 3 >= items.length) items = resize(Math.max(8, (int)(size * 1.8f))); // 1.75 isn't enough when size=5. items[size] = value1; items[size + 1] = value2; items[size + 2] = value3; items[size + 3] = value4; size += 4; } public void addAll (FloatArray array) { addAll(array.items, 0, array.size); } public void addAll (FloatArray array, int offset, int length) { if (offset + length > array.size) throw new IllegalArgumentException("offset + length must be <= size: " + offset + " + " + length + " <= " + array.size); addAll(array.items, offset, length); } public void addAll (float... array) { addAll(array, 0, array.length); } public void addAll (float[] array, int offset, int length) { float[] items = this.items; int sizeNeeded = size + length; if (sizeNeeded > items.length) items = resize(Math.max(Math.max(8, sizeNeeded), (int)(size * 1.75f))); System.arraycopy(array, offset, items, size, length); size += length; } public float get (int index) { if (index >= size) throw new IndexOutOfBoundsException("index can't be >= size: " + index + " >= " + size); return items[index]; } public void set (int index, float value) { if (index >= size) throw new IndexOutOfBoundsException("index can't be >= size: " + index + " >= " + size); items[index] = value; } public void incr (int index, float value) { if (index >= size) throw new IndexOutOfBoundsException("index can't be >= size: " + index + " >= " + size); items[index] += value; } public void incr (float value) { float[] items = this.items; for (int i = 0, n = size; i < n; i++) items[i] += value; } public void mul (int index, float value) { if (index >= size) throw new IndexOutOfBoundsException("index can't be >= size: " + index + " >= " + size); items[index] *= value; } public void mul (float value) { float[] items = this.items; for (int i = 0, n = size; i < n; i++) items[i] *= value; } public void insert (int index, float value) { if (index > size) throw new IndexOutOfBoundsException("index can't be > size: " + index + " > " + size); float[] items = this.items; if (size == items.length) items = resize(Math.max(8, (int)(size * 1.75f))); if (ordered) System.arraycopy(items, index, items, index + 1, size - index); else items[size] = items[index]; size++; items[index] = value; } /** Inserts the specified number of items at the specified index. The new items will have values equal to the values at those * indices before the insertion. */ public void insertRange (int index, int count) { if (index > size) throw new IndexOutOfBoundsException("index can't be > size: " + index + " > " + size); int sizeNeeded = size + count; if (sizeNeeded > items.length) items = resize(Math.max(Math.max(8, sizeNeeded), (int)(size * 1.75f))); System.arraycopy(items, index, items, index + count, size - index); size = sizeNeeded; } public void swap (int first, int second) { if (first >= size) throw new IndexOutOfBoundsException("first can't be >= size: " + first + " >= " + size); if (second >= size) throw new IndexOutOfBoundsException("second can't be >= size: " + second + " >= " + size); float[] items = this.items; float firstValue = items[first]; items[first] = items[second]; items[second] = firstValue; } public boolean contains (float value) { int i = size - 1; float[] items = this.items; while (i >= 0) if (items[i--] == value) return true; return false; } public int indexOf (float value) { float[] items = this.items; for (int i = 0, n = size; i < n; i++) if (items[i] == value) return i; return -1; } public int lastIndexOf (float value) { float[] items = this.items; for (int i = size - 1; i >= 0; i--) if (items[i] == value) return i; return -1; } public boolean removeValue (float value) { float[] items = this.items; for (int i = 0, n = size; i < n; i++) { if (items[i] == value) { removeIndex(i); return true; } } return false; } /** Removes and returns the item at the specified index. */ public float removeIndex (int index) { if (index >= size) throw new IndexOutOfBoundsException("index can't be >= size: " + index + " >= " + size); float[] items = this.items; float value = items[index]; size--; if (ordered) System.arraycopy(items, index + 1, items, index, size - index); else items[index] = items[size]; return value; } /** Removes the items between the specified indices, inclusive. */ public void removeRange (int start, int end) { int n = size; if (end >= n) throw new IndexOutOfBoundsException("end can't be >= size: " + end + " >= " + size); if (start > end) throw new IndexOutOfBoundsException("start can't be > end: " + start + " > " + end); int count = end - start + 1, lastIndex = n - count; if (ordered) System.arraycopy(items, start + count, items, start, n - (start + count)); else { int i = Math.max(lastIndex, end + 1); System.arraycopy(items, i, items, start, n - i); } size = n - count; } /** Removes from this array all of elements contained in the specified array. * @return true if this array was modified. */ public boolean removeAll (FloatArray array) { int size = this.size; int startSize = size; float[] items = this.items; for (int i = 0, n = array.size; i < n; i++) { float item = array.get(i); for (int ii = 0; ii < size; ii++) { if (item == items[ii]) { removeIndex(ii); size--; break; } } } return size != startSize; } /** Removes and returns the last item. */ public float pop () { return items[--size]; } /** Returns the last item. */ public float peek () { return items[size - 1]; } /** Returns the first item. */ public float first () { if (size == 0) throw new IllegalStateException("Array is empty."); return items[0]; } /** Returns true if the array has one or more items. */ public boolean notEmpty () { return size > 0; } /** Returns true if the array is empty. */ public boolean isEmpty () { return size == 0; } public void clear () { size = 0; } /** Reduces the size of the backing array to the size of the actual items. This is useful to release memory when many items * have been removed, or if it is known that more items will not be added. * @return {@link #items} */ public float[] shrink () { if (items.length != size) resize(size); return items; } /** Increases the size of the backing array to accommodate the specified number of additional items. Useful before adding many * items to avoid multiple backing array resizes. * @return {@link #items} */ public float[] ensureCapacity (int additionalCapacity) { if (additionalCapacity < 0) throw new IllegalArgumentException("additionalCapacity must be >= 0: " + additionalCapacity); int sizeNeeded = size + additionalCapacity; if (sizeNeeded > items.length) resize(Math.max(Math.max(8, sizeNeeded), (int)(size * 1.75f))); return items; } /** Sets the array size, leaving any values beyond the current size undefined. * @return {@link #items} */ public float[] setSize (int newSize) { if (newSize < 0) throw new IllegalArgumentException("newSize must be >= 0: " + newSize); if (newSize > items.length) resize(Math.max(8, newSize)); size = newSize; return items; } protected float[] resize (int newSize) { float[] newItems = new float[newSize]; float[] items = this.items; System.arraycopy(items, 0, newItems, 0, Math.min(size, newItems.length)); this.items = newItems; return newItems; } public void sort () { Arrays.sort(items, 0, size); } public void reverse () { float[] items = this.items; for (int i = 0, lastIndex = size - 1, n = size / 2; i < n; i++) { int ii = lastIndex - i; float temp = items[i]; items[i] = items[ii]; items[ii] = temp; } } public void shuffle () { float[] items = this.items; for (int i = size - 1; i >= 0; i--) { int ii = MathUtils.random(i); float temp = items[i]; items[i] = items[ii]; items[ii] = temp; } } /** Reduces the size of the array to the specified size. If the array is already smaller than the specified size, no action is * taken. */ public void truncate (int newSize) { if (size > newSize) size = newSize; } /** Returns a random item from the array, or zero if the array is empty. */ public float random () { if (size == 0) return 0; return items[MathUtils.random(0, size - 1)]; } public float[] toArray () { float[] array = new float[size]; System.arraycopy(items, 0, array, 0, size); return array; } public int hashCode () { if (!ordered) return super.hashCode(); float[] items = this.items; int h = 1; for (int i = 0, n = size; i < n; i++) h = h * 31 + NumberUtils.floatToRawIntBits(items[i]); return h; } /** Returns false if either array is unordered. */ public boolean equals (Object object) { if (object == this) return true; if (!ordered) return false; if (!(object instanceof FloatArray)) return false; FloatArray array = (FloatArray)object; if (!array.ordered) return false; int n = size; if (n != array.size) return false; float[] items1 = this.items, items2 = array.items; for (int i = 0; i < n; i++) if (items1[i] != items2[i]) return false; return true; } /** Returns false if either array is unordered. */ public boolean equals (Object object, float epsilon) { if (object == this) return true; if (!(object instanceof FloatArray)) return false; FloatArray array = (FloatArray)object; int n = size; if (n != array.size) return false; if (!ordered) return false; if (!array.ordered) return false; float[] items1 = this.items, items2 = array.items; for (int i = 0; i < n; i++) if (Math.abs(items1[i] - items2[i]) > epsilon) return false; return true; } public String toString () { if (size == 0) return "[]"; float[] items = this.items; StringBuilder buffer = new StringBuilder(32); buffer.append('['); buffer.append(items[0]); for (int i = 1; i < size; i++) { buffer.append(", "); buffer.append(items[i]); } buffer.append(']'); return buffer.toString(); } public String toString (String separator) { if (size == 0) return ""; float[] items = this.items; StringBuilder buffer = new StringBuilder(32); buffer.append(items[0]); for (int i = 1; i < size; i++) { buffer.append(separator); buffer.append(items[i]); } return buffer.toString(); } /** @see #FloatArray(float[]) */ static public FloatArray with (float... array) { return new FloatArray(array); } }
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.utils; import java.util.Arrays; import com.badlogic.gdx.math.MathUtils; /** A resizable, ordered or unordered float array. Avoids the boxing that occurs with ArrayList<Float>. If unordered, this class * avoids a memory copy when removing elements (the last element is moved to the removed element's position). * @author Nathan Sweet */ public class FloatArray { public float[] items; public int size; public boolean ordered; /** Creates an ordered array with a capacity of 16. */ public FloatArray () { this(true, 16); } /** Creates an ordered array with the specified capacity. */ public FloatArray (int capacity) { this(true, capacity); } /** @param ordered If false, methods that remove elements may change the order of other elements in the array, which avoids a * memory copy. * @param capacity Any elements added beyond this will cause the backing array to be grown. */ public FloatArray (boolean ordered, int capacity) { this.ordered = ordered; items = new float[capacity]; } /** Creates a new array containing the elements in the specific array. The new array will be ordered if the specific array is * ordered. The capacity is set to the number of elements, so any subsequent elements added will cause the backing array to be * grown. */ public FloatArray (FloatArray array) { this.ordered = array.ordered; size = array.size; items = new float[size]; System.arraycopy(array.items, 0, items, 0, size); } /** Creates a new ordered array containing the elements in the specified array. The capacity is set to the number of elements, * so any subsequent elements added will cause the backing array to be grown. */ public FloatArray (float[] array) { this(true, array, 0, array.length); } /** Creates a new array containing the elements in the specified array. The capacity is set to the number of elements, so any * subsequent elements added will cause the backing array to be grown. * @param ordered If false, methods that remove elements may change the order of other elements in the array, which avoids a * memory copy. */ public FloatArray (boolean ordered, float[] array, int startIndex, int count) { this(ordered, count); size = count; System.arraycopy(array, startIndex, items, 0, count); } public void add (float value) { float[] items = this.items; if (size == items.length) items = resize(Math.max(8, (int)(size * 1.75f))); items[size++] = value; } public void add (float value1, float value2) { float[] items = this.items; if (size + 1 >= items.length) items = resize(Math.max(8, (int)(size * 1.75f))); items[size] = value1; items[size + 1] = value2; size += 2; } public void add (float value1, float value2, float value3) { float[] items = this.items; if (size + 2 >= items.length) items = resize(Math.max(8, (int)(size * 1.75f))); items[size] = value1; items[size + 1] = value2; items[size + 2] = value3; size += 3; } public void add (float value1, float value2, float value3, float value4) { float[] items = this.items; if (size + 3 >= items.length) items = resize(Math.max(8, (int)(size * 1.8f))); // 1.75 isn't enough when size=5. items[size] = value1; items[size + 1] = value2; items[size + 2] = value3; items[size + 3] = value4; size += 4; } public void addAll (FloatArray array) { addAll(array.items, 0, array.size); } public void addAll (FloatArray array, int offset, int length) { if (offset + length > array.size) throw new IllegalArgumentException("offset + length must be <= size: " + offset + " + " + length + " <= " + array.size); addAll(array.items, offset, length); } public void addAll (float... array) { addAll(array, 0, array.length); } public void addAll (float[] array, int offset, int length) { float[] items = this.items; int sizeNeeded = size + length; if (sizeNeeded > items.length) items = resize(Math.max(Math.max(8, sizeNeeded), (int)(size * 1.75f))); System.arraycopy(array, offset, items, size, length); size += length; } public float get (int index) { if (index >= size) throw new IndexOutOfBoundsException("index can't be >= size: " + index + " >= " + size); return items[index]; } public void set (int index, float value) { if (index >= size) throw new IndexOutOfBoundsException("index can't be >= size: " + index + " >= " + size); items[index] = value; } public void incr (int index, float value) { if (index >= size) throw new IndexOutOfBoundsException("index can't be >= size: " + index + " >= " + size); items[index] += value; } public void incr (float value) { float[] items = this.items; for (int i = 0, n = size; i < n; i++) items[i] += value; } public void mul (int index, float value) { if (index >= size) throw new IndexOutOfBoundsException("index can't be >= size: " + index + " >= " + size); items[index] *= value; } public void mul (float value) { float[] items = this.items; for (int i = 0, n = size; i < n; i++) items[i] *= value; } public void insert (int index, float value) { if (index > size) throw new IndexOutOfBoundsException("index can't be > size: " + index + " > " + size); float[] items = this.items; if (size == items.length) items = resize(Math.max(8, (int)(size * 1.75f))); if (ordered) System.arraycopy(items, index, items, index + 1, size - index); else items[size] = items[index]; size++; items[index] = value; } /** Inserts the specified number of items at the specified index. The new items will have values equal to the values at those * indices before the insertion. */ public void insertRange (int index, int count) { if (index > size) throw new IndexOutOfBoundsException("index can't be > size: " + index + " > " + size); int sizeNeeded = size + count; if (sizeNeeded > items.length) items = resize(Math.max(Math.max(8, sizeNeeded), (int)(size * 1.75f))); System.arraycopy(items, index, items, index + count, size - index); size = sizeNeeded; } public void swap (int first, int second) { if (first >= size) throw new IndexOutOfBoundsException("first can't be >= size: " + first + " >= " + size); if (second >= size) throw new IndexOutOfBoundsException("second can't be >= size: " + second + " >= " + size); float[] items = this.items; float firstValue = items[first]; items[first] = items[second]; items[second] = firstValue; } public boolean contains (float value) { int i = size - 1; float[] items = this.items; while (i >= 0) if (items[i--] == value) return true; return false; } public int indexOf (float value) { float[] items = this.items; for (int i = 0, n = size; i < n; i++) if (items[i] == value) return i; return -1; } public int lastIndexOf (float value) { float[] items = this.items; for (int i = size - 1; i >= 0; i--) if (items[i] == value) return i; return -1; } public boolean removeValue (float value) { float[] items = this.items; for (int i = 0, n = size; i < n; i++) { if (items[i] == value) { removeIndex(i); return true; } } return false; } /** Removes and returns the item at the specified index. */ public float removeIndex (int index) { if (index >= size) throw new IndexOutOfBoundsException("index can't be >= size: " + index + " >= " + size); float[] items = this.items; float value = items[index]; size--; if (ordered) System.arraycopy(items, index + 1, items, index, size - index); else items[index] = items[size]; return value; } /** Removes the items between the specified indices, inclusive. */ public void removeRange (int start, int end) { int n = size; if (end >= n) throw new IndexOutOfBoundsException("end can't be >= size: " + end + " >= " + size); if (start > end) throw new IndexOutOfBoundsException("start can't be > end: " + start + " > " + end); int count = end - start + 1, lastIndex = n - count; if (ordered) System.arraycopy(items, start + count, items, start, n - (start + count)); else { int i = Math.max(lastIndex, end + 1); System.arraycopy(items, i, items, start, n - i); } size = n - count; } /** Removes from this array all of elements contained in the specified array. * @return true if this array was modified. */ public boolean removeAll (FloatArray array) { int size = this.size; int startSize = size; float[] items = this.items; for (int i = 0, n = array.size; i < n; i++) { float item = array.get(i); for (int ii = 0; ii < size; ii++) { if (item == items[ii]) { removeIndex(ii); size--; break; } } } return size != startSize; } /** Removes and returns the last item. */ public float pop () { return items[--size]; } /** Returns the last item. */ public float peek () { return items[size - 1]; } /** Returns the first item. */ public float first () { if (size == 0) throw new IllegalStateException("Array is empty."); return items[0]; } /** Returns true if the array has one or more items. */ public boolean notEmpty () { return size > 0; } /** Returns true if the array is empty. */ public boolean isEmpty () { return size == 0; } public void clear () { size = 0; } /** Reduces the size of the backing array to the size of the actual items. This is useful to release memory when many items * have been removed, or if it is known that more items will not be added. * @return {@link #items} */ public float[] shrink () { if (items.length != size) resize(size); return items; } /** Increases the size of the backing array to accommodate the specified number of additional items. Useful before adding many * items to avoid multiple backing array resizes. * @return {@link #items} */ public float[] ensureCapacity (int additionalCapacity) { if (additionalCapacity < 0) throw new IllegalArgumentException("additionalCapacity must be >= 0: " + additionalCapacity); int sizeNeeded = size + additionalCapacity; if (sizeNeeded > items.length) resize(Math.max(Math.max(8, sizeNeeded), (int)(size * 1.75f))); return items; } /** Sets the array size, leaving any values beyond the current size undefined. * @return {@link #items} */ public float[] setSize (int newSize) { if (newSize < 0) throw new IllegalArgumentException("newSize must be >= 0: " + newSize); if (newSize > items.length) resize(Math.max(8, newSize)); size = newSize; return items; } protected float[] resize (int newSize) { float[] newItems = new float[newSize]; float[] items = this.items; System.arraycopy(items, 0, newItems, 0, Math.min(size, newItems.length)); this.items = newItems; return newItems; } public void sort () { Arrays.sort(items, 0, size); } public void reverse () { float[] items = this.items; for (int i = 0, lastIndex = size - 1, n = size / 2; i < n; i++) { int ii = lastIndex - i; float temp = items[i]; items[i] = items[ii]; items[ii] = temp; } } public void shuffle () { float[] items = this.items; for (int i = size - 1; i >= 0; i--) { int ii = MathUtils.random(i); float temp = items[i]; items[i] = items[ii]; items[ii] = temp; } } /** Reduces the size of the array to the specified size. If the array is already smaller than the specified size, no action is * taken. */ public void truncate (int newSize) { if (size > newSize) size = newSize; } /** Returns a random item from the array, or zero if the array is empty. */ public float random () { if (size == 0) return 0; return items[MathUtils.random(0, size - 1)]; } public float[] toArray () { float[] array = new float[size]; System.arraycopy(items, 0, array, 0, size); return array; } public int hashCode () { if (!ordered) return super.hashCode(); float[] items = this.items; int h = 1; for (int i = 0, n = size; i < n; i++) h = h * 31 + NumberUtils.floatToRawIntBits(items[i]); return h; } /** Returns false if either array is unordered. */ public boolean equals (Object object) { if (object == this) return true; if (!ordered) return false; if (!(object instanceof FloatArray)) return false; FloatArray array = (FloatArray)object; if (!array.ordered) return false; int n = size; if (n != array.size) return false; float[] items1 = this.items, items2 = array.items; for (int i = 0; i < n; i++) if (items1[i] != items2[i]) return false; return true; } /** Returns false if either array is unordered. */ public boolean equals (Object object, float epsilon) { if (object == this) return true; if (!(object instanceof FloatArray)) return false; FloatArray array = (FloatArray)object; int n = size; if (n != array.size) return false; if (!ordered) return false; if (!array.ordered) return false; float[] items1 = this.items, items2 = array.items; for (int i = 0; i < n; i++) if (Math.abs(items1[i] - items2[i]) > epsilon) return false; return true; } public String toString () { if (size == 0) return "[]"; float[] items = this.items; StringBuilder buffer = new StringBuilder(32); buffer.append('['); buffer.append(items[0]); for (int i = 1; i < size; i++) { buffer.append(", "); buffer.append(items[i]); } buffer.append(']'); return buffer.toString(); } public String toString (String separator) { if (size == 0) return ""; float[] items = this.items; StringBuilder buffer = new StringBuilder(32); buffer.append(items[0]); for (int i = 1; i < size; i++) { buffer.append(separator); buffer.append(items[i]); } return buffer.toString(); } /** @see #FloatArray(float[]) */ static public FloatArray with (float... array) { return new FloatArray(array); } }
-1
libgdx/libgdx
7,270
Update missing build.gradle files with new syntax for registering tasks
Some Gradle build files were still using old syntax after https://github.com/libgdx/libgdx/pull/7134.
obigu
"2023-11-05T15:31:03Z"
"2023-11-13T11:04:33Z"
8e3b2ef2af2e1c1765b3441cb15cfbeddf4046fa
a25ceaddd8e9ea740b7e50e486ea4f815d2a3f58
Update missing build.gradle files with new syntax for registering tasks. Some Gradle build files were still using old syntax after https://github.com/libgdx/libgdx/pull/7134.
./tests/gdx-tests/src/com/badlogic/gdx/tests/gles32/GL32MultipleRenderTargetsBlendingTest.java
/******************************************************************************* * Copyright 2022 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.tests.gles32; import com.badlogic.gdx.Application.ApplicationType; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.GL30; import com.badlogic.gdx.graphics.GL32; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.glutils.FrameBuffer; import com.badlogic.gdx.graphics.glutils.GLFrameBuffer.FrameBufferBuilder; import com.badlogic.gdx.graphics.glutils.ShaderProgram; import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; import com.badlogic.gdx.tests.utils.GdxTest; import com.badlogic.gdx.tests.utils.GdxTestConfig; import com.badlogic.gdx.utils.GdxRuntimeException; import com.badlogic.gdx.utils.ScreenUtils; @GdxTestConfig(requireGL32 = true) public class GL32MultipleRenderTargetsBlendingTest extends GdxTest { static final String shapeRendererVS = "" + "attribute vec4 a_position;\n" + // "attribute vec4 a_color;\n" + // "uniform mat4 u_projModelView;\n" + // "varying vec4 v_color;\n" + // "void main() {\n" + // " v_color = a_color;\n" + // " gl_Position = u_projModelView * a_position;\n" + // "}"; static final String shapeRendererFS = "" + // "#if __VERSION__ < 300\n" + // "#extension GL_ARB_explicit_attrib_location : enable\n" + // "#endif\n" + // "\n" + // "layout(location = 0) out vec4 out_FragColor0;\n" + // "layout(location = 1) out vec4 out_FragColor1;\n" + // "layout(location = 2) out vec4 out_FragColor2;\n" + // "layout(location = 3) out vec4 out_FragColor3;\n" + // "layout(location = 4) out vec4 out_FragColor4;\n" + // "layout(location = 5) out vec4 out_FragColor5;\n" + // "layout(location = 6) out vec4 out_FragColor6;\n" + // "layout(location = 7) out vec4 out_FragColor7;\n" + // "in vec4 v_color;\n" + // "void main() {\n" + // " out_FragColor0 = v_color;\n" + // " out_FragColor1 = v_color;\n" + // " out_FragColor2 = v_color;\n" + // " out_FragColor3 = v_color;\n" + // " out_FragColor4 = v_color;\n" + // " out_FragColor5 = v_color;\n" + // " out_FragColor6 = v_color;\n" + // " out_FragColor7 = v_color;\n" + // "}"; static final String spriteBatchVS = "attribute vec4 " + ShaderProgram.POSITION_ATTRIBUTE + ";\n" // + "attribute vec4 " + ShaderProgram.COLOR_ATTRIBUTE + ";\n" // + "attribute vec2 " + ShaderProgram.TEXCOORD_ATTRIBUTE + "0;\n" // + "uniform mat4 u_projTrans;\n" // + "varying vec4 v_color;\n" // + "varying vec2 v_texCoords;\n" // + "\n" // + "void main()\n" // + "{\n" // + " v_color = " + ShaderProgram.COLOR_ATTRIBUTE + ";\n" // + " v_color.a = v_color.a * (255.0/254.0);\n" // + " v_texCoords = " + ShaderProgram.TEXCOORD_ATTRIBUTE + "0;\n" // + " gl_Position = u_projTrans * " + ShaderProgram.POSITION_ATTRIBUTE + ";\n" // + "}\n"; static final String spriteBatchFS = "#ifdef GL_ES\n" // + "#define LOWP lowp\n" // + "precision mediump float;\n" // + "#else\n" // + "#define LOWP \n" // + "#endif\n" // + "varying LOWP vec4 v_color;\n" // + "varying vec2 v_texCoords;\n" // + "uniform sampler2D u_texture;\n" // + "void main()\n"// + "{\n" // + " float a = texture2D(u_texture, v_texCoords).a;\n" // + " gl_FragColor = v_color * vec4(a, a, a, 1.0);\n" // + "}"; private FrameBuffer fbo; private ShapeRenderer shapes; private SpriteBatch batch; private ShaderProgram mrtShader; private ShaderProgram alphaShader; @Override public void create () { FrameBufferBuilder builder = new FrameBufferBuilder(64, 64); builder.addColorTextureAttachment(GL30.GL_RGBA8, GL30.GL_RGBA, GL30.GL_UNSIGNED_BYTE); builder.addColorTextureAttachment(GL30.GL_RGBA8, GL30.GL_RGBA, GL30.GL_UNSIGNED_BYTE); builder.addColorTextureAttachment(GL30.GL_RGBA8, GL30.GL_RGBA, GL30.GL_UNSIGNED_BYTE); builder.addColorTextureAttachment(GL30.GL_RGBA8, GL30.GL_RGBA, GL30.GL_UNSIGNED_BYTE); builder.addColorTextureAttachment(GL30.GL_RGBA8, GL30.GL_RGBA, GL30.GL_UNSIGNED_BYTE); builder.addColorTextureAttachment(GL30.GL_RGBA8, GL30.GL_RGBA, GL30.GL_UNSIGNED_BYTE); builder.addColorTextureAttachment(GL30.GL_RGBA8, GL30.GL_RGBA, GL30.GL_UNSIGNED_BYTE); builder.addColorTextureAttachment(GL30.GL_RGBA8, GL30.GL_RGBA, GL30.GL_UNSIGNED_BYTE); fbo = builder.build(); String prefix; if (Gdx.app.getType() == ApplicationType.Desktop) { prefix = "#version 150\n"; } else { prefix = "#version 300 es\n"; } String oldPrepend = ShaderProgram.prependFragmentCode; ShaderProgram.prependFragmentCode = null; mrtShader = new ShaderProgram(shapeRendererVS, prefix + shapeRendererFS); if (!mrtShader.isCompiled()) throw new GdxRuntimeException(mrtShader.getLog()); ShaderProgram.prependFragmentCode = oldPrepend; alphaShader = new ShaderProgram(spriteBatchVS, spriteBatchFS); if (!alphaShader.isCompiled()) throw new GdxRuntimeException(alphaShader.getLog()); shapes = new ShapeRenderer(6, mrtShader); batch = new SpriteBatch(); for (int i = 0; i < fbo.getTextureAttachments().size; i++) { boolean enabled = Gdx.gl32.glIsEnabledi(GL20.GL_BLEND, i); Gdx.app.log("Gdx", "#" + i + " blending: " + enabled); } } @Override public void dispose () { alphaShader.dispose(); mrtShader.dispose(); fbo.dispose(); shapes.dispose(); batch.dispose(); } @Override public void render () { // Configure blending for individual render target Gdx.gl32.glEnablei(GL20.GL_BLEND, 0); Gdx.gl32.glBlendFuncSeparatei(0, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA, GL20.GL_ONE, GL20.GL_ONE); Gdx.gl32.glEnablei(GL20.GL_BLEND, 1); Gdx.gl32.glBlendFunci(1, GL20.GL_SRC_ALPHA, GL20.GL_ONE); Gdx.gl32.glDisablei(GL20.GL_BLEND, 2); Gdx.gl32.glEnablei(GL20.GL_BLEND, 3); Gdx.gl32.glBlendFunci(3, GL20.GL_SRC_ALPHA, GL20.GL_ONE); Gdx.gl32.glBlendEquationi(3, GL20.GL_FUNC_SUBTRACT); Gdx.gl32.glDisablei(GL20.GL_BLEND, 4); Gdx.gl32.glColorMaski(4, true, false, false, false); Gdx.gl32.glEnablei(GL20.GL_BLEND, 5); Gdx.gl32.glBlendFunci(5, GL20.GL_SRC_ALPHA, GL20.GL_ONE); Gdx.gl32.glBlendEquationSeparatei(5, GL20.GL_FUNC_SUBTRACT, GL20.GL_FUNC_ADD); Gdx.gl32.glEnablei(GL20.GL_BLEND, 6); Gdx.gl32.glBlendFunci(6, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); Gdx.gl32.glBlendEquationSeparatei(6, GL32.GL_FUNC_REVERSE_SUBTRACT, GL20.GL_FUNC_ADD); Gdx.gl32.glEnablei(GL20.GL_BLEND, 7); Gdx.gl32.glBlendFunci(7, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); Gdx.gl32.glBlendEquationSeparatei(7, GL32.GL_MAX, GL20.GL_FUNC_ADD); // render into MRT fbo fbo.begin(); ScreenUtils.clear(Color.CLEAR); shapes.getProjectionMatrix().setToOrtho2D(0, 0, 4, 4); shapes.begin(ShapeType.Filled); shapes.setColor(1, .5f, 0, .5f); shapes.rect(0, 0, 3, 3); shapes.setColor(0f, .5f, .7f, .5f); shapes.rect(1, 1, 3, 3); shapes.end(); fbo.end(); // reset GL state for (int i = 0; i < 8; i++) { Gdx.gl32.glDisablei(GL20.GL_BLEND, i); Gdx.gl32.glBlendEquationi(i, GL20.GL_FUNC_ADD); Gdx.gl32.glBlendFunci(i, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); Gdx.gl32.glColorMaski(i, true, true, true, true); } // Display render targets batch.getProjectionMatrix().setToOrtho2D(0, 0, 4, 4); batch.disableBlending(); batch.begin(); float x = 0; batch.draw(fbo.getTextureAttachments().get(0), x, 0, 1, 1, 0, 0, 1, 1); batch.draw(fbo.getTextureAttachments().get(1), x + 1, 0, 1, 1, 0, 0, 1, 1); batch.draw(fbo.getTextureAttachments().get(2), x, 1, 1, 1, 0, 0, 1, 1); batch.draw(fbo.getTextureAttachments().get(3), x + 1, 1, 1, 1, 0, 0, 1, 1); batch.draw(fbo.getTextureAttachments().get(4), x, 2, 1, 1, 0, 0, 1, 1); batch.draw(fbo.getTextureAttachments().get(5), x + 1, 2, 1, 1, 0, 0, 1, 1); batch.draw(fbo.getTextureAttachments().get(6), x, 3, 1, 1, 0, 0, 1, 1); batch.draw(fbo.getTextureAttachments().get(7), x + 1, 3, 1, 1, 0, 0, 1, 1); batch.setShader(alphaShader); x = 2; batch.draw(fbo.getTextureAttachments().get(0), x, 0, 1, 1, 0, 0, 1, 1); batch.draw(fbo.getTextureAttachments().get(1), x + 1, 0, 1, 1, 0, 0, 1, 1); batch.draw(fbo.getTextureAttachments().get(2), x, 1, 1, 1, 0, 0, 1, 1); batch.draw(fbo.getTextureAttachments().get(3), x + 1, 1, 1, 1, 0, 0, 1, 1); batch.draw(fbo.getTextureAttachments().get(4), x, 2, 1, 1, 0, 0, 1, 1); batch.draw(fbo.getTextureAttachments().get(5), x + 1, 2, 1, 1, 0, 0, 1, 1); batch.draw(fbo.getTextureAttachments().get(6), x, 3, 1, 1, 0, 0, 1, 1); batch.draw(fbo.getTextureAttachments().get(7), x + 1, 3, 1, 1, 0, 0, 1, 1); batch.setShader(null); batch.end(); } }
/******************************************************************************* * Copyright 2022 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.tests.gles32; import com.badlogic.gdx.Application.ApplicationType; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.GL30; import com.badlogic.gdx.graphics.GL32; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.glutils.FrameBuffer; import com.badlogic.gdx.graphics.glutils.GLFrameBuffer.FrameBufferBuilder; import com.badlogic.gdx.graphics.glutils.ShaderProgram; import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; import com.badlogic.gdx.tests.utils.GdxTest; import com.badlogic.gdx.tests.utils.GdxTestConfig; import com.badlogic.gdx.utils.GdxRuntimeException; import com.badlogic.gdx.utils.ScreenUtils; @GdxTestConfig(requireGL32 = true) public class GL32MultipleRenderTargetsBlendingTest extends GdxTest { static final String shapeRendererVS = "" + "attribute vec4 a_position;\n" + // "attribute vec4 a_color;\n" + // "uniform mat4 u_projModelView;\n" + // "varying vec4 v_color;\n" + // "void main() {\n" + // " v_color = a_color;\n" + // " gl_Position = u_projModelView * a_position;\n" + // "}"; static final String shapeRendererFS = "" + // "#if __VERSION__ < 300\n" + // "#extension GL_ARB_explicit_attrib_location : enable\n" + // "#endif\n" + // "\n" + // "layout(location = 0) out vec4 out_FragColor0;\n" + // "layout(location = 1) out vec4 out_FragColor1;\n" + // "layout(location = 2) out vec4 out_FragColor2;\n" + // "layout(location = 3) out vec4 out_FragColor3;\n" + // "layout(location = 4) out vec4 out_FragColor4;\n" + // "layout(location = 5) out vec4 out_FragColor5;\n" + // "layout(location = 6) out vec4 out_FragColor6;\n" + // "layout(location = 7) out vec4 out_FragColor7;\n" + // "in vec4 v_color;\n" + // "void main() {\n" + // " out_FragColor0 = v_color;\n" + // " out_FragColor1 = v_color;\n" + // " out_FragColor2 = v_color;\n" + // " out_FragColor3 = v_color;\n" + // " out_FragColor4 = v_color;\n" + // " out_FragColor5 = v_color;\n" + // " out_FragColor6 = v_color;\n" + // " out_FragColor7 = v_color;\n" + // "}"; static final String spriteBatchVS = "attribute vec4 " + ShaderProgram.POSITION_ATTRIBUTE + ";\n" // + "attribute vec4 " + ShaderProgram.COLOR_ATTRIBUTE + ";\n" // + "attribute vec2 " + ShaderProgram.TEXCOORD_ATTRIBUTE + "0;\n" // + "uniform mat4 u_projTrans;\n" // + "varying vec4 v_color;\n" // + "varying vec2 v_texCoords;\n" // + "\n" // + "void main()\n" // + "{\n" // + " v_color = " + ShaderProgram.COLOR_ATTRIBUTE + ";\n" // + " v_color.a = v_color.a * (255.0/254.0);\n" // + " v_texCoords = " + ShaderProgram.TEXCOORD_ATTRIBUTE + "0;\n" // + " gl_Position = u_projTrans * " + ShaderProgram.POSITION_ATTRIBUTE + ";\n" // + "}\n"; static final String spriteBatchFS = "#ifdef GL_ES\n" // + "#define LOWP lowp\n" // + "precision mediump float;\n" // + "#else\n" // + "#define LOWP \n" // + "#endif\n" // + "varying LOWP vec4 v_color;\n" // + "varying vec2 v_texCoords;\n" // + "uniform sampler2D u_texture;\n" // + "void main()\n"// + "{\n" // + " float a = texture2D(u_texture, v_texCoords).a;\n" // + " gl_FragColor = v_color * vec4(a, a, a, 1.0);\n" // + "}"; private FrameBuffer fbo; private ShapeRenderer shapes; private SpriteBatch batch; private ShaderProgram mrtShader; private ShaderProgram alphaShader; @Override public void create () { FrameBufferBuilder builder = new FrameBufferBuilder(64, 64); builder.addColorTextureAttachment(GL30.GL_RGBA8, GL30.GL_RGBA, GL30.GL_UNSIGNED_BYTE); builder.addColorTextureAttachment(GL30.GL_RGBA8, GL30.GL_RGBA, GL30.GL_UNSIGNED_BYTE); builder.addColorTextureAttachment(GL30.GL_RGBA8, GL30.GL_RGBA, GL30.GL_UNSIGNED_BYTE); builder.addColorTextureAttachment(GL30.GL_RGBA8, GL30.GL_RGBA, GL30.GL_UNSIGNED_BYTE); builder.addColorTextureAttachment(GL30.GL_RGBA8, GL30.GL_RGBA, GL30.GL_UNSIGNED_BYTE); builder.addColorTextureAttachment(GL30.GL_RGBA8, GL30.GL_RGBA, GL30.GL_UNSIGNED_BYTE); builder.addColorTextureAttachment(GL30.GL_RGBA8, GL30.GL_RGBA, GL30.GL_UNSIGNED_BYTE); builder.addColorTextureAttachment(GL30.GL_RGBA8, GL30.GL_RGBA, GL30.GL_UNSIGNED_BYTE); fbo = builder.build(); String prefix; if (Gdx.app.getType() == ApplicationType.Desktop) { prefix = "#version 150\n"; } else { prefix = "#version 300 es\n"; } String oldPrepend = ShaderProgram.prependFragmentCode; ShaderProgram.prependFragmentCode = null; mrtShader = new ShaderProgram(shapeRendererVS, prefix + shapeRendererFS); if (!mrtShader.isCompiled()) throw new GdxRuntimeException(mrtShader.getLog()); ShaderProgram.prependFragmentCode = oldPrepend; alphaShader = new ShaderProgram(spriteBatchVS, spriteBatchFS); if (!alphaShader.isCompiled()) throw new GdxRuntimeException(alphaShader.getLog()); shapes = new ShapeRenderer(6, mrtShader); batch = new SpriteBatch(); for (int i = 0; i < fbo.getTextureAttachments().size; i++) { boolean enabled = Gdx.gl32.glIsEnabledi(GL20.GL_BLEND, i); Gdx.app.log("Gdx", "#" + i + " blending: " + enabled); } } @Override public void dispose () { alphaShader.dispose(); mrtShader.dispose(); fbo.dispose(); shapes.dispose(); batch.dispose(); } @Override public void render () { // Configure blending for individual render target Gdx.gl32.glEnablei(GL20.GL_BLEND, 0); Gdx.gl32.glBlendFuncSeparatei(0, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA, GL20.GL_ONE, GL20.GL_ONE); Gdx.gl32.glEnablei(GL20.GL_BLEND, 1); Gdx.gl32.glBlendFunci(1, GL20.GL_SRC_ALPHA, GL20.GL_ONE); Gdx.gl32.glDisablei(GL20.GL_BLEND, 2); Gdx.gl32.glEnablei(GL20.GL_BLEND, 3); Gdx.gl32.glBlendFunci(3, GL20.GL_SRC_ALPHA, GL20.GL_ONE); Gdx.gl32.glBlendEquationi(3, GL20.GL_FUNC_SUBTRACT); Gdx.gl32.glDisablei(GL20.GL_BLEND, 4); Gdx.gl32.glColorMaski(4, true, false, false, false); Gdx.gl32.glEnablei(GL20.GL_BLEND, 5); Gdx.gl32.glBlendFunci(5, GL20.GL_SRC_ALPHA, GL20.GL_ONE); Gdx.gl32.glBlendEquationSeparatei(5, GL20.GL_FUNC_SUBTRACT, GL20.GL_FUNC_ADD); Gdx.gl32.glEnablei(GL20.GL_BLEND, 6); Gdx.gl32.glBlendFunci(6, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); Gdx.gl32.glBlendEquationSeparatei(6, GL32.GL_FUNC_REVERSE_SUBTRACT, GL20.GL_FUNC_ADD); Gdx.gl32.glEnablei(GL20.GL_BLEND, 7); Gdx.gl32.glBlendFunci(7, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); Gdx.gl32.glBlendEquationSeparatei(7, GL32.GL_MAX, GL20.GL_FUNC_ADD); // render into MRT fbo fbo.begin(); ScreenUtils.clear(Color.CLEAR); shapes.getProjectionMatrix().setToOrtho2D(0, 0, 4, 4); shapes.begin(ShapeType.Filled); shapes.setColor(1, .5f, 0, .5f); shapes.rect(0, 0, 3, 3); shapes.setColor(0f, .5f, .7f, .5f); shapes.rect(1, 1, 3, 3); shapes.end(); fbo.end(); // reset GL state for (int i = 0; i < 8; i++) { Gdx.gl32.glDisablei(GL20.GL_BLEND, i); Gdx.gl32.glBlendEquationi(i, GL20.GL_FUNC_ADD); Gdx.gl32.glBlendFunci(i, GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA); Gdx.gl32.glColorMaski(i, true, true, true, true); } // Display render targets batch.getProjectionMatrix().setToOrtho2D(0, 0, 4, 4); batch.disableBlending(); batch.begin(); float x = 0; batch.draw(fbo.getTextureAttachments().get(0), x, 0, 1, 1, 0, 0, 1, 1); batch.draw(fbo.getTextureAttachments().get(1), x + 1, 0, 1, 1, 0, 0, 1, 1); batch.draw(fbo.getTextureAttachments().get(2), x, 1, 1, 1, 0, 0, 1, 1); batch.draw(fbo.getTextureAttachments().get(3), x + 1, 1, 1, 1, 0, 0, 1, 1); batch.draw(fbo.getTextureAttachments().get(4), x, 2, 1, 1, 0, 0, 1, 1); batch.draw(fbo.getTextureAttachments().get(5), x + 1, 2, 1, 1, 0, 0, 1, 1); batch.draw(fbo.getTextureAttachments().get(6), x, 3, 1, 1, 0, 0, 1, 1); batch.draw(fbo.getTextureAttachments().get(7), x + 1, 3, 1, 1, 0, 0, 1, 1); batch.setShader(alphaShader); x = 2; batch.draw(fbo.getTextureAttachments().get(0), x, 0, 1, 1, 0, 0, 1, 1); batch.draw(fbo.getTextureAttachments().get(1), x + 1, 0, 1, 1, 0, 0, 1, 1); batch.draw(fbo.getTextureAttachments().get(2), x, 1, 1, 1, 0, 0, 1, 1); batch.draw(fbo.getTextureAttachments().get(3), x + 1, 1, 1, 1, 0, 0, 1, 1); batch.draw(fbo.getTextureAttachments().get(4), x, 2, 1, 1, 0, 0, 1, 1); batch.draw(fbo.getTextureAttachments().get(5), x + 1, 2, 1, 1, 0, 0, 1, 1); batch.draw(fbo.getTextureAttachments().get(6), x, 3, 1, 1, 0, 0, 1, 1); batch.draw(fbo.getTextureAttachments().get(7), x + 1, 3, 1, 1, 0, 0, 1, 1); batch.setShader(null); batch.end(); } }
-1
libgdx/libgdx
7,270
Update missing build.gradle files with new syntax for registering tasks
Some Gradle build files were still using old syntax after https://github.com/libgdx/libgdx/pull/7134.
obigu
"2023-11-05T15:31:03Z"
"2023-11-13T11:04:33Z"
8e3b2ef2af2e1c1765b3441cb15cfbeddf4046fa
a25ceaddd8e9ea740b7e50e486ea4f815d2a3f58
Update missing build.gradle files with new syntax for registering tasks. Some Gradle build files were still using old syntax after https://github.com/libgdx/libgdx/pull/7134.
./tests/gdx-tests/src/com/badlogic/gdx/tests/g3d/HeightField.java
package com.badlogic.gdx.tests.g3d; import java.nio.Buffer; import java.nio.ByteBuffer; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Mesh; import com.badlogic.gdx.graphics.Pixmap; import com.badlogic.gdx.graphics.Pixmap.Format; import com.badlogic.gdx.graphics.VertexAttributes.Usage; import com.badlogic.gdx.graphics.VertexAttributes; import com.badlogic.gdx.graphics.g3d.utils.MeshBuilder; import com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder; import com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.VertexInfo; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.utils.Disposable; import com.badlogic.gdx.utils.GdxRuntimeException; /** This is a test class, showing how one could implement a height field. See also {@link HeightMapTest}. Do not expect this to be * a fully supported and implemented height field class. * <p /> * Represents a HeightField, which is an evenly spaced grid of values, where each value defines the height on that position of the * grid, so forming a 3D shape. Typically used for (relatively simple) terrains and such. See * <a href="http://en.wikipedia.org/wiki/Heightmap">wikipedia</a> for more information. * <p /> * A height field has a width and height, specifying the width and height of the grid. Points on this grid are specified using * integer values, named "x" and "y". Do not confuse these with the x, y and z floating point values representing coordinates in * world space. * <p /> * The values of the heightfield are normalized. Meaning that they typically range from 0 to 1 (but they can be negative or more * than one). The plane of the heightfield can be specified using the {@link #corner00}, {@link #corner01}, {@link #corner10} and * {@link #corner11} members. Where `corner00` is the location on the grid at x:0, y;0, `corner01` at x:0, y:height-1, `corner10` * at x:width-1, y:0 and `corner11` the location on the grid at x:width-1, y:height-1. * <p /> * The height and direction of the field can be set using the {@link #magnitude} vector. Typically this should be the vector * perpendicular to the heightfield. E.g. if the field is on the XZ plane, then the magnitude is typically pointing on the Y axis. * The length of the `magnitude` specifies the height of the height field. In other words, the word coordinate of a point on the * grid is specified as: * <p /> * base[y * width + x] + magnitude * value[y * width + x] * <p /> * Use the {@link #getPositionAt(Vector3, int, int)} method to get the coordinate of a specific point on the grid. * <p /> * You can set this heightfield using the constructor or one of the `set` methods. E.g. by specifying an array of values or a * {@link Pixmap}. The latter can be used to load a HeightMap, which is an image loaded from disc of which each texel is used to * specify the value for each point on the field. Be aware that the total number of vertices cannot exceed 32k. Using a large * height map will result in unpredicted results. * <p /> * You can also manually modify the heightfield by directly accessing the {@link #data} member. The index within this array can be * calculates as: `y * width + x`. E.g. `field.data[y * field.width + x] = value;`. When you modify the data then you can update * the {@link #mesh} using the {@link #update()} method. * <p /> * The {@link #mesh} member can be used to render the height field. The vertex attributes this mesh contains are specified in the * constructor. There are two ways for generating the mesh: smooth and sharp. * <p /> * Smooth can be forced by specifying `true` for the `smooth` argument of the constructor. Otherwise it will be based on whether * the specified vertex attributes contains a normal attribute. If there is no normal attribute then the mesh will always be * smooth (even when you specify `false` in the constructor). In this case the number of vertices is the same as the amount of * grid points. Causing vertices to be shared amongst multiple faces. * <p /> * Sharp will be used if the vertex attributes contains a normal attribute and you didnt specify `true` for the `smooth` argument * of the constructor. This will cause the number of vertices to be around four times the amount grid points and each normal is * estimated for each face instead of each point. * @author Xoppa */ public class HeightField implements Disposable { public final Vector2 uvOffset = new Vector2(0, 0); public final Vector2 uvScale = new Vector2(1, 1); public final Color color00 = new Color(Color.WHITE); public final Color color10 = new Color(Color.WHITE); public final Color color01 = new Color(Color.WHITE); public final Color color11 = new Color(Color.WHITE); public final Vector3 corner00 = new Vector3(0, 0, 0); public final Vector3 corner10 = new Vector3(1, 0, 0); public final Vector3 corner01 = new Vector3(0, 0, 1); public final Vector3 corner11 = new Vector3(1, 0, 1); public final Vector3 magnitude = new Vector3(0, 1, 0); public final float[] data; public final int width; public final int height; public final boolean smooth; public final Mesh mesh; private final float vertices[]; private final int stride; private final int posPos; private final int norPos; private final int uvPos; private final int colPos; private final MeshPartBuilder.VertexInfo vertex00 = new MeshPartBuilder.VertexInfo(); private final MeshPartBuilder.VertexInfo vertex10 = new MeshPartBuilder.VertexInfo(); private final MeshPartBuilder.VertexInfo vertex01 = new MeshPartBuilder.VertexInfo(); private final MeshPartBuilder.VertexInfo vertex11 = new MeshPartBuilder.VertexInfo(); private final Vector3 tmpV1 = new Vector3(); private final Vector3 tmpV2 = new Vector3(); private final Vector3 tmpV3 = new Vector3(); private final Vector3 tmpV4 = new Vector3(); private final Vector3 tmpV5 = new Vector3(); private final Vector3 tmpV6 = new Vector3(); private final Vector3 tmpV7 = new Vector3(); private final Vector3 tmpV8 = new Vector3(); private final Vector3 tmpV9 = new Vector3(); private final Color tmpC = new Color(); public HeightField (boolean isStatic, final Pixmap map, boolean smooth, int attributes) { this(isStatic, map.getWidth(), map.getHeight(), smooth, attributes); set(map); } public HeightField (boolean isStatic, final ByteBuffer colorData, final Pixmap.Format format, int width, int height, boolean smooth, int attributes) { this(isStatic, width, height, smooth, attributes); set(colorData, format); } public HeightField (boolean isStatic, final float[] data, int width, int height, boolean smooth, int attributes) { this(isStatic, width, height, smooth, attributes); set(data); } public HeightField (boolean isStatic, int width, int height, boolean smooth, int attributes) { this(isStatic, width, height, smooth, MeshBuilder.createAttributes(attributes)); } public HeightField (boolean isStatic, int width, int height, boolean smooth, VertexAttributes attributes) { this.posPos = attributes.getOffset(Usage.Position, -1); this.norPos = attributes.getOffset(Usage.Normal, -1); this.uvPos = attributes.getOffset(Usage.TextureCoordinates, -1); this.colPos = attributes.getOffset(Usage.ColorUnpacked, -1); smooth = smooth || (norPos < 0); // cant have sharp edges without normals this.width = width; this.height = height; this.smooth = smooth; this.data = new float[width * height]; this.stride = attributes.vertexSize / 4; final int numVertices = smooth ? width * height : (width - 1) * (height - 1) * 4; final int numIndices = (width - 1) * (height - 1) * 6; this.mesh = new Mesh(isStatic, numVertices, numIndices, attributes); this.vertices = new float[numVertices * stride]; setIndices(); } private void setIndices () { final int w = width - 1; final int h = height - 1; short indices[] = new short[w * h * 6]; int i = -1; for (int y = 0; y < h; ++y) { for (int x = 0; x < w; ++x) { final int c00 = smooth ? (y * width + x) : (y * 2 * w + x * 2); final int c10 = c00 + 1; final int c01 = c00 + (smooth ? width : w * 2); final int c11 = c10 + (smooth ? width : w * 2); indices[++i] = (short)c11; indices[++i] = (short)c10; indices[++i] = (short)c00; indices[++i] = (short)c00; indices[++i] = (short)c01; indices[++i] = (short)c11; } } mesh.setIndices(indices); } public void update () { if (smooth) { if (norPos < 0) updateSimple(); else updateSmooth(); } else updateSharp(); } private void updateSmooth () { for (int x = 0; x < width; ++x) { for (int y = 0; y < height; ++y) { VertexInfo v = getVertexAt(vertex00, x, y); getWeightedNormalAt(v.normal, x, y); setVertex(y * width + x, v); } } mesh.setVertices(vertices); } private void updateSimple () { for (int x = 0; x < width; ++x) { for (int y = 0; y < height; ++y) { setVertex(y * width + x, getVertexAt(vertex00, x, y)); } } mesh.setVertices(vertices); } private void updateSharp () { final int w = width - 1; final int h = height - 1; for (int y = 0; y < h; ++y) { for (int x = 0; x < w; ++x) { final int c00 = (y * 2 * w + x * 2); final int c10 = c00 + 1; final int c01 = c00 + w * 2; final int c11 = c10 + w * 2; VertexInfo v00 = getVertexAt(vertex00, x, y); VertexInfo v10 = getVertexAt(vertex10, x + 1, y); VertexInfo v01 = getVertexAt(vertex01, x, y + 1); VertexInfo v11 = getVertexAt(vertex11, x + 1, y + 1); v01.normal.set(v01.position).sub(v00.position).nor().crs(tmpV1.set(v11.position).sub(v01.position).nor()); v10.normal.set(v10.position).sub(v11.position).nor().crs(tmpV1.set(v00.position).sub(v10.position).nor()); v00.normal.set(v01.normal).lerp(v10.normal, .5f); v11.normal.set(v00.normal); setVertex(c00, v00); setVertex(c10, v10); setVertex(c01, v01); setVertex(c11, v11); } } mesh.setVertices(vertices); } /** Does not set the normal member! */ protected VertexInfo getVertexAt (final VertexInfo out, int x, int y) { final float dx = (float)x / (float)(width - 1); final float dy = (float)y / (float)(height - 1); final float a = data[y * width + x]; out.position.set(corner00).lerp(corner10, dx).lerp(tmpV1.set(corner01).lerp(corner11, dx), dy); out.position.add(tmpV1.set(magnitude).scl(a)); out.color.set(color00).lerp(color10, dx).lerp(tmpC.set(color01).lerp(color11, dx), dy); out.uv.set(dx, dy).scl(uvScale).add(uvOffset); return out; } public Vector3 getPositionAt (Vector3 out, int x, int y) { final float dx = (float)x / (float)(width - 1); final float dy = (float)y / (float)(height - 1); final float a = data[y * width + x]; out.set(corner00).lerp(corner10, dx).lerp(tmpV1.set(corner01).lerp(corner11, dx), dy); out.add(tmpV1.set(magnitude).scl(a)); return out; } public Vector3 getWeightedNormalAt (Vector3 out, int x, int y) { // This commented code is based on http://www.flipcode.com/archives/Calculating_Vertex_Normals_for_Height_Maps.shtml // Note that this approach only works for a heightfield on the XZ plane with a magnitude on the y axis // float sx = data[(x < width - 1 ? x + 1 : x) + y * width] + data[(x > 0 ? x-1 : x) + y * width]; // if (x == 0 || x == (width - 1)) // sx *= 2f; // float sy = data[(y < height - 1 ? y + 1 : y) * width + x] + data[(y > 0 ? y-1 : y) * width + x]; // if (y == 0 || y == (height - 1)) // sy *= 2f; // float xScale = (corner11.x - corner00.x) / (width - 1f); // float zScale = (corner11.z - corner00.z) / (height - 1f); // float yScale = magnitude.len(); // out.set(-sx * yScale, 2f * xScale, sy*yScale*xScale / zScale).nor(); // return out; // The following approach weights the normal of the four triangles (half quad) surrounding the position. // A more accurate approach would be to weight the normal of the actual triangles. int faces = 0; out.set(0, 0, 0); Vector3 center = getPositionAt(tmpV2, x, y); Vector3 left = x > 0 ? getPositionAt(tmpV3, x - 1, y) : null; Vector3 right = x < (width - 1) ? getPositionAt(tmpV4, x + 1, y) : null; Vector3 bottom = y > 0 ? getPositionAt(tmpV5, x, y - 1) : null; Vector3 top = y < (height - 1) ? getPositionAt(tmpV6, x, y + 1) : null; if (top != null && left != null) { out.add(tmpV7.set(top).sub(center).nor().crs(tmpV8.set(center).sub(left).nor()).nor()); faces++; } if (left != null && bottom != null) { out.add(tmpV7.set(left).sub(center).nor().crs(tmpV8.set(center).sub(bottom).nor()).nor()); faces++; } if (bottom != null && right != null) { out.add(tmpV7.set(bottom).sub(center).nor().crs(tmpV8.set(center).sub(right).nor()).nor()); faces++; } if (right != null && top != null) { out.add(tmpV7.set(right).sub(center).nor().crs(tmpV8.set(center).sub(top).nor()).nor()); faces++; } if (faces != 0) out.scl(1f / (float)faces); else out.set(magnitude).nor(); return out; } protected void setVertex (int index, VertexInfo info) { index *= stride; if (posPos >= 0) { vertices[index + posPos + 0] = info.position.x; vertices[index + posPos + 1] = info.position.y; vertices[index + posPos + 2] = info.position.z; } if (norPos >= 0) { vertices[index + norPos + 0] = info.normal.x; vertices[index + norPos + 1] = info.normal.y; vertices[index + norPos + 2] = info.normal.z; } if (uvPos >= 0) { vertices[index + uvPos + 0] = info.uv.x; vertices[index + uvPos + 1] = info.uv.y; } if (colPos >= 0) { vertices[index + colPos + 0] = info.color.r; vertices[index + colPos + 1] = info.color.g; vertices[index + colPos + 2] = info.color.b; vertices[index + colPos + 3] = info.color.a; } } public void set (final Pixmap map) { if (map.getWidth() != width || map.getHeight() != height) throw new GdxRuntimeException("Incorrect map size"); set(map.getPixels(), map.getFormat()); } public void set (final ByteBuffer colorData, final Pixmap.Format format) { set(heightColorsToMap(colorData, format, width, height)); } public void set (float[] data) { set(data, 0); } public void set (float[] data, int offset) { if (this.data.length > (data.length - offset)) throw new GdxRuntimeException("Incorrect data size"); System.arraycopy(data, offset, this.data, 0, this.data.length); update(); } @Override public void dispose () { mesh.dispose(); } /** Simply creates an array containing only all the red components of the data. */ public static float[] heightColorsToMap (final ByteBuffer data, final Pixmap.Format format, int width, int height) { final int bytesPerColor = (format == Format.RGB888 ? 3 : (format == Format.RGBA8888 ? 4 : 0)); if (bytesPerColor == 0) throw new GdxRuntimeException("Unsupported format, should be either RGB8 or RGBA8"); if (data.remaining() < (width * height * bytesPerColor)) throw new GdxRuntimeException("Incorrect map size"); final int startPos = data.position(); byte[] source = null; int sourceOffset = 0; if (data.hasArray() && !data.isReadOnly()) { source = data.array(); sourceOffset = data.arrayOffset() + startPos; } else { source = new byte[width * height * bytesPerColor]; data.get(source); ((Buffer)data).position(startPos); } float[] dest = new float[width * height]; for (int i = 0; i < dest.length; ++i) { int v = source[sourceOffset + i * bytesPerColor]; v = v < 0 ? 256 + v : v; dest[i] = (float)v / 255f; } return dest; } }
package com.badlogic.gdx.tests.g3d; import java.nio.Buffer; import java.nio.ByteBuffer; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Mesh; import com.badlogic.gdx.graphics.Pixmap; import com.badlogic.gdx.graphics.Pixmap.Format; import com.badlogic.gdx.graphics.VertexAttributes.Usage; import com.badlogic.gdx.graphics.VertexAttributes; import com.badlogic.gdx.graphics.g3d.utils.MeshBuilder; import com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder; import com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder.VertexInfo; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.utils.Disposable; import com.badlogic.gdx.utils.GdxRuntimeException; /** This is a test class, showing how one could implement a height field. See also {@link HeightMapTest}. Do not expect this to be * a fully supported and implemented height field class. * <p /> * Represents a HeightField, which is an evenly spaced grid of values, where each value defines the height on that position of the * grid, so forming a 3D shape. Typically used for (relatively simple) terrains and such. See * <a href="http://en.wikipedia.org/wiki/Heightmap">wikipedia</a> for more information. * <p /> * A height field has a width and height, specifying the width and height of the grid. Points on this grid are specified using * integer values, named "x" and "y". Do not confuse these with the x, y and z floating point values representing coordinates in * world space. * <p /> * The values of the heightfield are normalized. Meaning that they typically range from 0 to 1 (but they can be negative or more * than one). The plane of the heightfield can be specified using the {@link #corner00}, {@link #corner01}, {@link #corner10} and * {@link #corner11} members. Where `corner00` is the location on the grid at x:0, y;0, `corner01` at x:0, y:height-1, `corner10` * at x:width-1, y:0 and `corner11` the location on the grid at x:width-1, y:height-1. * <p /> * The height and direction of the field can be set using the {@link #magnitude} vector. Typically this should be the vector * perpendicular to the heightfield. E.g. if the field is on the XZ plane, then the magnitude is typically pointing on the Y axis. * The length of the `magnitude` specifies the height of the height field. In other words, the word coordinate of a point on the * grid is specified as: * <p /> * base[y * width + x] + magnitude * value[y * width + x] * <p /> * Use the {@link #getPositionAt(Vector3, int, int)} method to get the coordinate of a specific point on the grid. * <p /> * You can set this heightfield using the constructor or one of the `set` methods. E.g. by specifying an array of values or a * {@link Pixmap}. The latter can be used to load a HeightMap, which is an image loaded from disc of which each texel is used to * specify the value for each point on the field. Be aware that the total number of vertices cannot exceed 32k. Using a large * height map will result in unpredicted results. * <p /> * You can also manually modify the heightfield by directly accessing the {@link #data} member. The index within this array can be * calculates as: `y * width + x`. E.g. `field.data[y * field.width + x] = value;`. When you modify the data then you can update * the {@link #mesh} using the {@link #update()} method. * <p /> * The {@link #mesh} member can be used to render the height field. The vertex attributes this mesh contains are specified in the * constructor. There are two ways for generating the mesh: smooth and sharp. * <p /> * Smooth can be forced by specifying `true` for the `smooth` argument of the constructor. Otherwise it will be based on whether * the specified vertex attributes contains a normal attribute. If there is no normal attribute then the mesh will always be * smooth (even when you specify `false` in the constructor). In this case the number of vertices is the same as the amount of * grid points. Causing vertices to be shared amongst multiple faces. * <p /> * Sharp will be used if the vertex attributes contains a normal attribute and you didnt specify `true` for the `smooth` argument * of the constructor. This will cause the number of vertices to be around four times the amount grid points and each normal is * estimated for each face instead of each point. * @author Xoppa */ public class HeightField implements Disposable { public final Vector2 uvOffset = new Vector2(0, 0); public final Vector2 uvScale = new Vector2(1, 1); public final Color color00 = new Color(Color.WHITE); public final Color color10 = new Color(Color.WHITE); public final Color color01 = new Color(Color.WHITE); public final Color color11 = new Color(Color.WHITE); public final Vector3 corner00 = new Vector3(0, 0, 0); public final Vector3 corner10 = new Vector3(1, 0, 0); public final Vector3 corner01 = new Vector3(0, 0, 1); public final Vector3 corner11 = new Vector3(1, 0, 1); public final Vector3 magnitude = new Vector3(0, 1, 0); public final float[] data; public final int width; public final int height; public final boolean smooth; public final Mesh mesh; private final float vertices[]; private final int stride; private final int posPos; private final int norPos; private final int uvPos; private final int colPos; private final MeshPartBuilder.VertexInfo vertex00 = new MeshPartBuilder.VertexInfo(); private final MeshPartBuilder.VertexInfo vertex10 = new MeshPartBuilder.VertexInfo(); private final MeshPartBuilder.VertexInfo vertex01 = new MeshPartBuilder.VertexInfo(); private final MeshPartBuilder.VertexInfo vertex11 = new MeshPartBuilder.VertexInfo(); private final Vector3 tmpV1 = new Vector3(); private final Vector3 tmpV2 = new Vector3(); private final Vector3 tmpV3 = new Vector3(); private final Vector3 tmpV4 = new Vector3(); private final Vector3 tmpV5 = new Vector3(); private final Vector3 tmpV6 = new Vector3(); private final Vector3 tmpV7 = new Vector3(); private final Vector3 tmpV8 = new Vector3(); private final Vector3 tmpV9 = new Vector3(); private final Color tmpC = new Color(); public HeightField (boolean isStatic, final Pixmap map, boolean smooth, int attributes) { this(isStatic, map.getWidth(), map.getHeight(), smooth, attributes); set(map); } public HeightField (boolean isStatic, final ByteBuffer colorData, final Pixmap.Format format, int width, int height, boolean smooth, int attributes) { this(isStatic, width, height, smooth, attributes); set(colorData, format); } public HeightField (boolean isStatic, final float[] data, int width, int height, boolean smooth, int attributes) { this(isStatic, width, height, smooth, attributes); set(data); } public HeightField (boolean isStatic, int width, int height, boolean smooth, int attributes) { this(isStatic, width, height, smooth, MeshBuilder.createAttributes(attributes)); } public HeightField (boolean isStatic, int width, int height, boolean smooth, VertexAttributes attributes) { this.posPos = attributes.getOffset(Usage.Position, -1); this.norPos = attributes.getOffset(Usage.Normal, -1); this.uvPos = attributes.getOffset(Usage.TextureCoordinates, -1); this.colPos = attributes.getOffset(Usage.ColorUnpacked, -1); smooth = smooth || (norPos < 0); // cant have sharp edges without normals this.width = width; this.height = height; this.smooth = smooth; this.data = new float[width * height]; this.stride = attributes.vertexSize / 4; final int numVertices = smooth ? width * height : (width - 1) * (height - 1) * 4; final int numIndices = (width - 1) * (height - 1) * 6; this.mesh = new Mesh(isStatic, numVertices, numIndices, attributes); this.vertices = new float[numVertices * stride]; setIndices(); } private void setIndices () { final int w = width - 1; final int h = height - 1; short indices[] = new short[w * h * 6]; int i = -1; for (int y = 0; y < h; ++y) { for (int x = 0; x < w; ++x) { final int c00 = smooth ? (y * width + x) : (y * 2 * w + x * 2); final int c10 = c00 + 1; final int c01 = c00 + (smooth ? width : w * 2); final int c11 = c10 + (smooth ? width : w * 2); indices[++i] = (short)c11; indices[++i] = (short)c10; indices[++i] = (short)c00; indices[++i] = (short)c00; indices[++i] = (short)c01; indices[++i] = (short)c11; } } mesh.setIndices(indices); } public void update () { if (smooth) { if (norPos < 0) updateSimple(); else updateSmooth(); } else updateSharp(); } private void updateSmooth () { for (int x = 0; x < width; ++x) { for (int y = 0; y < height; ++y) { VertexInfo v = getVertexAt(vertex00, x, y); getWeightedNormalAt(v.normal, x, y); setVertex(y * width + x, v); } } mesh.setVertices(vertices); } private void updateSimple () { for (int x = 0; x < width; ++x) { for (int y = 0; y < height; ++y) { setVertex(y * width + x, getVertexAt(vertex00, x, y)); } } mesh.setVertices(vertices); } private void updateSharp () { final int w = width - 1; final int h = height - 1; for (int y = 0; y < h; ++y) { for (int x = 0; x < w; ++x) { final int c00 = (y * 2 * w + x * 2); final int c10 = c00 + 1; final int c01 = c00 + w * 2; final int c11 = c10 + w * 2; VertexInfo v00 = getVertexAt(vertex00, x, y); VertexInfo v10 = getVertexAt(vertex10, x + 1, y); VertexInfo v01 = getVertexAt(vertex01, x, y + 1); VertexInfo v11 = getVertexAt(vertex11, x + 1, y + 1); v01.normal.set(v01.position).sub(v00.position).nor().crs(tmpV1.set(v11.position).sub(v01.position).nor()); v10.normal.set(v10.position).sub(v11.position).nor().crs(tmpV1.set(v00.position).sub(v10.position).nor()); v00.normal.set(v01.normal).lerp(v10.normal, .5f); v11.normal.set(v00.normal); setVertex(c00, v00); setVertex(c10, v10); setVertex(c01, v01); setVertex(c11, v11); } } mesh.setVertices(vertices); } /** Does not set the normal member! */ protected VertexInfo getVertexAt (final VertexInfo out, int x, int y) { final float dx = (float)x / (float)(width - 1); final float dy = (float)y / (float)(height - 1); final float a = data[y * width + x]; out.position.set(corner00).lerp(corner10, dx).lerp(tmpV1.set(corner01).lerp(corner11, dx), dy); out.position.add(tmpV1.set(magnitude).scl(a)); out.color.set(color00).lerp(color10, dx).lerp(tmpC.set(color01).lerp(color11, dx), dy); out.uv.set(dx, dy).scl(uvScale).add(uvOffset); return out; } public Vector3 getPositionAt (Vector3 out, int x, int y) { final float dx = (float)x / (float)(width - 1); final float dy = (float)y / (float)(height - 1); final float a = data[y * width + x]; out.set(corner00).lerp(corner10, dx).lerp(tmpV1.set(corner01).lerp(corner11, dx), dy); out.add(tmpV1.set(magnitude).scl(a)); return out; } public Vector3 getWeightedNormalAt (Vector3 out, int x, int y) { // This commented code is based on http://www.flipcode.com/archives/Calculating_Vertex_Normals_for_Height_Maps.shtml // Note that this approach only works for a heightfield on the XZ plane with a magnitude on the y axis // float sx = data[(x < width - 1 ? x + 1 : x) + y * width] + data[(x > 0 ? x-1 : x) + y * width]; // if (x == 0 || x == (width - 1)) // sx *= 2f; // float sy = data[(y < height - 1 ? y + 1 : y) * width + x] + data[(y > 0 ? y-1 : y) * width + x]; // if (y == 0 || y == (height - 1)) // sy *= 2f; // float xScale = (corner11.x - corner00.x) / (width - 1f); // float zScale = (corner11.z - corner00.z) / (height - 1f); // float yScale = magnitude.len(); // out.set(-sx * yScale, 2f * xScale, sy*yScale*xScale / zScale).nor(); // return out; // The following approach weights the normal of the four triangles (half quad) surrounding the position. // A more accurate approach would be to weight the normal of the actual triangles. int faces = 0; out.set(0, 0, 0); Vector3 center = getPositionAt(tmpV2, x, y); Vector3 left = x > 0 ? getPositionAt(tmpV3, x - 1, y) : null; Vector3 right = x < (width - 1) ? getPositionAt(tmpV4, x + 1, y) : null; Vector3 bottom = y > 0 ? getPositionAt(tmpV5, x, y - 1) : null; Vector3 top = y < (height - 1) ? getPositionAt(tmpV6, x, y + 1) : null; if (top != null && left != null) { out.add(tmpV7.set(top).sub(center).nor().crs(tmpV8.set(center).sub(left).nor()).nor()); faces++; } if (left != null && bottom != null) { out.add(tmpV7.set(left).sub(center).nor().crs(tmpV8.set(center).sub(bottom).nor()).nor()); faces++; } if (bottom != null && right != null) { out.add(tmpV7.set(bottom).sub(center).nor().crs(tmpV8.set(center).sub(right).nor()).nor()); faces++; } if (right != null && top != null) { out.add(tmpV7.set(right).sub(center).nor().crs(tmpV8.set(center).sub(top).nor()).nor()); faces++; } if (faces != 0) out.scl(1f / (float)faces); else out.set(magnitude).nor(); return out; } protected void setVertex (int index, VertexInfo info) { index *= stride; if (posPos >= 0) { vertices[index + posPos + 0] = info.position.x; vertices[index + posPos + 1] = info.position.y; vertices[index + posPos + 2] = info.position.z; } if (norPos >= 0) { vertices[index + norPos + 0] = info.normal.x; vertices[index + norPos + 1] = info.normal.y; vertices[index + norPos + 2] = info.normal.z; } if (uvPos >= 0) { vertices[index + uvPos + 0] = info.uv.x; vertices[index + uvPos + 1] = info.uv.y; } if (colPos >= 0) { vertices[index + colPos + 0] = info.color.r; vertices[index + colPos + 1] = info.color.g; vertices[index + colPos + 2] = info.color.b; vertices[index + colPos + 3] = info.color.a; } } public void set (final Pixmap map) { if (map.getWidth() != width || map.getHeight() != height) throw new GdxRuntimeException("Incorrect map size"); set(map.getPixels(), map.getFormat()); } public void set (final ByteBuffer colorData, final Pixmap.Format format) { set(heightColorsToMap(colorData, format, width, height)); } public void set (float[] data) { set(data, 0); } public void set (float[] data, int offset) { if (this.data.length > (data.length - offset)) throw new GdxRuntimeException("Incorrect data size"); System.arraycopy(data, offset, this.data, 0, this.data.length); update(); } @Override public void dispose () { mesh.dispose(); } /** Simply creates an array containing only all the red components of the data. */ public static float[] heightColorsToMap (final ByteBuffer data, final Pixmap.Format format, int width, int height) { final int bytesPerColor = (format == Format.RGB888 ? 3 : (format == Format.RGBA8888 ? 4 : 0)); if (bytesPerColor == 0) throw new GdxRuntimeException("Unsupported format, should be either RGB8 or RGBA8"); if (data.remaining() < (width * height * bytesPerColor)) throw new GdxRuntimeException("Incorrect map size"); final int startPos = data.position(); byte[] source = null; int sourceOffset = 0; if (data.hasArray() && !data.isReadOnly()) { source = data.array(); sourceOffset = data.arrayOffset() + startPos; } else { source = new byte[width * height * bytesPerColor]; data.get(source); ((Buffer)data).position(startPos); } float[] dest = new float[width * height]; for (int i = 0; i < dest.length; ++i) { int v = source[sourceOffset + i * bytesPerColor]; v = v < 0 ? 256 + v : v; dest[i] = (float)v / 255f; } return dest; } }
-1
libgdx/libgdx
7,270
Update missing build.gradle files with new syntax for registering tasks
Some Gradle build files were still using old syntax after https://github.com/libgdx/libgdx/pull/7134.
obigu
"2023-11-05T15:31:03Z"
"2023-11-13T11:04:33Z"
8e3b2ef2af2e1c1765b3441cb15cfbeddf4046fa
a25ceaddd8e9ea740b7e50e486ea4f815d2a3f58
Update missing build.gradle files with new syntax for registering tasks. Some Gradle build files were still using old syntax after https://github.com/libgdx/libgdx/pull/7134.
./tests/gdx-tests-android/assets/data/shaders/projtex-vert.glsl
attribute vec4 a_position; attribute vec3 a_normal; uniform mat4 u_camera; uniform mat4 u_projector; uniform mat4 u_model; uniform mat4 u_modelNormal; uniform vec3 u_projectorPos; uniform vec3 u_color; varying vec3 v_color; varying vec4 v_texcoords; varying vec3 v_normal; varying vec3 v_position; void main() { vec4 worldPos = u_model * a_position; vec3 worldNormal = (u_modelNormal * vec4(a_normal, 1)).xyz; v_position = worldPos.xyz; v_normal = worldNormal.xyz; v_color = u_color; v_texcoords = u_projector * worldPos; gl_Position = u_camera * worldPos; }
attribute vec4 a_position; attribute vec3 a_normal; uniform mat4 u_camera; uniform mat4 u_projector; uniform mat4 u_model; uniform mat4 u_modelNormal; uniform vec3 u_projectorPos; uniform vec3 u_color; varying vec3 v_color; varying vec4 v_texcoords; varying vec3 v_normal; varying vec3 v_position; void main() { vec4 worldPos = u_model * a_position; vec3 worldNormal = (u_modelNormal * vec4(a_normal, 1)).xyz; v_position = worldPos.xyz; v_normal = worldNormal.xyz; v_color = u_color; v_texcoords = u_projector * worldPos; gl_Position = u_camera * worldPos; }
-1
libgdx/libgdx
7,270
Update missing build.gradle files with new syntax for registering tasks
Some Gradle build files were still using old syntax after https://github.com/libgdx/libgdx/pull/7134.
obigu
"2023-11-05T15:31:03Z"
"2023-11-13T11:04:33Z"
8e3b2ef2af2e1c1765b3441cb15cfbeddf4046fa
a25ceaddd8e9ea740b7e50e486ea4f815d2a3f58
Update missing build.gradle files with new syntax for registering tasks. Some Gradle build files were still using old syntax after https://github.com/libgdx/libgdx/pull/7134.
./extensions/gdx-bullet/jni/swig-src/collision/com/badlogic/gdx/physics/bullet/collision/btCompoundShapeData.java
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.collision; import com.badlogic.gdx.physics.bullet.BulletBase; import com.badlogic.gdx.physics.bullet.linearmath.*; public class btCompoundShapeData extends BulletBase { private long swigCPtr; protected btCompoundShapeData (final String className, long cPtr, boolean cMemoryOwn) { super(className, cPtr, cMemoryOwn); swigCPtr = cPtr; } /** Construct a new btCompoundShapeData, normally you should not need this constructor it's intended for low-level usage. */ public btCompoundShapeData (long cPtr, boolean cMemoryOwn) { this("btCompoundShapeData", cPtr, cMemoryOwn); construct(); } @Override protected void reset (long cPtr, boolean cMemoryOwn) { if (!destroyed) destroy(); super.reset(swigCPtr = cPtr, cMemoryOwn); } public static long getCPtr (btCompoundShapeData obj) { return (obj == null) ? 0 : obj.swigCPtr; } @Override protected void finalize () throws Throwable { if (!destroyed) destroy(); super.finalize(); } @Override protected synchronized void delete () { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; CollisionJNI.delete_btCompoundShapeData(swigCPtr); } swigCPtr = 0; } super.delete(); } public void setCollisionShapeData (btCollisionShapeData value) { CollisionJNI.btCompoundShapeData_collisionShapeData_set(swigCPtr, this, btCollisionShapeData.getCPtr(value), value); } public btCollisionShapeData getCollisionShapeData () { long cPtr = CollisionJNI.btCompoundShapeData_collisionShapeData_get(swigCPtr, this); return (cPtr == 0) ? null : new btCollisionShapeData(cPtr, false); } public void setChildShapePtr (btCompoundShapeChildData value) { CollisionJNI.btCompoundShapeData_childShapePtr_set(swigCPtr, this, btCompoundShapeChildData.getCPtr(value), value); } public btCompoundShapeChildData getChildShapePtr () { long cPtr = CollisionJNI.btCompoundShapeData_childShapePtr_get(swigCPtr, this); return (cPtr == 0) ? null : new btCompoundShapeChildData(cPtr, false); } public void setNumChildShapes (int value) { CollisionJNI.btCompoundShapeData_numChildShapes_set(swigCPtr, this, value); } public int getNumChildShapes () { return CollisionJNI.btCompoundShapeData_numChildShapes_get(swigCPtr, this); } public void setCollisionMargin (float value) { CollisionJNI.btCompoundShapeData_collisionMargin_set(swigCPtr, this, value); } public float getCollisionMargin () { return CollisionJNI.btCompoundShapeData_collisionMargin_get(swigCPtr, this); } public btCompoundShapeData () { this(CollisionJNI.new_btCompoundShapeData(), true); } }
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.collision; import com.badlogic.gdx.physics.bullet.BulletBase; import com.badlogic.gdx.physics.bullet.linearmath.*; public class btCompoundShapeData extends BulletBase { private long swigCPtr; protected btCompoundShapeData (final String className, long cPtr, boolean cMemoryOwn) { super(className, cPtr, cMemoryOwn); swigCPtr = cPtr; } /** Construct a new btCompoundShapeData, normally you should not need this constructor it's intended for low-level usage. */ public btCompoundShapeData (long cPtr, boolean cMemoryOwn) { this("btCompoundShapeData", cPtr, cMemoryOwn); construct(); } @Override protected void reset (long cPtr, boolean cMemoryOwn) { if (!destroyed) destroy(); super.reset(swigCPtr = cPtr, cMemoryOwn); } public static long getCPtr (btCompoundShapeData obj) { return (obj == null) ? 0 : obj.swigCPtr; } @Override protected void finalize () throws Throwable { if (!destroyed) destroy(); super.finalize(); } @Override protected synchronized void delete () { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; CollisionJNI.delete_btCompoundShapeData(swigCPtr); } swigCPtr = 0; } super.delete(); } public void setCollisionShapeData (btCollisionShapeData value) { CollisionJNI.btCompoundShapeData_collisionShapeData_set(swigCPtr, this, btCollisionShapeData.getCPtr(value), value); } public btCollisionShapeData getCollisionShapeData () { long cPtr = CollisionJNI.btCompoundShapeData_collisionShapeData_get(swigCPtr, this); return (cPtr == 0) ? null : new btCollisionShapeData(cPtr, false); } public void setChildShapePtr (btCompoundShapeChildData value) { CollisionJNI.btCompoundShapeData_childShapePtr_set(swigCPtr, this, btCompoundShapeChildData.getCPtr(value), value); } public btCompoundShapeChildData getChildShapePtr () { long cPtr = CollisionJNI.btCompoundShapeData_childShapePtr_get(swigCPtr, this); return (cPtr == 0) ? null : new btCompoundShapeChildData(cPtr, false); } public void setNumChildShapes (int value) { CollisionJNI.btCompoundShapeData_numChildShapes_set(swigCPtr, this, value); } public int getNumChildShapes () { return CollisionJNI.btCompoundShapeData_numChildShapes_get(swigCPtr, this); } public void setCollisionMargin (float value) { CollisionJNI.btCompoundShapeData_collisionMargin_set(swigCPtr, this, value); } public float getCollisionMargin () { return CollisionJNI.btCompoundShapeData_collisionMargin_get(swigCPtr, this); } public btCompoundShapeData () { this(CollisionJNI.new_btCompoundShapeData(), true); } }
-1
libgdx/libgdx
7,270
Update missing build.gradle files with new syntax for registering tasks
Some Gradle build files were still using old syntax after https://github.com/libgdx/libgdx/pull/7134.
obigu
"2023-11-05T15:31:03Z"
"2023-11-13T11:04:33Z"
8e3b2ef2af2e1c1765b3441cb15cfbeddf4046fa
a25ceaddd8e9ea740b7e50e486ea4f815d2a3f58
Update missing build.gradle files with new syntax for registering tasks. Some Gradle build files were still using old syntax after https://github.com/libgdx/libgdx/pull/7134.
./gdx/src/com/badlogic/gdx/ApplicationAdapter.java
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx; /** Convenience implementation of {@link ApplicationListener}. Derive from this and only override what you need. * @author mzechner */ public abstract class ApplicationAdapter implements ApplicationListener { @Override public void create () { } @Override public void resize (int width, int height) { } @Override public void render () { } @Override public void pause () { } @Override public void resume () { } @Override public void dispose () { } }
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx; /** Convenience implementation of {@link ApplicationListener}. Derive from this and only override what you need. * @author mzechner */ public abstract class ApplicationAdapter implements ApplicationListener { @Override public void create () { } @Override public void resize (int width, int height) { } @Override public void render () { } @Override public void pause () { } @Override public void resume () { } @Override public void dispose () { } }
-1
libgdx/libgdx
7,270
Update missing build.gradle files with new syntax for registering tasks
Some Gradle build files were still using old syntax after https://github.com/libgdx/libgdx/pull/7134.
obigu
"2023-11-05T15:31:03Z"
"2023-11-13T11:04:33Z"
8e3b2ef2af2e1c1765b3441cb15cfbeddf4046fa
a25ceaddd8e9ea740b7e50e486ea4f815d2a3f58
Update missing build.gradle files with new syntax for registering tasks. Some Gradle build files were still using old syntax after https://github.com/libgdx/libgdx/pull/7134.
./extensions/gdx-tools/src/com/badlogic/gdx/tools/flame/PointSpriteBatchPanel.java
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.tools.flame; import java.awt.GridBagConstraints; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.DefaultComboBoxModel; import javax.swing.JComboBox; import javax.swing.JLabel; import com.badlogic.gdx.graphics.g3d.particles.batches.PointSpriteParticleBatch; public class PointSpriteBatchPanel extends EditorPanel<PointSpriteParticleBatch> { JComboBox sortCombo; JComboBox srcBlendFunction, destBlendFunction; public PointSpriteBatchPanel (FlameMain particleEditor3D, PointSpriteParticleBatch renderer) { super(particleEditor3D, "Point sprite Batch", "Renderer used to draw point sprite particles."); initializeComponents(renderer); setValue(renderer); } private void initializeComponents (PointSpriteParticleBatch renderer) { // Sort sortCombo = new JComboBox(); sortCombo.setModel(new DefaultComboBoxModel(SortMode.values())); sortCombo.setSelectedItem(SortMode.find(renderer.getSorter())); sortCombo.addActionListener(new ActionListener() { public void actionPerformed (ActionEvent event) { SortMode mode = (SortMode)sortCombo.getSelectedItem(); editor.getPointSpriteBatch().setSorter(mode.sorter); } }); // Blending source srcBlendFunction = new JComboBox(); srcBlendFunction.setModel(new DefaultComboBoxModel(BlendFunction.values())); srcBlendFunction.setSelectedItem(BlendFunction.find(renderer.getBlendingAttribute().sourceFunction)); srcBlendFunction.addActionListener(new ActionListener() { public void actionPerformed (ActionEvent event) { BlendFunction blend = (BlendFunction)srcBlendFunction.getSelectedItem(); editor.getPointSpriteBatch().getBlendingAttribute().sourceFunction = blend.blend; } }); // Blending destination destBlendFunction = new JComboBox(); destBlendFunction.setModel(new DefaultComboBoxModel(BlendFunction.values())); destBlendFunction.setSelectedItem(BlendFunction.find(renderer.getBlendingAttribute().destFunction)); destBlendFunction.addActionListener(new ActionListener() { public void actionPerformed (ActionEvent event) { BlendFunction blend = (BlendFunction)destBlendFunction.getSelectedItem(); editor.getPointSpriteBatch().getBlendingAttribute().destFunction = blend.blend; } }); int i = 0; Insets insets = new Insets(3, 0, 0, 0); contentPanel.add(new JLabel("Sort"), new GridBagConstraints(0, i, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insets, 0, 0)); contentPanel.add(sortCombo, new GridBagConstraints(1, i++, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insets, 0, 0)); contentPanel.add(new JLabel("Blending Src"), new GridBagConstraints(0, i, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insets, 0, 0)); contentPanel.add(srcBlendFunction, new GridBagConstraints(1, i++, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insets, 0, 0)); contentPanel.add(new JLabel("Blending Dest"), new GridBagConstraints(0, i, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insets, 0, 0)); contentPanel.add(destBlendFunction, new GridBagConstraints(1, i++, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insets, 0, 0)); } }
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.tools.flame; import java.awt.GridBagConstraints; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.DefaultComboBoxModel; import javax.swing.JComboBox; import javax.swing.JLabel; import com.badlogic.gdx.graphics.g3d.particles.batches.PointSpriteParticleBatch; public class PointSpriteBatchPanel extends EditorPanel<PointSpriteParticleBatch> { JComboBox sortCombo; JComboBox srcBlendFunction, destBlendFunction; public PointSpriteBatchPanel (FlameMain particleEditor3D, PointSpriteParticleBatch renderer) { super(particleEditor3D, "Point sprite Batch", "Renderer used to draw point sprite particles."); initializeComponents(renderer); setValue(renderer); } private void initializeComponents (PointSpriteParticleBatch renderer) { // Sort sortCombo = new JComboBox(); sortCombo.setModel(new DefaultComboBoxModel(SortMode.values())); sortCombo.setSelectedItem(SortMode.find(renderer.getSorter())); sortCombo.addActionListener(new ActionListener() { public void actionPerformed (ActionEvent event) { SortMode mode = (SortMode)sortCombo.getSelectedItem(); editor.getPointSpriteBatch().setSorter(mode.sorter); } }); // Blending source srcBlendFunction = new JComboBox(); srcBlendFunction.setModel(new DefaultComboBoxModel(BlendFunction.values())); srcBlendFunction.setSelectedItem(BlendFunction.find(renderer.getBlendingAttribute().sourceFunction)); srcBlendFunction.addActionListener(new ActionListener() { public void actionPerformed (ActionEvent event) { BlendFunction blend = (BlendFunction)srcBlendFunction.getSelectedItem(); editor.getPointSpriteBatch().getBlendingAttribute().sourceFunction = blend.blend; } }); // Blending destination destBlendFunction = new JComboBox(); destBlendFunction.setModel(new DefaultComboBoxModel(BlendFunction.values())); destBlendFunction.setSelectedItem(BlendFunction.find(renderer.getBlendingAttribute().destFunction)); destBlendFunction.addActionListener(new ActionListener() { public void actionPerformed (ActionEvent event) { BlendFunction blend = (BlendFunction)destBlendFunction.getSelectedItem(); editor.getPointSpriteBatch().getBlendingAttribute().destFunction = blend.blend; } }); int i = 0; Insets insets = new Insets(3, 0, 0, 0); contentPanel.add(new JLabel("Sort"), new GridBagConstraints(0, i, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insets, 0, 0)); contentPanel.add(sortCombo, new GridBagConstraints(1, i++, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insets, 0, 0)); contentPanel.add(new JLabel("Blending Src"), new GridBagConstraints(0, i, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insets, 0, 0)); contentPanel.add(srcBlendFunction, new GridBagConstraints(1, i++, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insets, 0, 0)); contentPanel.add(new JLabel("Blending Dest"), new GridBagConstraints(0, i, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insets, 0, 0)); contentPanel.add(destBlendFunction, new GridBagConstraints(1, i++, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, insets, 0, 0)); } }
-1
libgdx/libgdx
7,270
Update missing build.gradle files with new syntax for registering tasks
Some Gradle build files were still using old syntax after https://github.com/libgdx/libgdx/pull/7134.
obigu
"2023-11-05T15:31:03Z"
"2023-11-13T11:04:33Z"
8e3b2ef2af2e1c1765b3441cb15cfbeddf4046fa
a25ceaddd8e9ea740b7e50e486ea4f815d2a3f58
Update missing build.gradle files with new syntax for registering tasks. Some Gradle build files were still using old syntax after https://github.com/libgdx/libgdx/pull/7134.
./extensions/gdx-bullet/jni/src/bullet/BulletCollision/CollisionShapes/btTriangleMesh.h
/* Bullet Continuous Collision Detection and Physics Library Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #ifndef BT_TRIANGLE_MESH_H #define BT_TRIANGLE_MESH_H #include "btTriangleIndexVertexArray.h" #include "LinearMath/btVector3.h" #include "LinearMath/btAlignedObjectArray.h" ///The btTriangleMesh class is a convenience class derived from btTriangleIndexVertexArray, that provides storage for a concave triangle mesh. It can be used as data for the btBvhTriangleMeshShape. ///It allows either 32bit or 16bit indices, and 4 (x-y-z-w) or 3 (x-y-z) component vertices. ///If you want to share triangle/index data between graphics mesh and collision mesh (btBvhTriangleMeshShape), you can directly use btTriangleIndexVertexArray or derive your own class from btStridingMeshInterface. ///Performance of btTriangleMesh and btTriangleIndexVertexArray used in a btBvhTriangleMeshShape is the same. class btTriangleMesh : public btTriangleIndexVertexArray { btAlignedObjectArray<btVector3> m_4componentVertices; btAlignedObjectArray<btScalar> m_3componentVertices; btAlignedObjectArray<unsigned int> m_32bitIndices; btAlignedObjectArray<unsigned short int> m_16bitIndices; bool m_use32bitIndices; bool m_use4componentVertices; public: btScalar m_weldingThreshold; btTriangleMesh (bool use32bitIndices=true,bool use4componentVertices=true); bool getUse32bitIndices() const { return m_use32bitIndices; } bool getUse4componentVertices() const { return m_use4componentVertices; } ///By default addTriangle won't search for duplicate vertices, because the search is very slow for large triangle meshes. ///In general it is better to directly use btTriangleIndexVertexArray instead. void addTriangle(const btVector3& vertex0,const btVector3& vertex1,const btVector3& vertex2, bool removeDuplicateVertices=false); ///Add a triangle using its indices. Make sure the indices are pointing within the vertices array, so add the vertices first (and to be sure, avoid removal of duplicate vertices) void addTriangleIndices(int index1, int index2, int index3 ); int getNumTriangles() const; virtual void preallocateVertices(int numverts); virtual void preallocateIndices(int numindices); ///findOrAddVertex is an internal method, use addTriangle instead int findOrAddVertex(const btVector3& vertex, bool removeDuplicateVertices); ///addIndex is an internal method, use addTriangle instead void addIndex(int index); }; #endif //BT_TRIANGLE_MESH_H
/* Bullet Continuous Collision Detection and Physics Library Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #ifndef BT_TRIANGLE_MESH_H #define BT_TRIANGLE_MESH_H #include "btTriangleIndexVertexArray.h" #include "LinearMath/btVector3.h" #include "LinearMath/btAlignedObjectArray.h" ///The btTriangleMesh class is a convenience class derived from btTriangleIndexVertexArray, that provides storage for a concave triangle mesh. It can be used as data for the btBvhTriangleMeshShape. ///It allows either 32bit or 16bit indices, and 4 (x-y-z-w) or 3 (x-y-z) component vertices. ///If you want to share triangle/index data between graphics mesh and collision mesh (btBvhTriangleMeshShape), you can directly use btTriangleIndexVertexArray or derive your own class from btStridingMeshInterface. ///Performance of btTriangleMesh and btTriangleIndexVertexArray used in a btBvhTriangleMeshShape is the same. class btTriangleMesh : public btTriangleIndexVertexArray { btAlignedObjectArray<btVector3> m_4componentVertices; btAlignedObjectArray<btScalar> m_3componentVertices; btAlignedObjectArray<unsigned int> m_32bitIndices; btAlignedObjectArray<unsigned short int> m_16bitIndices; bool m_use32bitIndices; bool m_use4componentVertices; public: btScalar m_weldingThreshold; btTriangleMesh (bool use32bitIndices=true,bool use4componentVertices=true); bool getUse32bitIndices() const { return m_use32bitIndices; } bool getUse4componentVertices() const { return m_use4componentVertices; } ///By default addTriangle won't search for duplicate vertices, because the search is very slow for large triangle meshes. ///In general it is better to directly use btTriangleIndexVertexArray instead. void addTriangle(const btVector3& vertex0,const btVector3& vertex1,const btVector3& vertex2, bool removeDuplicateVertices=false); ///Add a triangle using its indices. Make sure the indices are pointing within the vertices array, so add the vertices first (and to be sure, avoid removal of duplicate vertices) void addTriangleIndices(int index1, int index2, int index3 ); int getNumTriangles() const; virtual void preallocateVertices(int numverts); virtual void preallocateIndices(int numindices); ///findOrAddVertex is an internal method, use addTriangle instead int findOrAddVertex(const btVector3& vertex, bool removeDuplicateVertices); ///addIndex is an internal method, use addTriangle instead void addIndex(int index); }; #endif //BT_TRIANGLE_MESH_H
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./CHANGES
[1.12.1] - LWJGL3 Improvement: Audio device is automatically switched if it was changed in the operating system. - Tiled Fix: TiledLayer parallax default values fix - API Addition: TiledDrawable: Align can be set to manipulate the alignment of the rendering (TiledDrawable#setAlign, TiledDrawable#getAlign) - API Addition: TiledDrawable#draw: Also available as a static function (with align) if you don't want to create an extra instance per texture region - Android: Removed mouse catching added on 1.12.0 due to unintended effects (see #7187). - Android: Fixed touch state inconsistency when touching screen with 3 fingers on some devices (see #7256) - iOS: Update to MobiVM 2.3.20 - API Addition: Using "object" property in Tiled object now fetches MapObject being pointed to, and BaseTmxMapLoader includes method for fetching map where key is id and value is MapObject instance. - Update to LWJGL 3.3.3 [1.12.0] - [BREAKING CHANGE] Added #touchCancelled to InputProcessor interface, see #6871. - [BREAKING CHANGE] Android: Immersive mode is now true by default. Set `useImmersiveMode` config to `false` to disable it. - [BREAKING CHANGE] iOS: Increased min supported iOS version to 11.0. Update your Info.plist file if necessary. - [BREAKING CHANGE] iOS: `hideHomeIndicator` set to `false` by default (was `true`). - [BREAKING CHANGE] iOS: `screenEdgesDeferringSystemGestures` set to `UIRectEdge.All` by default (was `UIRectEdge.None`). - [BREAKING CHANGE] iOS: preferred FPS is now uncapped by default, see #6717 - [BREAKING CHANGE] iOS: `ApplicationListener.create` and first `resize` are now called within `UIApplicationDelegate.didFinishLaunching`. Allows for earlier rendering and prevents black screen frames after launch screen. NOTE: App will get terminated if this method is blocked for more than 10-20 sec. - [BREAKING CHANGE] Actor#localToAscendantCoordinates throws an exception if the specified actor is not an ascendant. - [BREAKING CHANGE] WidgetGroup#hit first validates the layout. - [BREAKING CHANGE] Cell getters return object wrapper instead of primitives. - [BREAKING CHANGE] MeshPartBuilder#lastIndex now returns int instead of short. - [BREAKING CHANGE] 3D API - max bone weights is now configurable and limited to 4 by default. Change this value if you need less or more. See #6522. - [BREAKING CHANGE] Mesh#getVerticesBuffer, Mesh#getIndicesBuffer, VertexData#getBuffer, and IndexData#getBuffer are deprecated in favor to new methods with boolean parameter. If you subclassed some of these classes, you need to implement the new methods. - [BREAKING CHANGE] Desktop: The return value of AudioDevice#getLatency() is now in samples, and not milliseconds - [BREAKING CHANGE] iOS: 32 bit (armv7) builds are no longer supported. Builds must be 64 bit (arm64) only. - [BREAKING CHANGE] iOS: Use dynamic frameworks instead of static libs - [BREAKING CHANGE] optimized Mesh#bind and Mesh#unbind have a new parameter for instanced attribute locations. If you use these methods without instancing, you can pass a null value. - [BREAKING CHANGE] Dropped support for older libc versions since libGDX is now built on Ubuntu 20.04 (#7005) - [KNOWN ISSUE] Android drag behaviour. Gdx.input.getDeltaX() and Gdx.input.getDeltaY always return 0 for pointer 0. Fixed on next version. - Update to jnigen 2.4.1 - LWJGL Fix: setPosision() for MP3 files. - iOS: Add new MobiVM MetalANGLE backend - iOS: Update to MobiVM 2.3.19 - Update to LWJGL 3.3.2 - API Addition: Added Audio#switchOutputDevice and Audio#getAvailableOutputDevices to specify output devices. Only works for LWJGL3 - Fix LWJGL3: Audio doesn't die anymore, if a device gets disconnected - API Addition: Added Haptics API with 4 different Input#vibrate() methods with complete Android and iOS implementations. - Fix: Fixed Android and iOS touch cancelled related issues, see #6871. - Javadoc: Add "-use" flag to javadoc generation - Android: gdx-setup now uses AGP 7.2.2 and SDK 32, requiring Android Studio Chipmunk or IntelliJ IDEA 2022.2 and JDK 11. - libGDX is now built using Java 11 due to new Android requirements. The rest of libGDX can still be built with JDK 8 and runtime compatibility of libGDX projects should be unaffected. - Fixed glViewport when using HdpiMode.Logical with the LWJGL3 backend. - Added Stage#actorRemoved to fire exit events just before an actor is removed. - ScrollPane#setScrollingDisabled avoids invalidate() if nothing changed. - Fixed incorrect ScrollPane#scrollTo. - API Addition: Added Texture3D support - Fix: Throw an exception when maximum Attribute count is reached to prevent silent failure. - API Fix: The cursor can now be catched on Android. - LWJGL3 Fix: Stereo audio can now be played on mono output devices. This may also improve downmixing to stereo and upmixing to surround. - API Addition: Added CheckBox#getImageDrawable. - FIX: HexagonalTiledMapRenderer now displays maps with the correct stagger index. - API Addition: Added I18NBundle#keys() method. - TOOLS Features: Save mode can be changed in Flame particle 3D editor. - API Addition: added WebGL 2.0 implementation to Gwt backend : you can enable it by GwtApplicationConfiguration#useGL30 - Added GLES31 and GLES32 support with Lwjgl3 backend implementation - API Addition: JsonReader#stop() to stop parsing. - API Change: TextureAtlas now uses FileHandle#reader so outside code can control the charset - API Fix: Intersector#isPointInTriangle - API Addition: The Skin serializer now supports useIntegerPositions - API Change: The skin serializer now treats scaledSize as a float - API Change: DataInput throws an EOF-Exception - API Fix: RenderBuffer leak in GLFrameBuffer class - API Change: Pixmap#setPixels will now verify it has been given a direct ByteBuffer - API Addition: glTexImage2D and glTexSubImage2D with offset parameter - API Addition: OrientedBoundingBox - API Addition: Tiled parallax factor support - API Fix: LWJGL 3’s borderless fullscreen works with negative monitor coords - API Fix: Update mouse x and y values immediately after calling #setCursorPosition - API Change: Never stall with AssetManager on GWT - API Change: Allow packed depth stencil buffer creation when not using GL30 - API Fix: Fixed DataInput#readString for non-ASCII - API Fix: LwjglGraphics.setupDisplay() is no longer choosing the wrong display mode - API Fix: MathUtils.lerpAngle() fixed for extreme inputs - MathUtils trigonometry improvements - Various Scene2D fixes and improvements - Fix: JsonValue#addChild now clears leftover list pointers, preventing inconsistent or looping JSON objects. [1.11.0] - [BREAKING CHANGE] iOS: Increased min supported iOS version to 9.0. Update your Info.plist file if necessary. - [BREAKING CHANGE] Removed Maven and Ant build systems. libGDX is now solely built with Gradle. See https://libgdx.com/dev/from-source/ for updated build instructions. - [BREAKING CHANGE] Android Moved natives loading out of static init block, see #5795 - [BREAKING CHANGE] Linux: Shared libraries are now built on Ubuntu 18.04 (up from Ubuntu 16.04) - [BREAKING CHANGE] The built-in font files arial-15.fnt and arial-15.png have been replaced with lsans-15.fnt and lsans-15.png; this may change some text layout that uses the built-in font, and code that expects arial-15 assets to be present must change to lsans-15. - [BREAKING CHANGE] Legacy LWJGL3 projects must update the sourceCompatibility to 1.8 or higher. - [BREAKING CHANGE] Android Removed hideStatusBar configuration, see #6683 - [BREAKING CHANGE] Lwjgl3ApplicationConfiguration#useOpenGL3 was replaced by #setOpenGLEmulation - Gradle build now takes -PjavaVersion=7|8|9... to specify the Java version against which to compile libGDX. Default is Java 7 for everything, except the LWJGL3 backend, which is compiled for Java 8. - LWJGL3 extension: Added gdx-lwjgl3-glfw-awt-macos extension. Fixes GLFW in such a way, that the LWJGL3/libGDX must no longer run on the main thread in macOS, which allows AWT to work in parallel, i.e. file dialogs, JFrames, ImageIO, etc. You no longer need to pass `-XstartOnFirstThread` when starting an LWJGL3 app on macOS. See `AwtTestLWJGL` in gdx-tests-lwjgl3. For more information, see https://github.com/libgdx/libgdx/pull/6772 - API Addition: Added LWJGL3 ANGLE support for x86_64 Windows, Linux, and macOS. Emulates OpenGL ES 2.0 through DirectX (Windows), desktop OpenGL (Linux), and Metal (macOS). May become the preferred method of rendering on macOS if Apple removes OpenGL support entirely. May fix some OpenGL driver issues. More information here: https://github.com/libgdx/libgdx/pull/6672 - iOS: Update to MobiVM 2.3.16 - Update to LWJGL 3.3.1 - API Addition: ObjLoader now supports ambientColor, ambientTexture, transparencyTexture, specularTexture and shininessTexture - API Addition: PointSpriteParticleBatch blending is now configurable. - TOOLS Features: Blending mode and sort mode can be changed in Flame particle 3D editor. - API Addition: Polygon methods setVertex, getVertex, getVertexCount, getCentroid. - API Addition: TMX built-in tile property "type" is now supported. - API Addition: Octree structure. - API Addition: Added StringBuilder#toStringAndClear() method. - FirstPersonCameraController keys mapping is now configurable - Fix: GlyphLayout: Several fixes for color markup runs with multi-line or wrapping texts - API change: GlyphLayout#GlyphRun is now one GlyphRun per line. "color" was removed from GlyphRun and is now handled by GlyphLayout. - Gdx Setup Tool: Target Android API 30 and update AGP plugin to 4.1.3 - API Fix: Sound IDs are now properly removed; this prevents changes to music instances with the same ID - API Fix: LWJGL3Net#openURI does now work on macOS & JDK >= 16 - API Fix: Fixed a possible deadlock with AssetManager#dispose() and #clear() - API Change: Enable the AL_DIRECT_CHANNELS_SOFT option for Sounds and AudioDevices as well to fix stereo sound - API Addition: CameraInputController#setInvertedControls(boolean) - API Removal: AnimatedTiledMapTile#frameCount - LWJGL 3 is now the default desktop backend. If you want to port your existing applications, take a look here: https://gist.github.com/crykn/eb37cb4f7a03d006b3a0ecad27292a2d - Brought the official and third-party extensions in gdx-setup up to date. Removed some unmaintained ones and added gdx-websockets & jbump. - API Fix: Escaped characters in XML attributes are now properly un-escaped - Bug Fix: AssetManager backslash conversion removed - fixes use of filenames containing backslashes - gdx-setup now places the assets directory in project root instead of android or core. See advanced settings (UI) or arguments (command line) if you don't want it in root. - API Fix: Resolved issues with LWJGL 3 and borderless fullscreen - API Addition: GeometryUtils,polygons isCCW, ensureClockwise, reverseVertices - API Addition: Added FreeTypeFontGenerator#hasCharGlyph method. - API Fix: Pool discard method now resets object by default. This fixes the known issue about Pool in libGDX 1.10.0. - API Addition: Split GWT reflection cache into two generated classes - API Fix: Fix Box2D memory leak with ropes on GWT - API Fix: Fix NPE in Type#getDeclaredAnnotation - API Addition: Add pause/resume methods to AudioDevice - API Fix: Protection against NullPointerException in World#destroyBody() - API Fix: Prevent repeated mipmap generation in FileTextureArrayData - API Fix: Fix issue with camera reference in CameraGroupStrategy’s default sorter - API Fix: Move vertex array index buffer limit to backends to fix issue with numIndices parameter - API Fix: TexturePacker: Fix wrong Y value when using padding - API Fix: Lwjgl3Net: Add fallback to xdg-open on Linux if Desktop.BROWSE is unavailable - API Addition: Add NWSEResize, NESWResize, AllResize, NotAllowed and None SystemCursors - API Addition: GWTApplication#getJavaHeap and getNativeHeap are now supported - API Addition: Box2D Shape now implements Disposable - API Addition: Added ChainShape#clear method - API Addition: Added Tooltip#setTouchIndependent; see #6758 - API Addition: Emulate Timer#isEmpty on GWT - API Addition: Bits add copy constructor public Bits (Bits bitsToCpy) - API Addition: Added List#drawSelection(). - API Addition: GwtApplicationConfiguration#xrCompatible - API Fix: setSystemCursor() now works on Android - API Fix: getDisplayMode() is now more accurate on Android and GWT. - API Addition: JsonValue#iterator(String) to more easily iterate a child that may not exist. - API Addition: Added ExtendViewport#setScaling, eg for use with Scaling.contain. - API Addition: Added application lifecycle methods to IOSAudio for custom audio implementations. - API Addition: Added getBoundingRectangle() to Polyline - API Addition: ShapeRenderer#check() has now protected visibility - API Addition: Add ability to host GWT module on a different domain than the site, see #6851 - API Addition: Addes Tooltip#setTouchIndependent; see #6758 - API ADDITION: Emulate Timer#isEmpty on GWT - API Addition: OrientedBoundingBox. [1.10.0] - [BREAKING CHANGE] Android armeabi support has been removed. To migrate your projects: remove any dependency with natives-armeabi qualifier from your gradle build file, this apply to gdx-platform, gdx-bullet-platform, gdx-freetype-platform and gdx-box2d-platform. - [BREAKING CHANGE] tvOS libraries have been removed. No migration steps required. - [BREAKING CHANGE] Linux x86 (32-bit) support has been removed. No migration steps required. - [BREAKING CHANGE] Requires Java 7 or above. - [BREAKING CHANGE] API Change: Scaling is now an object instead of an enum. This may change behavior when used with serialization. - [BREAKING CHANGE] Group#clear() and #clearChildren() now unfocus the children. Added clear(boolean) and clearChildren(boolean) for when this isn't wanted. Code that overrides clear()/clearChildren() probably should change to override the (boolean) method. #6423 - [BREAKING CHANGE] Lwjgl3WindowConfiguration#autoIconify is enabled by default. - [KNOWN ISSUE] Pool no longer reset freed objects when pool size is above its retention limit. Pool will discard objects instead. If you want to keep the old behavior, you should override Pool#discard method to reset discarded objects. - Scene2d.ui: Added new ParticleEffectActor to use particle effects on Stage - API addition: iOS: Added HdpiMode option to IOSApplicationConfiguration to allow users to set whether they want to work in logical or raw pixels (default logical). - Fix for #6377 Gdx.net.openURI not working with targetSdk 30 - Api Addition: Added a Pool#discard(T) method. - Architecture support: Linux ARM and AARCH64 support has been added. The gdx-xxx-natives.jar files now contain native libraries of these architectures as well. - API Addition: Desktop Sound now returns number of channels and sample rate. [1.9.14] - [BREAKING CHANGE] iOS: IOSUIViewController has been moved to its own separate class - [BREAKING CHANGE] API Change: G3D AnimationDesc#update now returns -1 (instead of 0) if animation not finished. - [BREAKING CHANGE] InputEventQueue no longer implements InputProcessor, pass InputProcessor to #drain. - [BREAKING CHANGE] HeadlessApplicationConfiguration#renderInterval was changed to #updatesPerSecond - API addition: Added Pixmap#setPixels(ByteBuffer). - API change: ScreenUtils#getFrameBufferPixmap is deprecated in favor to new method Pixmap#createFromFrameBuffer. - API Addition: Added overridable createFiles() methods to backend application classes to allow initializing custom module implementations. - API Addition: Add a Graphics#setForegroundFPS() method. [1.9.13] - [BREAKING CHANGE] Fixed keycode representations for ESCAPE, END, INSERT and F1 to F12. These keys are working on Android now, but if you hardcoded or saved the values you might need to migrate. - [BREAKING CHANGE] TextureAtlas.AtlasRegion and Region splits and pads fields have been removed and moved to name/value pairs, use #findValue("split") and #findValue("pad") instead. - iOS: Update to MobiVM 2.3.12 - GWT: Key codes set with Gdx.input.setCatchKey prevent default browser behaviour - Added Scaling.contain mode: Scales the source to fit the target while keeping the same aspect ratio, but the source is not scaled at all if smaller in both directions. - API Addition: Added hasContents() to Clipboard interface, to reduce clipboard notifications on iOS 14 - TOOLS Features: Blending mode can be changed in Flame particle 3D editor. - Input Keycodes added: CAPS_LOCK, PAUSE (aka Break), PRINT_SCREEN, SCROLL_LOCK, F13 to F24, NUMPAD_DIVIDE, NUMPAD_MULTIPLY, NUMPAD_SUBTRACT, NUMPAD_ADD, NUMPAD_DOT, NUMPAD_COMMA, NUMPAD_ENTER, NUMPAD_EQUALS, NUMPAD_LEFT_PAREN, NUMPAD_RIGHT_PAREN, NUM_LOCK. Following changes might be done depending on platform: Keys.STAR to Keys.NUMPAD_MULTIPLY, Keys.SLASH to Keys.NUMPAD_DIVIDE, Keys.NUM to Keys.NUM_LOCK, Keys.COMMA to Keys.NUMPAD_COMMA, Keys.PERIOD to Keys.NUMPAD_DOT, Keys.COMMA to Keys.NUMPAD_COMMA, Keys.ENTER to Keys.NUMPAD_ENTER, Keys.PLUS to Keys.NUMPAD_ADD, Keys.MINUS to Keys.NUMPAD_SUBTRACT - Added a QuadFloatTree class. - Desktop: Cubemap Seamless feature is now enabled by default when supported, can be changed via backend specific methods, see supportsCubeMapSeamless and enableCubeMapSeamless in both LwjglGraphics and Lwjgl3Graphics. - API Addition: TextureAtlas reads arbitrary name/value pairs for each region. See #6316. - TexturePacker writes using a new format when legacyOutput is false (default is true). TextureAtlas can read both old and new formats. See #6316. [1.9.12] - [BREAKING CHANGE] iOS: Changed how Retina/hdpi handled on iOS. See #3709. - [BREAKING CHANGE] API Change: InputProcessor scrolled method now receives scroll amount for X and Y. Changed type to float to support devices which report fractional scroll amounts. Updated InputEvent in scene2d accordingly: added scrollAmountX, scrollAmountY attributes and corresponding setters and getters. See #6154. - [BREAKING CHANGE] API Change: Vector2 angleRad(Vector2) now correctly returns counter-clockwise angles. See #5428 - [BREAKING CHANGE] Android: getDeltaTime() now returns the raw delta time instead of a smoothed one. See #6228. - Fixed vertices returned by Decal.getVertices() not being updated - Fixes Issue #5048. The function Intersector.overlapConvexPolygons now should return the right minimum translation vector values. - Update to MobiVM 2.3.11 - API Change: Removed Pool constructor with preFill parameter in favor of using Pool#fill() method. See #6117 - API Addition: Slider can now be configured to only trigger on certain mouse button clicks (Slider#setButton(int)). - Fixed GlyphLayout not laying out correctly with color markup. - Fixed TileDrawable not applying its scale correctly. - API Addition: Added epsilon methods to maps with float values. - API Addition: Added an insertRange method to array collections. - Fixed GestureDetector maxFlingDelay. - API Change: Changed default GestureDetector maxFlingDelay to Integer.MAX_VALUE (didn't work before, this matches that). - Gdx.files.external on Android now uses app external storage - see wiki article File handling for more information - Improved text, cursor and selection rendering in TextArea. - API Addition: Added setProgrammaticChangeEvents, updateVisualValue, round methods to ProgressBar/Slider. - iOS: Keyboard events working on RoboVM on iOS 13.5 and up, uses same API as on other platforms - API Addition: Added AndroidLiveWallpaper.notifyColorsChanged() to communicate visually significant colors back to the wallpaper engine. - API Change: AssetManager invokes the loaded callback when an asset is unloaded from the load queue if the asset is already loaded. - GWT: changed audio backend to WebAudio API. Now working on mobiles, pitch implemented. Configuration change: preferFlash removed. When updating existing projects, you can remove the soundmanager js files from your webapp folder and the references to it from index.html - GWT: added possibility to lazy load assets via AssetManager instead of preload them before game start. See GWT specifics wiki article for more information. - GWT: New configuration setting usePhysicalPixels to use native resolution on mobile / Retina / HDPI screens. When using this option, make sure to update your code in index.html and HTMLLauncher from setup template. - GWT: GwtApplicationConfiguration and GWT backend now support an application to be resizable or fixed size. You can remove your own resizing code from your HTMLLaunchers. - GWT: Assets in distribute build are renamed with md5 hash suffix to bypass browser cache on changes - GWT: Fixed GwtFileHandle that was only returning text assets when listing a directory, now returns all children - API Addition: Pixmap.downloadFromUrl() downloads an image from http(s) URLs and passes it back as a Pixmap on all platforms - Added support for Linux ARM builds. - 32-bit: ARMv7/armhf - 64-bit: ARMv8/AArch64 - API Change: Removed arm abi from SharedLibraryLoader - API Addition: Added a Lwjgl3ApplicationConfiguration#foregroundFPS option. - API Change: Utility classes are now final and have a private constructor to prevent instantiation. - API Change: ScrollPane now supports all combinations of scrollBarsOnTop and fadeScrollBars. - API Addition: Added new methods with a "deg" suffix in the method's name for all Vector2 degrees-based methods and deprecated the old ones. - API Addition: Added Slider#setVisualPercent. - API Change: Enabling fullscreen mode on the lwjgl3 backend now automatically sets the vsync setting again. - API Addition: Added put(key, value, defaultValue) for maps with primitive keys, so the old value can be returned. - API Addition: Added ObjectLongMap. - Added Intersector#intersectRayOrientedBoundsFast to detect if a ray intersects an oriented bounding box, see https://github.com/libgdx/libgdx/pull/6139 - API Addition: Added Table#clip() and Container#clip() methods. - API Addition: Added getBackgroundDrawable() to Button. - API Addition: Added imageCheckedDown and getImageDrawable() to ImageButton and ImageTextButton. - API Addition: Added focusedFontColor, checkedFocusedFontColor, and getFontColor() to TextButton and ImageTextButton. - API Addition: Added wrapReverse setting to HorizontalGroup. - API Addition: Added Slider style drawables for over and down: background, knobBefore, and knobAfter. - Fixed LwjglFrame not hiding the canvas in some situations. - API Change: Table#round uses ceil/floor and is applied during layout, rather than afterward. - Fixed blurry NinePatch rendering when using a single center region. - API Change: Upon changing the window size with the lwjgl3 backend, the window is centered on the monitor. - Fixed DepthShaderProvider no longer creates one DepthShader per bones count. Now it creates only one skinned variant and one non-skinned variant based on DepthShader/Config numBones. - API Addition: Added Intersector#intersectPlanes to calculate the point intersected by three planes, see https://github.com/libgdx/libgdx/pull/6217 - API Addition: Added alternative Android Audio implementation for performant sound. See https://github.com/libgdx/libgdx/pull/6243. - API Addition: Expose SpriteBatch and PolygonSpriteBatch setupMatrices() as protected. - API Addition: New parameter OnscreenKeyboardType for Input.setOnscreenKeyboardVisible and Input.getTextInput [1.9.11] - Update to MobiVM 2.3.8 - Update to LWJGL 3.2.3 - Fixed AndroidInput crashes due to missing array resize (pressure array). - API Change: Ray#set methods and Ray#mul(Matrix4) normalize direction vector. Use public field to set and avoid nor() - API Change: New internal implementation of all Map and Set classes (except ArrayMap) to avoid OutOfMemoryErrors when too many keys collide. This also helps resistance against malicious users who can choose problematic names. - API Addition: OrderedMap#alter(Object,Object) and OrderedMap#alterIndex(int,Object) allow swapping out a key in-place without changing its value; OrderedSet also has this. - API Addition: Json can now read/write: ObjectIntMap, ObjectFloatMap, IntMap, LongMap. - API Addition: Added @Null annotation for IDE null analysis. All parameters and return values should be considered non-null unless annotated (or javadoc'ed if not yet annotated). - API Addition: Added ParticleEmitter#preAllocateParticles() and ParticleEffect#preAllocateParticles() to avoid particle allocations during updates. - Fixed changing looping state of already playing sounds on Android by first pausing the sound before setting the looping state (see #5822). - API Change: scene2d: Table#getRow now returns -1 when over the table but not over a row (used to return the last row). - API Change: scene2d: Tree#addToTree and #removeFromTree now have an "int actorIndex" parameter. - API Addition: scene2d: Convenience method Actions#targeting(Actor, Action) to set an action's target. - API Change: scene2d: In TextField, only revert the text if the change event was cancelled. This allows the text to be manipulated in the change listener. - API Change: scene2d: Tree.Node#removeAll renamed to clearChildren. - API Addition: scene2d: Added SelectBox#setSelectedPrefWidth to make the pref width based on the selected item and SelectBoxStyle#overFontColor. - API Change: DefaultTextureBinder WEIGHTED strategy replaced by LRU strategy. - API Change: ShaderProgram begin and end methods are deprecated in favor to bind method. - API Addition: Added a OpenALAudio#getSourceId(long) method. - API Addition: Added a ShaderProgram#getHandle() method. - API Change: Replaced deprecated android support libraries with androidx. AndroidFragmentApplication is only affected. - API Addition: Created interfaces AndroidAudio and AndroidInput and added AndroidApplication#createAudio and AndroidApplication#createInput to allow initializing custom module implementations. - Allows up to 64k (65536) vertices in a Mesh instead of 32k before. Indices can use unsigned short range, so index above 32767 should be converted to int using bitwise mask, eg. int unsigneShortIndex = (shortIndex & 0xFFFF). - API Change: DragAndDrop only removes actors that were not already in the stage. This is to better support using a source actor as the drag actor, see #5675 and #5403. - API Change: Changed TiledMapTileLayer#tileWidth & #tileHeight from float to int - API Addition: convenient Matrix4 rotate methods: rotateTowardDirection and rotateTowardTarget - API Addition: Convenience method Actions#targeting(Actor, Action) to set an action's target. - API Change: Correction of TextField#ENTER_ANDROID renamed to NEWLINE and TextField#ENTER_DESKTOP renamed to CARRIAGE_RETURN. - API Change: Changed the visibility of TextField#BULLET, TextField#DELETE, TextField#TAB and TextField#BACKSPACE to protected. - API Addition: TextField and TextArea are providing the protected method TextField#checkFocusTraverse(char) to handle the focus traversal. - API Addition: UIUtils provides the constants UIUtils#isAndroid and UIUtils#isIos now. - Fixed: The behaving of TextFields and TextAreas new line and focus traversal works like intended on all platforms now. - API Change: Changed Base64Coder#encodeString() to use UTF-8 instead of the platform default encoding. See #6061 - Fixed: SphereShapeBuilder poles are now merged which removes lighting artifacts, see #6068 for more information. - API Change: Matrix3#setToRotation(Vector3, float float) now rotates counter-clockwise about the axis provided. This also changes Matrix3:setToRotation(Vector3, float) and the 3d particles will rotate counter-clockwise as well. - API Change: TexturePacker uses a dash when naming atlas page image files if the name ends with a digit or a digit + 'x'. - API Addition: Added Skin#setScale to control the size of drawables from the skin. This enables scaling a UI and using different sized images to match, without affecting layout. - API Change: Moved adding touch focus from Actor#notify to InputListener#handle (see #6082). Code that overrides InputListener#handle or otherwise handles InputEvent.Type.touchDown events must now call Stage#addTouchFocus to get touchDragged and touchUp events. - API Addition: Added AsynchronousAssetLoader#unloadAsync to fix memory leaks when an asset is unloaded during loading. - Fixed Label text wrapping when it shouldn't (#6098). - Fixed ShapeRenderer not being able to render alpha 0xff (was max 0xfe). - API Change: glGetActiveUniform and glGetActiveAttrib parameter changed from Buffer to IntBuffer. [1.9.10] - API Addition: Allow target display for maximization LWJGL3 backend - API Addition: Accelerometer support on GWT - API Change: Set default behaviour of iOS audio to allow use of iPod - API Change: IOSDevice is no longer an enum to allow users to add their own new devices when LibGDX is not up to date - API Addition: Add statusBarVisible configuration to IOSApplicationConfiguration - Update GWT Backend to GWT 2.8.2 - Update Android backend to build against API 28 (Android 9.0) - API Addition: Input.isButtonJustPressed - Update to LWJGL 2 backend to 2.9.3 - Update to MobiVM 2.3.6 release - Update to LWJGL 3.2.1 - API Addition: Input allows getting the maximum number of pointers supported by the backend - API Addition: Configuration option added to allow setting a max number of threads to use for net requests - API Change: NetJavaImpl now uses a cached thread pool to allow concurrent requests (by default, the thread pool is unbounded - use maxNetThreads in backend configurations to set a limit - set to 1 for previous behavior) - API Addition: New MathUtils norm and map methods - API Change: Pixmap blending was incorrect. Generated fonts may change for the better, but may require adjusting font settings. - API Change: Particle effects obtained from a ParticleEffectPool are now automatically started - Removed OSX 32-bit support - API Change: By default LWJGL2 backend no longer does pause/resume when becoming background/foreground window. New app config setting was added to enable the old behavior. - API Change: By default LWJGL2 backend now does pause/resume when window is minimized/restored. New app config setting was added to disable this behavior. - LWJGL3: Fixed window creation ignoring refresh rate of fullscreen mode. - TmxMapLoader and AtlasTmxMapLoader refactoring: Shared functionality was moved to BaseTmxMapLoader, duplicate code was removed. - AtlasTmxMapLoader supports group layers now (a positive side effect of the BaseTmxMapLoader refactoring). - API Change: TmxMapLoader and AtlasTmxMapLoader: load/loadAsync methods work exactly as before, but many methods of these classes had to change. This makes it possible implement new Tiled features. - API Addition: TextField#drawMessageText. - Fixed TextField rendering text outside the widget at small sizes. - API Addition: Group#getChild(int) - API Addition: notEmpty() for collections. - API Change: scene2d.ui Tree methods renamed for node set/getObject to set/getValue. - API Change: scene2d.ui Tree and Tree.Node require generics for the type of node, values, and actors. - API Change: For Selection in scene2d.utils "toggle" is now respected when !required and selected.size == 1. - API Addition: new InstanceBufferObject and InstanceBufferObjectSubData classes to enable instanced rendering. - API Addition: Support for InstancedRendering via Mesh - API Change: Cell#setLayout renamed to setTable. - API Addition: Added Collections#allocateIterators. When true, iterators are allocated. When false (default), iterators cannot be used nested. - API Addition: Added Group#removeActorAt(int,boolean) to avoid looking up the actor index. Subclasses intending to take action when an actor is removed may need to override this new method. - API Change: If Group#addActorAfter is called with an afterActor not in the group, the actor is added as the last child (not the first). [1.9.9] - API Addition: Add support for stripping whitespace in PixmapPacker - API Addition: Add support for 9 patch packing in PixmapPacker - API Addition: Pressure support for ios/android. https://github.com/libgdx/libgdx/pull/5270 - Update to Lwjgl 3.2.0 - Update android level we build against to 7.1 (API 25) - API Change: gdx-tools no longer bundles dependencies to be compatible with java 9 - Skin JSON files can now use the simple names of classes, i.e. "BitmapFont" rather than "com.badlogic.gdx.graphics.g2d.BitmapFont". Custom classes can be added by overriding Skin.getJsonLoader() and calling json.setClassTag(). - Skin supports cascading styles in JSON. Use the "parent" property to tag another style by name to use its values as defaults. See https://github.com/libgdx/libgdx/blob/master/tests/gdx-tests-android/assets/data/uiskin.json for example. - SkinLoader can be used on subclasses of Skin by overriding generateSkin(). - API addition: Tree indentation can be customized. - Fixed GlyphLayout not respecting BitmapFontData#down. - API Addition: Added faceIndex paramter to #FreeTypeFontGenerator(FileHandle, int). - API Change: BitmapFont#getSpaceWidth changed to BitmapFont#getSpaceXadvance. - Many GlyphLayout fixes. - API Addition: Added FileHandle#map(), can be used to memory map a file - API Change: BitmapFontData#getGlyphs changed for better glyph layout. See https://github.com/libgdx/libgdx/commit/9a7dfdff3c6374a5ebd2f33a819982aceb287dfa - API Change: Actor#hit is now responsible for returning null if invisible. #5264 - API Addition: Added [Collection]#isEmpty() method to all 22 custom LibGDX-collections (e.g. Array, ObjectMap, ObjectSet, Queue, ...) - API Addition: StringBuilder#clear() - API Addition: Color#WHITE_FLOAT_BITS - Table layout fixed when expand is used and the layout width is less than the table's min width. - InputMultiplexer#setProcessors(Array) now copies the items instead of using the specified array instance. - API Change: A wrapped HorizontalGroup or VerticalGroup will now size children down to their min size if the group is smaller than their pref size. - LWJGL3: useVSync() is now a per-window setting. Any additional windows should disable vsync to avoid frames dropping to (refresh rate / # of windows). - Batch and sprite implementations and SpriteCache store Color separately from the float packed color, since converting to/from float is lossy. - API Change: NumberUtils floatToIntColor expands the alpha from 0-254 to 0-255, so 255 doesn't become 254 from conversion from int to float to int. - API Change: Batch and Decal setColor(float) renamed to setPackedColor for differentiation, since the conversion from float to Color is lossy. - API Change: PolygonSprite getVertexColor renamed to getPackedColor to match other classes. - API Change: FreeTypeFontGenerator only generates a missing glyph if \0 is in the characters. - API Change: DragScrollListener no longer requires the touch/mouse cursor to be directly above/below the scroll pane. - API Change: List#toString(Object) changed from protected to public. Subclasses overriding this need to change to public. - API Change: List now handles more key presses. - API Change: TexturePacker ImageProcessor#addImage(File, String) now returns the Rect. [1.9.8] - Add iPhoneX images - Fix MacOS issue with GL_ARB_texture_float extension check - Fix AtlasTmxMapLoader tileset tile id offset - Bullet: updated to 2.87, see: http://bulletphysics.org/wordpress/?p=485 - API Addition: Possibility to specify TexturePacker settings for resampling when scaling. - API Addition: Support for customizing render buffer attachments in GLFrameBuffers - API Change: Revert to constructors for GLFrameBuffers for easier customization [1.9.7] - Update to MobiVM(RoboVM) 2.3.3 - Add iOS 11 support - Update to Lwjgl 3.1.3 - Update to MOE 1.4.0 - API Change: GLFrameBuffer has been refactored https://github.com/libgdx/libgdx/pull/4882. Create standard FrameBuffers with static methods. Customized FBOS with FrameBufferBuilder - API addition: Tiled group layer support - Fix Tiled properties, offset parsing for image layers - API addition: Added utility methods for Vector equals with epsilon - Fix Animation backing array type - Fix Mesh copying with 0 indices - Fix restoration of pooled particle effects scale - Fix loss of controller listeners on reconnect - Added basic kotlin project generation support in the setup tool - API addition: Allow APK expansion to be used in fragments and activities - API addition: Added color properties support from tiled maps - API Change: Added rotation vector sensor support on Android - API Change: GLProfiler refactored for OOP and lwjgl3 multi windows - LWJGL3: The creation of additional windows via Lwjgl3Application.newWindow() is now deferred, with postRunnable(), until all existing windows have been updated. This fixes a potential native crash with NVidia GL drivers on Windows, presumably caused by a GL context conflict. - API addition: Lwjgl3WindowListener.created() is called after a new window has been created. It's unsafe to call Lwjgl3Window functions in between Lwjgl3Application.newWindow() and this callback. - Updated LWJGL3 backend to 3.1.3. - Lwjgl3Graphics.setUndecorated() and Lwjgl3Graphics.setResizable() now delegate their work to the respective GLFW functions. - API addition: ProgressBar.isVertical() - returns whether a progress bar is vertical or horizontal. - API Change: SplitPane now by default does not allow the split amount to shrink children below their minimum sizes (cropping them). This behavior can be reverted by overriding clampSplitAmount or wrapping the children in Containers set to minSize(0) and fill(). SplitPane also now correctly includes the handle min size in its own min size calculations. - API Change: SplitPane.getSplit() renamed to SplitPane.getSplitAmount() to match other getter and setter names. - Improved internal Timer synchronization. - API Change: List#drawItem, added float width parameter. - API Addition: Make it possible to disable sound on the GWT-Backend with disableSound=true. - API Change: ScrollPane setWidget deprecated in favor of setActor to match other APIs. - API Change: removed JGLFW backend - Fixed mixed up use of TexturePacker.Settings.stripWhitespaceX|Y. - Added joystick POV support to LWJGL3 controller backend. - Added support for 2d particles sprite animation. - API Change: ParticleEmitter getSprite, setSprite, getImagePath, setImagePath are now getSprites, setSprites, getImagePaths, setImagePaths. - Added support for 2d particles independant scale X and Y. - API Change: ParticleEmitter getScale, matchSize are now getScaleX/getScaleY, matchSizeX/matchSizeY. Added scaleSize(float scaleX, float scaleY) - API Change: Added iconDropped() callback to AndroidWallpaperListener. [1.9.6] - Fix performance regression in LWJGL3 backend, use java.nio instead of BufferUtils. Those are intrinsics and quite a bit faster than BufferUtils on HotSpot. - Updated to latest Sound Manager 2 - Added mappings for Xbox 360 controller for Linux - Separated error log for vertex/fragment shaders for easier debugging - Minimum Android API level is now level 9 (Android 2.3) - API addition: Configurable TexturePacker bleed iterations - Updated IOS Multi-OS Engine backend to 1.3.6 - API Change: Pixmap.setBlending, Pixmap.setFilter are now instance methods - VertexAttribute expert constructors exposed. Short types can now be used for attributes. [1.9.5] - Fix NPE swallowing "video driver unsupported" error on LWJGL 2 backend. - Allow window icons to be set in Lwjgl3ApplicationConfiguration or Lwjgl3WindowConfiguration. - Allow window icon and title to be changed in Lwjgl3Window - API Addition: ApplicationLogger interface, allowing easier access to custom logging - DefaultRenderableSorter accounts for center of Renderable mesh, see https://github.com/libgdx/libgdx/pull/4319 - Bullet: added FilterableVehicleRaycaster, see https://github.com/libgdx/libgdx/pull/4361 - Bullet: updated to 2.85, see: http://bulletphysics.org/wordpress/?p=456 - Updated iOS native build scripts to iOS 10.1 and TVOS 10.0 - API Addition: BitmapFont#blankLineScale. - Fixed rounding of Drawables in ProgressBar. Allow rounding to be disabled with setRound(). - Updated LWJGL3 backend to LWJGL 3.1.0, see https://blog.lwjgl.org/lwjgl-3-1-0-released/ - LWJGL3 backend now supports non-continuous rendering, see https://github.com/libgdx/libgdx/pull/3772 - API Change: Lwjgl3WindowListener.refreshRequested() is called when the windowing system (GLFW) reports contents of a window are dirty and need to be redrawn. - API Change: Lwjgl3WindowListener.maximized() is called when a window enters or exits a maximized state. - API Change: Lwjgl3WindowListener.deiconified() removed, combined with .iconified(). - API Change: Lwjgl3Window.deiconify() renamed to .restore() since it can also be used to de-maximize a window. - Lwjgl3Window now has a maximize() method, and windows can be started maximized using the window or app configuration's setMaximized() method. - NinePatch can now be drawn rotated or scaled. - NinepatchDrawable is now a TransformDrawable. - API Change: Group add* methods no longer remove and re-add the actor if it is already in the group, instead they do nothing. - API Change: g2d.Animation is now generic so it can support Drawables, PolygonRegions, NinePatches, etc. To fix existing code, specify the TextureRegion type in animation declarations (and instantiations in Java 6), i.e. Animation<TextureRegion> myAnimation = new Animation<TextureRegion>(...); - TiledDrawable throws unsupported operation if trying to draw rotated/scaled. #4005 - API Change: DragAndDrop now puts default position of drag actor at pointer location. The original default offset from the pointer was (14, -20). - Added ShaderProgramLoader for AssetManager. - BoundingBox#isValid now returns also true when min==max, see: https://github.com/libgdx/libgdx/pull/4460 [1.9.4] - Moved snapping from ProgressBar to Slider to prevent snapping when setting the value programmatically. - Bullet: added btSoftBody#getLinkCount() and btSoftBody#getLink(int), see https://github.com/libgdx/libgdx/issues/4152 - API Change: Wrapping for scene2d's HorizontalGroup and VerticalGroup. - Fix hiero problem with certain unicode characters. See https://github.com/libgdx/libgdx/issues/4202 - Switched to RoboVM fork 2.2.0, fixes incompatibility with Android Gradle plugin and iOS 9.3.4 [1.9.3] - Switched to MobiDevelop's RoboVM fork (http://robovm.mobidevelop.com) - Addition of Intel Multi-OS Engine backend for deploying to iOS - Updated iOS native build scripts to iOS 9.3 and TVOS 9.2 - API Addition: GestureDetector#pinchStop() called when no longer pinching - API Addition: Gdx.graphics.setUndecorated/setResizable API added to Graphics https://github.com/libgdx/libgdx/pull/3847 - API Addition: Gdx.graphics.getGLVersion(), grab the GL version and implementation type. https://github.com/libgdx/libgdx/pull/3788 - API Change: Lwjgl3WindowListener -> filesDropped(String[] files) adds drag'n drop support for the lwjgl3 backend - Added isComplete() to ParticleEffect to make it easier to know when all the emitters are done, behaves the same as in the 2D API. - API Change: renamed Lwjgl3WindowListener.windowIsClosing() to closeRequested() to better communicate its intent. - Add IndexData.updateIndices method to increase performance when used with IndexBufferObjectSubData. - Added FlushablePool - Added ShapeCache see https://github.com/libgdx/libgdx/pull/3953 - API Change: moved shape builder logic out of MeshBuilder, see: https://github.com/libgdx/libgdx/pull/3996 - API Change: changed copy constructor OrderedMap(ObjectMap) to OrderedMap(OrderedMap) - API Change: Table reset now calls clearChildren, not clear. - Fixed crashes in AndroidMusic.java when isPlaying is called. Errors are now logged only rather than crashing the app. - Added emulation of ScreenUtils for GWT - Improved performance of glReadPixels() on GWT. New method is 20-30 times faster - Fixed crash on Mac when using LWJGL2, custom cursors and embedding the game in an AWT window - Fixed getDisplayModes(Monitor monitor) returning wrong data on LWJGL2 backend - Fixed Gdx.input.getCurrentEventTime() not being set on LWJGL3, fixes GestureDetector and flick scroll not working - Fixed not being able to select non-latin characters in TextFields - Bullet: added CustomActionInterface, see https://github.com/libgdx/libgdx/pull/4025 - Add window size limits option to LWJGL3 app and window configurations - Add handling of tag "<objectgroup>" within tags "<tile>" in TmxMap loaders. [1.9.2] - Added TextureArray wrapper see https://github.com/libgdx/libgdx/pull/3807 - Fixed bug in AndroidGL20.cpp which cast a pointer to a 32-bit int. Crash on 64-bit ARM, but only for a specific code path and address... - Fixed multiple controllers registering on same index with LWJGL3, see https://github.com/libgdx/libgdx/issues/3774 - Fixed the FreeTypeFontGenerator texture bleeding, see https://github.com/libgdx/libgdx/issues/3521 [1.9.1] - API Change: Override GwtApplication#createApplicationListener() to create your ApplicationListener on GWT, overriding GwtApplication#getApplicationListener() isn't needed anymore, see https://github.com/libgdx/libgdx/issues/3628 - Fixed ARM64 and x86_64 binaries for Android [1.9.0] - API Change: Lwjgl3ApplicationConfiguration#setBackbufferConfig -> setBackBufferConfig - Fixed HexagonalTiledMapRenderer, see https://github.com/libgdx/libgdx/pull/3654 - Added support for locking the screen orientation in GWT, see https://github.com/libgdx/libgdx/pull/3633 - Added Gdx-Kiwi and gdx-lml to extensions, see https://github.com/libgdx/libgdx/pull/3597 - Added Gyroscope support in Input, implemented for Android, see https://github.com/libgdx/libgdx/pull/3594 - Fixed touch mapping on iOS, see https://github.com/libgdx/libgdx/pull/3590 - Added orientation to Box2D Transform class, see https://github.com/libgdx/libgdx/pull/3308 - Added system cursors to GWT, fix 'Ibeam' system cursor not working on LWJGL3. - Added experimental AndroidApplicationConfiguration#useGL30 and IOSApplicationConfiguration#useGL30 for testing OpenGL ES 3.0 support on mobile devices, do not use in production. - Fix broken kerning for FreeType fonts, see https://github.com/libgdx/libgdx/pull/3756 - Added ARM64 and x86_64 binaries for Android - API Addition: FreeTypeFontParameter has an additional field for tweaking hinting, see https://github.com/libgdx/libgdx/pull/3757 [1.8.0] - API Change: Rewrote FreeType shadow rendering (much better). - Added spaceX/Y to FreeType fonts. - Higher quality FreeType font rendering. - Hiero updated to v5, now with FreeType support and other new features! - GlyphLayout now allocates much, much less memory when processing long text that wraps. - Added LWJGL 3 backend, see https://github.com/libgdx/libgdx/issues/3673 for more info. - Added Graphics#getBackBufferWidth and Graphics#getBackBufferHeight for HDPI handling - API Change: Added HdpiUtils. Instead of calling GL20#glViewport and GL20#glScissor yourself please use HdpiUtils instead. It will ensure that you handle HDPI monitors correctly when using those OpenGL functions. On HDPI monitors, the size reported by Gdx.graphics getWidth/getHeight is in logical coordinates as dictated by the operating system, usually half the HDPI resolution. The OpenGL drawing surface works in backbuffer coordinates at the full HDPI resolution. If you pass logical coordinates to glViewport and glScissor, you only affect a quarter of the real backbuffer size. Use HdpiUtils instead, it will do the right thing, while letting you continue to work in logical (aka returned by Gdx.graphics.getWidth/getHeight) coordinates. - API Change: Graphis#getDesktopDisplayMode() has been renamed to Graphics#getDisplayMode() and returns the current display mode of the monitor the window is shown on (primary monitor on all backends except LWJGL3, which supports real multi-monitor setups). - API Change: Graphics#getDisplayModes() return the display modes of the monitor the monitor the window is shown on (primary monitor on all backends except LWJGL3 which supports real multi-monitor setups). - API Change: Graphics#setDisplayMode(DisplayMode) has been renamed to Graphics#setFullscreenMode(). If the window is in windowed mode, it will be switched to fullscreen mode on the monitor from which the DisplayMode stems from. - API Change: Graphics#setDisplayMode(int, int, boolean) has been renamed to Graphics#setWindowedMode(int, int). This will NOT allow you to switch to fullscreen anymore, use Graphics#setFullscreenMode() instead. If the window is in fullscreen mode, it will be switched to windowed mode on the monitor the window was in fullscreen mode on. - API Addition: Graphics#Monitor, represents a monitor connected to the machine the app is running on. A monitor is defined by a name and it's position relative to other connected monitors. All backends except the LWJGL3 backend will report only the primary monitor - API Addition: Graphics#getPrimaryMonitor() returns the primary monitor you usually want to work with. - API Addition: Graphics#getMonitor() returns the monitor your app's window is shown on, which may not be the primary monitor in >= 2 monitor systems. All backends except the LWJGL3 backend will report only the primary monitor. - API Addition: Graphics#getMonitors() returns all monitors connected to the system. All backends except the LWJGL3 backend will only report the primary monitor. - API Addition: Graphics#getDisplayMode(Monitor) returns the display mode of the monitor the app's window is shown on. All backends except the LWJGL3 backend will report the primary monitor display mode instead of the actual monitor's display mode. Not a problem as all other backends run on systems with only a single monitor so far (primary monitor). - Added option to include credentials on cross-origin http requests (used only for GWT backend). - Added option to specify crossorigin attribute when loading images with AssetDownloader (GWT), see #3216. - API Change: removed Sound#setPriority, this was only implemented for the Android backend. However, Android itself never honored priority settings. - API Change: cursor API has been cleaned up. To create a custom cursor, call Graphics#newCursor(), to set the custom cursor call Graphics#setCursor(), to set a system cursor call Graphics#setSystemCursor(). The Cursor#setSystemCursor method has been removed as that was not the right place. Note that cursors only work on the LWJGL, LWJGL3 and GWT backends. Note that system cursors only fully work on LWJGL3 as the other two backends lack a means to set a specific system cursor. These backends fall back to displaying an arrow cursor when setting any system cursor. - API Addition: Added Lwjgl3WindowListener, allows you to hook into per-window iconficiation, focus and close events. Also allows you to prevent closing the window when a close event arrives. [1.7.2] - Added AndroidAudio#newMusic(FileDescriptor) to allow loading music from a file descriptor, see #2970 - Added GLOnlyTextureData, which is now the default for FrameBuffer and FrameBufferCubemap, see #3539 - Added rotationChanged() for Actor class, called when rotation changes, see https://github.com/libgdx/libgdx/pull/3563 - Fixed crash on MacOS when enumerating connected gamepads. - ParticleEmitter no longer says it's complete when it's set to continuous, see #3516 - Improved JSON parsing and object mapping error messages. - Updated FreeType from version 2.5.5 to 2.6.2. - Fixed corrupt FreeType rendering for some font sizes. - API Change: FreeTypeFontParameter has new fields for rendering borders and shadows. - FreeTypeFontParameter can render much better fonts at small sizes using gamma settings. - BitmapFont can now render missing (tofu) glyph for glyphs not in the font. - FreeTypeFontGenerator depreacted methods removed. - Fixed BitmapFont color tags changing glyph spacing versus not using color tags. BitmapFont#getGlyphs has a new paramter. See #3455. - Skin's TintedDrawable now works with TiledDrawable. #3627 - Updated jnigen to Java Parser 2.3.0 (http://javaparser.github.io/javaparser/). - FreeType fonts no longer look terrible at small size. This is a big deal! - Updated to RoboVM 1.12.0, includes tvOS support! [1.7.1] - Fixes AtlasTmxMapLoader region name loading to tileset name instead of filename - Changes TiledMapPacker output, region names are tileset names, adjusts gid, defaults to one atlas per map - API Change: members of Renderable and MeshPart are changed, see https://github.com/libgdx/libgdx/pull/3483 - Added Vector#setToRandomDirection(), see #3222 - Updated to stb_image v2.08 - Added Node#copy(), used when creating a ModelInstance from a Model to allow using custom nodes - Add ModelCache, see https://github.com/libgdx/libgdx/wiki/ModelCache - Updated bullet to v2.83.6 - Updated to RoboVM 1.9, for free life-time license read http://www.badlogicgames.com/wordpress/?p=3762 [1.7.0] - Gdx.input.setCursorImage removed, replaced with Gdx.graphics.setCursor and Gdx.graphics.newCursor see https://github.com/libgdx/libgdx/pull/2841/ - Fixed an issue with UTF8 decoding in GWT emulation of InputStreamReader - Updated to RoboVM 1.8 for iOS 9 support. [1.6.5] - Objects from animated tiles in TMX maps are now supported. - Made possible to use any actor for tooltips. - Improved cross-platform reflection api for annotations. - NinePatch#scale now also scales middle patch size. - GLFrameBuffer is now abstract, renamed setupTexture to createColorTexture, added disposeColorTexture - Added LwjglApplicationConfiguration#gles30Context*Version, see https://github.com/libgdx/libgdx/pull/2941 - Added OpenGL error checking to GLProfiler, see https://github.com/libgdx/libgdx/pull/2889 - Updated to RoboVM 1.6 [1.6.4] - TextField cursor and selection size changed. https://github.com/libgdx/libgdx/commit/2a830dea348948d2a37bd8f6338af2023fec9b09 - FreeTypeFontGenerator setting to improve shadows and borders. - ScrollPane scrolls smoothly when the scrolled area is much larger than the scrollbars. - TexturePacker sorts page regions by name. - GlyphLayout text wrapping changed to not trim whitespace. https://github.com/libgdx/libgdx/commit/ee42693da067da7c5ddd747f051c1423d262cb96 - Fixed BitmapFont computing space width incorrectly when padding is used and no space glyph is in the font. - Fixed TextArea cursor and selection drawing positions. - Fixed ActorGestureListener pan and zoom when the actor is rotated or scaled. - Fixed TextField for non-pixel display. - Allow ellipsis string to be set on Label. - AssetManager gets hook for handling loading failure. - TextField now fires a ChangeEvent when the text change. Can be cancelled too! - Added tooltips to scene2d.ui. - Updated to RoboVM 1.5 [1.6.3] - Updated to RoboVM 1.4 [1.6.2] - API Change: TiledMapImageLayer now uses floats instead of ints for positioning - API Change: Added GLFrameBuffer and FrameBufferCubemap: Framebuffer now extends GLFramebuffer, see #2933 [1.6.1] - Added optional hostname argument to Net.newServerSocket method to allow specific ip bindings for server applications made with gdx. - Changed the way iOS native libs are handled. Removed updateRoboVMXML and copyNatives task from ios/build.gradle. Instead natives are now packaged in jars, within the META-INF/robovm/ios folder. Additionally, a robovm.xml file is stored there that gets merged with the project's robovm.xml file by RoboVM. [1.6.0] - API Change: GlyphLayout xAdvances now have an additional entry at the beginning. This was required to implement tighter text bounds. #3034 - API Change: Label#getTextBounds changed to getGlyphLayout. This exposes all the runs, not just the width and height. - In the 2D ParticleEditor, all chart points can be dragged at once by holding ctrl. They can be dragged proportionally by holding ctrl-shift. - Added Merge button to the 2D ParticleEditor, for merging a loaded particle effect file with the currently open particle effect. - Added ability to retrieve method annotations to reflection api - Added PixmapPacker.updateTextureRegions() method. - Added ability to pack "anonymous" pixmaps into PixmapPacker, which will appear in the generated texture but not a generated or updated TextureAtlas - Added PixmapPacker.packDirectToTexture() methods. - API Change: PixmapPacker.generateTextureAtlas(...) now returns an atlas which can be updated with subsequent calls to PixmapPacker.updateTextureAtlas(...) - API Change: FreeTypeFontGenerator.generateFont(...) now works with a user-provided PixmapPacker. - Added DirectionalLightsAttribute, PointLightsAttribute and SpotLightsAttribute, removed Environment#directionalLights/pointLights/spotLights, added Environment#remove, lights are now just like any other attribute. See also https://github.com/libgdx/libgdx/wiki/Material-and-environment#lights - API Change: BitmapFont metrics now respect padding. #3074 - Update bullet wrapper to v2.83 - Added AnimatedTiledMapTile.getFrameTiles() method [1.5.6] - API Change: Refactored Window. https://github.com/libgdx/libgdx/commit/7d372b3c67d4fcfe4e82546b0ad6891d14d03242 - Added VertexBufferObjectWithVAO, see https://github.com/libgdx/libgdx/pull/2527 - API Change: Removed Mesh.create(...), use MeshBuilder instead - API Change: BitmapFontData, BitmapFont, and BitmapFontCache have been refactored. http://www.badlogicgames.com/wordpress/?p=3658 - FreeTypeFontGenerator can now render glyphs on the fly. - Attribute now implements Comparable, custom attributes might need to be updated, see: https://github.com/libgdx/libgdx/wiki/Material-and-environment#custom-attributes - API Change: Removed (previously deprecated) GLTexture#createTextureData/createGLHandle, Ray#getEndPoint(float), Color#tmp, Node#parent/children, VertexAttribute#Color(), Usage#Color, ModelBuilder#createFromMesh, BoundingBox#getCenter()/updateCorners()/getCorners(), Matrix4.tmp [1.5.5] - Added iOS ARM-64 bit support for Bullet physics - 3D Animation, NodeAnimation keyframes are separated into translation, rotation and scaling - Added capability to enable color markup from inside skin json file. - Exposed method ControllerManager#clearListeners on Controllers class - Net#openURI now returns a boolean to indicate whether the uri was actually opened. - DefaultShader now always combines material and environment attributes - Added ShapeRenderer constructor to pass a custom shader program to ImmediateModeRenderer20. - API Change: Group#toString now returns actor hierarchy. Group#print is gone. - Added SpotLight class, see https://github.com/libgdx/libgdx/pull/2907 - Added support for resolving file handles using classpaths (ClasspathFileHandleResolver) [1.5.4] - Added support for image layers in Tiled maps (TiledMapImageLayer) - Added support for loading texture objects from TMX Maps (TextureMapObject) - Added support for border and shadow with FreeTypeFontGenerator - see https://github.com/libgdx/libgdx/pull/2774 - Now unknown markup colors are silently ignored and considered as normal text. - Updated freetype from version 2.4.10 to 2.5.5 - Added 3rd party extensions to setup application, see - Updated to RoboVM 1.0.0-beta-04 - Updated to GWT 2.6.1, sadly GWT 2.7.0 isn't production ready yet. [1.5.3] - API Change: TextField#setRightAlign -> TextField#setAlignment - I18NBundle is now compatible with Android 2.2 - Fixed GWT reflection includes for 3D particles - 3D ParticleEffectLoader registered by default - Added HttpRequestBuilder, see https://github.com/libgdx/libgdx/pull/2698 - Added LwjglApplicationConfiguration.useHDPI for Mac OS X with retina displays. Allows you to get "real" pixel coordinates for mouse and display coordinates. - Updated RoboVM to 1.0.0-beta-03 [1.5.2] - Fixed issue #2433 with color markup and alpha animation. - Fixed natives loading for LWJGL on Mac OS X [1.5.1] - Gradle updated to 2.2 - Android Gradle tooling updated to 1.0.0 - API Change: Switched from Timer to AnimationScheduler for driving main loop on GWT. Removed fps field from GwtApplicationConfiguration to instead let the browser choose the most optimal rate. - API Change: Added pause and resume handling on GWT backend. When the browser supports the page visibility api, pause and resume will be called when the tab or window loses and gains visibility. - API Change: Added concept of target actor, separate from the actor the action is added to. This allows an action to be added to one actor but affect another. This is useful to create a sequence of actions that affect many different actors. Previously this would require adding actions to each actor and using delays to get them to play in the correct order. - Added 64-bit support for iOS sim and device - Deprecated Node#children and Node#parent, added inheritTransform flag and methods to add/get/remove children - API Change: By default keyframes are no longer copied from Model to ModelInstance but shared instead, can be changed using the `ModelInstance.defaultShareKeyframes` flag or `shareKeyframes` constructor argument. - JSON minimal format now makes commas optional: newline can be used in place of any comma. - JSON minimal format is now more lenient with unquoted strings: spaces and more are allowed. - API Change: Added support for KTX/ZKTX file format, https://github.com/libgdx/libgdx/pull/2431 - Update stb_image from v1.33 to v1.48, see https://github.com/libgdx/libgdx/pull/2668 - Bullet Wrapper: added Gimpact, see https://github.com/libgdx/libgdx/issues/2619 - API Addition: Added MeshPartBuilder#addMesh(...), can be used to more easily combine meshes/models - Update to LWJGL 2.9.2, fixes fullscreen mode on "retina" displays - Fixes to RoboVM backend which would crash if accelerometer is used. [1.5.0] - API Addition: IOSInput now uses CMCoreMotion for accelerometer and magnetometer - API Addition: Added getter for UITextField on IOS for keyboard customization - API Addition: Added ability to save PixmapPackers to atlas files. See PixmapPackerIO. - API Addition: Added HttpRequestHeader and HttpResponseHeader with constants for HTTP headers. - API Addition: HttpRequest is now poolable. - New PNG encoder that supports compression, more efficient vertical flipping, and minimal allocation when encoding multiple PNGs. - API Change: Label#setEllipse -> Label#setEllipsis. - API Change: BatchTiledMapRenderer *SpriteBatch fields and methods renamed to *Batch - API Change: ScrollPane#scrollToCenter -> ScrollPane#scrollTo; see optional boolean arguments centerHorizontal and centerVertical (scrollToCenter centered vertically only). - API Change: Changed Input#getTextInput to accept both text and hint, removed Input#getPlaceholderTextInput. - Bug Fix: Fixed potential NPE with immersive mode in the Android fragment backend. - iOS backend now supports sound ids, thanks Tomski! [1.4.1] - Update to the Gradle Integration plugin nightly build if you are on Eclipse 4.4.x! - Update Intellij IDEA to 13.1.5+, because Gradle! - Updated to Gradle 2.1 and Android build tools 20, default Android version to 20. You need to install the latest Android build tools via the SDK manager - API Change: deprecation of bounding box methods, see https://github.com/libgdx/libgdx/pull/2408 - Added non-continuous rendering to iOS backend, thanks Dominik! - Setup now uses Gradle 2.1 with default Android API level 20, build tools 20.0.0 - Non-continuous renderering implemented for iOS - Added color markup support for scene2d label and window title. - API Change: removed default constructor of DecalBatch, removed DefaultGroupStrategy - Updated to latests RoboVM release, 1.0.0-alpha-04, please update your RoboVM plugins/installations - Reduced I18NBundle loading times on Android and bypassed unclosed stream on iOS. - Removed the gdx-ai extension from the libGDX repository. Now it lives in its own repository under the libGDX umbrella, see https://github.com/libgdx/gdx-ai - API Addition: Added randomSign and randomTriangular methods to MathUtils. - API Addition: Decal has now a getter for the Color. - API Addition: now I18NBundle can be set so that no exception is thrown when the key can not be found. - API Addition: added annotation support in reflection layer, thanks code-disaster! https://github.com/libgdx/libgdx/pull/2215 - API Addition: shapes like Rect, Circle etc. now implement Shape2D interface so you can put them all into a single collection https://github.com/libgdx/libgdx/pull/2178 - API Addition: bitmap fonts can now be loaded from an atlas via AssetManager/BitmapFontLoader, see https://github.com/libgdx/libgdx/pull/2110 - API Change: updated to RoboVM 1.0.0-SNAPSHOT for now until the next alpha is released. - API Change: Table now uses padding from its background drawable by default. https://github.com/libgdx/libgdx/issues/2322 - Drawables now know their names, making debugging easier. - API Change: Table fill now respects the widget's minimum size. - Texture packer, fixed image size written to atlas file. - API Change: Cell no longer uses primitive wrappers in public API and boxing is minimized. - API Addition: TextureAttribute now supports uv transform (texture regions). - API Change: Added parameters to Elastic Interpolation. - API Change: Removed Actor#setCenterPosition, added setPosition(x,y,align). - API Change: JsonReader, forward slash added to characters an unquoted strings cannot start with. - API Change: Stage#cancelTouchFocus(EventListener,Actor) changed to cancelTouchFocusExcept. - API Change: Json/JsonWriter.setQuoteLongValues() quotes Long, BigDecimal and BigInteger types to prevent truncation in languages like JavaScript and PHP. [1.3.1] - API change: Viewport refactoring. https://github.com/libgdx/libgdx/pull/2220 - Fixed GWT issues [1.3.0] - Added Input.isKeyJustPressed. - API Addition: multiple recipients are now supported by MessageDispatcher, see https://github.com/libgdx/libgdx/wiki/Message-Handling#multiple-recipients - API Change: State#onMessage now takes the message receiver as argument. - API Addition: added StackStateMachine to the gdx-ai extension. - API change: ShapeRenderer: rect methods accept scale, more methods can work under both line and fill types, auto shape type changing. - API change: Built-in ShapeRenderer debugging for Stage, see https://github.com/libgdx/libgdx/pull/2011 - Files#getLocalStoragePath now returns the actual path instead of the empty string synonym on desktop (LWJGL and JGLFW). - Fixed and improved xorshift128+ PRNG implementation. - Added support for Tiled's animated tiles, and varying frame duration tile animations. - Fixed an issue with time granularity in MessageDispatcher. - Updated to Android API level 19 and build tools 19.1.0 which will require the latest Eclipse ADT 23.02, see http://stackoverflow.com/questions/24437564/update-eclipse-with-android-development-tools-23 for how things are broken this time... - Updated to RoboVM 0.0.14 and RoboVM Gradle plugin version 0.0.10 - API Addition: added FreeTypeFontLoader so you can transparently load BitmapFonts generated through gdx-freetype via AssetManager, see https://github.com/libgdx/libgdx/blob/master/tests/gdx-tests/src/com/badlogic/gdx/tests/FreeTypeFontLoaderTest.java - Preferences put methods now return "this" for chaining - Fixed issue 2048 where MessageDispatcher was dispatching delayed messages immediately. - API Addition: 3d particle system and accompanying editor, contributed by lordjone, see https://github.com/libgdx/libgdx/pull/2005 - API Addition: extended shape classes like Circle, Ellipse etc. with hashcode/equals and other helper methods, see https://github.com/libgdx/libgdx/pull/2018 - minor API change (will not increase minor revision number): fixed a bug in handling of atlasPrefixes, https://github.com/libgdx/libgdx/pull/2023 - Bullet: btManifoldPoint member getters/setters changed from btVector3 to Vector3, also it is no longer pooled, instead static instances are used for callback methods - Added Intersector#intersectRayRay to detect if two 2D rays intersect, see https://github.com/libgdx/libgdx/pull/2132 - Bullet: ClosestRayResultCallback, AllHitsRayResultCallback, LocalConvexResult, ClosestConvexResultCallback and subclasses now use getter/setters taking a Vector3 instead of btVector3, see https://github.com/libgdx/libgdx/pull/2176 - 2d particle system supports pre-multiplied alpha. - Bullet: btIDebugDrawer/DebugDrawer now use pooled Vector3 instances instead of btVector3, see https://github.com/libgdx/libgdx/issues/2174 [1.2.0] - API Addition: Some OpenGL profiling utilities have been added, see https://github.com/libgdx/libgdx/wiki/Profiling - API Addition: A FreeTypeFontGeneratorLoader has been added to the gdx-freetype extension - API change: Animation#frameDuration and #animationDuration are now hidden behind a getter/setter and dynamic - API Addition: Vector#setZero - API Addition: gdx-ai, extension for AI algorithms. Currently supports FSMs, see https://github.com/libgdx/libgdx/wiki/Artificial-Intelligence - API change: TableLayout has been forked and integrated into libgdx more tightly, see http://www.badlogicgames.com/wordpress/?p=3458 - API Addition: added equals/hashCode methods to Rectangle, may break old code (very, very unlikely) - API Addition: scene2D Actors now have a setCenterPosition method, see https://github.com/libgdx/libgdx/pull/2000 [1.1.0] - Updated to RoboVM 0.0.13 and RoboVM Gradle plugin 0.0.9 - Big improvements to setup-ui and build times in Intellij IDEA https://github.com/libgdx/libgdx/pull/1865 - Setup now uses android build tools version: 19.1.0 - BitmapFontCache now supports in-string colored text through a simple markup language, see https://github.com/libgdx/libgdx/wiki/Color-Markup-Language - Added i18n localization/internationalization support, thanks davebaol, see https://github.com/libgdx/libgdx/wiki/Internationalization-and-Localization - Possibility to override density on desktop to simulate mobile devices, see https://github.com/libgdx/libgdx/pull/1825 - Progressive JPEG support through JPGD (https://code.google.com/p/jpeg-compressor/). - Mavenized JGLFW backend - Box2D: Added MotorJoint and ghost vertices on EdgeShape - Updated GWT Box2D to latest version - Updated native Box2D to latest version 2.3.1, no API changes - API change: Matrix4.set(x,y,z, translation) changed, z axis is no more flipped - API addition: Matrix4.avg(Matrix4[],float[]) that lets weighted averaging multiple matrices, Quaternion.slerp(Quaternion[],float[]) that lets weighted slerping multiple Quaternions - fixed the long standing issue of the alpha=1 not actually being fully opaque, thanks kalle! https://github.com/libgdx/libgdx/issues/1815 - down to 25 issues on the tracker, 8 bugs, 17 enhancement requests :) [1.0.1] - updated to RoboVM 0.12 (and so should you!) - fixed GC issues on iOS with regards to touch (thanks Niklas!), see https://github.com/libgdx/libgdx/pull/1758 - updated gwt gradle plugin to 0.4, android build tools to 0.10, gradle version to 1.11 - Tiled maps are now always y-up - Tiled maps now support drawing offsets for tiles - FileHandle#list is now supported in GWT! - FileHandle#list now supports FileFilters - Controllers now reinitialize on the desktop when switching between windowed/fullscreen - added a Texture unpacker that will extract all images from a texture atlas, see https://github.com/libgdx/libgdx/pull/1774 - updates to gdx-setup - CustomCollisionDispatcher in bullet, see https://github.com/libgdx/libgdx/commit/916fc85cecf433c3461b458e00f8afc516ad21e3 [1.0.0] - Box2D is no longer in the core, it has been moved to an extension. See http://www.badlogicgames.com/wordpress/?p=3404 - Merged gdx-openal project into gdx-backend-lwjgl - Now LoadedCallback in AssetLoaderParameters is always called after loading an asset from AssetManager, even if the asset is already loaded - Added Payload as a new parameter to Source.dragStop, see https://github.com/libgdx/libgdx/pull/1666 - You can now load PolygonRegions via AssetLoader, see https://github.com/libgdx/libgdx/pull/1602 - implemented software keyboard support in RoboVM iOS backend - Fixed an issue where key event timestamp is not set by the android backend. - scene2d.ui, added to TextArea the preferred number of rows used to calculate the preferred height. - scene2d.actions, fixed infinite recursion for event listener's handle(event). - Various Quaternion changes. - scene2d.ui, fixed a drawing issue with knobBefore when there's no knob (typical progress bar). - Various MeshBuilder fixes and additions. - Math package: added cumulative distribution. - Fixed Music isPlaying() on iOS when is paused. - Added support for C-style comments to JsonReader (mainly used for json skin files). - Support for resource removal from Skin objects. - Added fling gesture to generate fling in scrollpane. - Vector classes now have mulAdd method for adding pre-multiplied values - Vector implementations no longer use squared value for margin comparisons, see: isZero(float margin), isUnit(float margin). - Vector2 now has isUnit and isZero methods (copied from Vector3) - Removed deprecated methods from Vector classes. - Added new headless backend for server applications - Support 'scaledSize' as a json skin data value for BitmapFont - Added setAlpha(float a) method to Sprite class - Added Input.Keys.toString(int keycode) and Input.Keys.valueOf(String keyname) methods - Added Immersive Mode support to Android backend - Added userObject to Actor in scene2d, allowing for custom data storage - Altered Android's hide status bar behavior - Changed the way wakelocks are implemented. You no longer need any special permissions for the libgdx wakelock - BitmapFontCache setColor changes to match SpriteBatch and friends. http://www.badlogicgames.com/forum/viewtopic.php?f=23&t=12112 - Changed ParticleEffect: the ParticleEffect.save method now takes a Writer instead of a File - TexturePacker2 renamed to TexturePacker, added grid and scaling settings. - Added support for custom prefrences on the desktop backends. - Fixed double resume calls on iOS. - Android Music no longer throws exceptions if MediaPlayer is null. - PolygonSpriteBatch implements Batch. - New scene2d actions: EventAction, CountdownEventAction. - Adds cancelHttpRequest() method to Net interface - Updated GWT/HTML5 Backend to GWT 2.6.0 - Minimal Android version is 2.2, see http://www.badlogicgames.com/wordpress/?p=3297 - Updated to LWJGL 2.9.1 - Can now embed your libgdx app as a fragment, more info on the wiki - scene2d.ui, renamed Actor methods translate, rotate, scale, size to moveBy, rotateBy, scaleBy, sizeBy. May have conflicts with Actions static import, eg you'll need to use "Actions.moveBy" - scene2d.ui, Table background is now drawn usign the table's transform - scene2d.ui, added Container which is similar to a Table with one cell, but more lightweight - Added texture filters and mip map generation to BitMapFontLoader and FreeTypeFontGenerator - scene2d.ui, VerticalGroup and HorizontalGroup got pad, fill and an API similar to Table/Container - Removed OpenGL ES 1.0, 1.1 support; see http://www.badlogicgames.com/wordpress/?p=3311 - Added OpenGL ES 3 support - Updated Android backend, demos, tests to 4.4 - Added Viewport, changed Stage to have a Viewport instead of a Camera (API change, see http://www.badlogicgames.com/wordpress/?p=3322 ). - Changed play mode constants of Animation class to enumeration, see http://www.badlogicgames.com/wordpress/?p=3330 - Updated to RoboVM 0.0.11 and RoboVM Gradle plugin 0.0.6, see http://www.badlogicgames.com/wordpress/?p=3351 - Updated to Swig 3.0 for Bullet, disabled SIMD on Mac OS X as alignements are broken in Bullet, see https://github.com/libgdx/libgdx/pull/1595 - TextureData can only be Custom or Pixmap; compressed image files are considered custom [0.9.9] - added setCursorImage method to Input interface to support custom mouse cursors on the desktop - removed Xamarin backend, see http://www.badlogicgames.com/wordpress/?p=3213 - added Select class for selecting kth ordered statistic from arrays (see Array.selectRanked() method) - refactored Box2D to use badlogic Arrays instead of java.util.ArrayLists - MipMapGenerator methods now don't take disposePixmap argument anymore - added GLTexture, base class for all textures, encapsulates target (2d, cubemap, ...) - added CubeMap, 6 sided texture - changed TextureData#consumeCompressedData, takes target now - added RoboVM backend jar and native libs (libObjectAL, libgdx, in ios/ folder of distribution) - added RoboVM backend to build - changed Bullet wrapper API, see http://www.badlogicgames.com/wordpress/?p=3150 - changed MusicLoader and SoundLoader to be asynchronous loaders - changed behaviour of Net#sendHttpRequest() so HttpResponseListener#handleHttpResponse() callback is executed in worker thread instead of main thread - added Bresenham2, for drawing lines on an integer 2D grid - added GridPoint2 and GridPoint3, representing integer points in a 2D or 3D grid - added attribute location caching for VertexData/Mesh. Hand vertex attribs to a ShaderProgram, get back int[], pass that to Mesh - added Android x86 builds, removed libandroidgl20.so, it's now build as part of gdx-core for Android - changed method signature on Box2D World#getBodies and World#getJoints, pass in an Array to fill - removed glGetShaderSource from GL20, use ShaderProgram#getVertexShaderSource/getFragmentShaderSource instead - added reflection api - added AsynchExecutor, execute tasks asynchronously. Used for GWT mainly. - removed FileHandle#file(), has no business in there. - removed box2deditor - removed custom typedarrays in gwt backend - added classpath files support for gwt backend (limited) - moved AndroidWallpaperListener to Android Backend - added new VertexAttribute Usage flags, bone weight, tangent, binormal. previously encoded as Usage.Generic. Also added field "unit" to VertexAttribute, used by texture coordinates and bone weights to specify index/unit. - setup-ui template for iOS disables pngcrush, also updated wiki iOS article - add Pixmap#fillTriangle via jni gdx2d_fill_triangle() to fill a triangle based on its vertices. - add asynchronous download with continuous progress feedback to GWT asset preloader, see https://github.com/libgdx/libgdx/pull/409?w=1 - add capability to add/exclude package/classes GWT Reflection system, see https://github.com/libgdx/libgdx/pull/409?w=1 - add updated gdx-tiled-preprocessor, generate one single TextureAtlas for all the specified Tiled maps, see http://www.badlogicgames.com/forum/viewtopic.php?f=17&t=8911 - maps API, add new AtlasTiledMapLoader for loading maps produced by the tiled preprocessor tool - ImageProcessor, TexturePacker2 now accepts BufferedImage objects as input - TexturePacker2 now avoids duplicated aliases - Updated to LWJGL 2.9.0 - refactored JSON API, see http://www.badlogicgames.com/wordpress/?p=2993 - Updated Box2D to the latest trunk. Body#applyXXX methods now take an additional boolean parameter. - TmxMapLoader has a flag in Parameters that lets you specify whether to generate mipmaps - Animation#isAnimationFinished was fixed to behave as per javadocs (ignores looping) - remove GLU interface and implementations. Use Matrix4 et al instead. see http://www.badlogicgames.com/wordpress/?p=2886 - new maps API, see http://www.badlogicgames.com/wordpress/?p=2870 - removed static public tmp Vector2 instances, manage such temporary vars yourself, see http://www.badlogicgames.com/wordpress/?p=2840 - changed Scene2D Group#clear(), see http://www.badlogicgames.com/wordpress/?p=2837 - changed the build system, natives are now fetched from the build server, see http://www.badlogicgames.com/wordpress/?p=2821 - freetype extension supported on iOS, see http://www.badlogicgames.com/wordpress/?p=2819 - changed ShapeRenderer API, see http://www.badlogicgames.com/wordpress/?p=2809 - changed Actions.add to addAction, changed parameter order, and added removeAction, addListener, removeListener - Box2d joints now allow for user data - Changes to Intersector, Circle, Rectangle and BoundingBox for consistency in #overlap, #intersect and #contains methods, see https://github.com/libgdx/libgdx/pull/312 - Removed LwjglApplicationConfiguration CPU sync. Added foreground and background target framerate. - scene2d, no longer use getters/setters internally for Actor x, y, width, height, scalex, scaley and rotation. - Array, detect nested iterator usage and throw exception. - Added getVolume to Music class and Android, IOS and GWT backends - 1381, fixed JSON parsing of longs. In addition to Float, it now parses Long if no decimal point is found. - Changed Array constructors that took an array to have offset and count - scene2d, Actor parentToLocalCoordinates and localToParentCoordinates refactoring, see http://www.badlogicgames.com/forum/viewtopic.php?p=40441#p40441 - scene2d, Action#setActor no longer calls reset if the Action has no pool. This allows non-pooled actions to be add and removed from actors, restarted, and reused. - ScrollBar#setForceOverscroll renamed to setForceScroll, as it affects more than just overscroll. - ArrayMap#addAll renamed to putAll to match the other maps. - Added ObjectSet and IntSet. - Added completion listener to Music. - Added Music#setPan. - Sound#play and Sound#loop on Android now return -1 on failure, to match other backends. - DelegateAction subclasses need to implement delegate() instead of act(). http://www.badlogicgames.com/forum/viewtopic.php?p=43576#p43576 - Added pause and resume methods to Sound. - Changed AssetErrorListener#error to have AssetDescriptor to enable access to parameters of failed asset. - Changed SelectBoxStyle to have ScrollPaneStyle and ListStyle for fully customizing the drop down list. http://www.badlogicgames.com/wordpress/?p=3110 - AssetLoader now takes a FileHandle that is the resolved file name. The AssetLoader no longer has to resolve the file name, so we can prevent it from being resolved twice. - Rewrote EarClippingTriangulator to not allocate (no more Vector2s). - Added ParticleEffectLoader to make AssetManager load ParticleEffects - Added GeometryUtils, more Intersector functions, DelaunayTriangulator, ConvexHull. - Added getBoundingBox to ParticleEffect - EarClippingTriangulator changed to return triangle indices. - PolygonSpriteBatch and friends refactored to use triangle indices. - Added add(T, float), remove(int), remove(T) and clear() methods to BinaryHeap - Bitmap Font changes: - FreeTypeFontGenerator allows you to specify the PixmapPacker now, to create an atlas with many different fonts (see FreeTypePackTest) - BitmapFont, BitmapFontCache and FreeTypeFontGenerator now support fonts with multiple texture pages. (see BitmapFontTest and FreeTypePackTest) - BitmapFontData.imagePath and getImagePath() is depreacted, use imagePaths[] and getImagePath(int) instead - Added two BitmapFont constructors for convenience; no need to specify flip boolean - Added getCache() to BitmapFont, for expert users who wish to use the BitmapFontCache (see BitmapFontTest) - FreeTypeFontGenerator now includes setMaxTextureSize and getMaxTextureSize to cap the generated glyph atlas size (default 1024) - added render-hooks beginRender() and endRender() to BatchTiledMapRenderer - Added panStop to GestureListener interface. - ScissorStack#calculateScissors changed to take viewport, enabling it to work with glViewport. - Added Bits#getAndClear, Bits#getAndSet and Bits#containsAll - Added setX and setY to TextureAtlas.AtlasSprite so it matches expected behavior [0.9.8] - see http://www.badlogicgames.com/wordpress/?p=2791 [0.9.7] - see http://www.badlogicgames.com/wordpress/?p=2664 [0.9.6] - see http://www.badlogicgames.com/wordpress/?p=2513
[1.12.1] - LWJGL3 Improvement: Audio device is automatically switched if it was changed in the operating system. - Tiled Fix: TiledLayer parallax default values fix - API Addition: TiledDrawable: Align can be set to manipulate the alignment of the rendering (TiledDrawable#setAlign, TiledDrawable#getAlign) - API Addition: TiledDrawable#draw: Also available as a static function (with align) if you don't want to create an extra instance per texture region - Android: Removed mouse catching added on 1.12.0 due to unintended effects (see #7187). - Android: Fixed touch state inconsistency when touching screen with 3 fingers on some devices (see #7256) - iOS: Update to MobiVM 2.3.20 - API Addition: Using "object" property in Tiled object now fetches MapObject being pointed to, and BaseTmxMapLoader includes method for fetching map where key is id and value is MapObject instance. - Update to LWJGL 3.3.3 - API Addition: Vector4 is just like Vector2 or Vector3, but with x, y, z, and w float components; a Vector4 can be passed as a shader uniform. [1.12.0] - [BREAKING CHANGE] Added #touchCancelled to InputProcessor interface, see #6871. - [BREAKING CHANGE] Android: Immersive mode is now true by default. Set `useImmersiveMode` config to `false` to disable it. - [BREAKING CHANGE] iOS: Increased min supported iOS version to 11.0. Update your Info.plist file if necessary. - [BREAKING CHANGE] iOS: `hideHomeIndicator` set to `false` by default (was `true`). - [BREAKING CHANGE] iOS: `screenEdgesDeferringSystemGestures` set to `UIRectEdge.All` by default (was `UIRectEdge.None`). - [BREAKING CHANGE] iOS: preferred FPS is now uncapped by default, see #6717 - [BREAKING CHANGE] iOS: `ApplicationListener.create` and first `resize` are now called within `UIApplicationDelegate.didFinishLaunching`. Allows for earlier rendering and prevents black screen frames after launch screen. NOTE: App will get terminated if this method is blocked for more than 10-20 sec. - [BREAKING CHANGE] Actor#localToAscendantCoordinates throws an exception if the specified actor is not an ascendant. - [BREAKING CHANGE] WidgetGroup#hit first validates the layout. - [BREAKING CHANGE] Cell getters return object wrapper instead of primitives. - [BREAKING CHANGE] MeshPartBuilder#lastIndex now returns int instead of short. - [BREAKING CHANGE] 3D API - max bone weights is now configurable and limited to 4 by default. Change this value if you need less or more. See #6522. - [BREAKING CHANGE] Mesh#getVerticesBuffer, Mesh#getIndicesBuffer, VertexData#getBuffer, and IndexData#getBuffer are deprecated in favor to new methods with boolean parameter. If you subclassed some of these classes, you need to implement the new methods. - [BREAKING CHANGE] Desktop: The return value of AudioDevice#getLatency() is now in samples, and not milliseconds - [BREAKING CHANGE] iOS: 32 bit (armv7) builds are no longer supported. Builds must be 64 bit (arm64) only. - [BREAKING CHANGE] iOS: Use dynamic frameworks instead of static libs - [BREAKING CHANGE] optimized Mesh#bind and Mesh#unbind have a new parameter for instanced attribute locations. If you use these methods without instancing, you can pass a null value. - [BREAKING CHANGE] Dropped support for older libc versions since libGDX is now built on Ubuntu 20.04 (#7005) - [KNOWN ISSUE] Android drag behaviour. Gdx.input.getDeltaX() and Gdx.input.getDeltaY always return 0 for pointer 0. Fixed on next version. - Update to jnigen 2.4.1 - LWJGL Fix: setPosision() for MP3 files. - iOS: Add new MobiVM MetalANGLE backend - iOS: Update to MobiVM 2.3.19 - Update to LWJGL 3.3.2 - API Addition: Added Audio#switchOutputDevice and Audio#getAvailableOutputDevices to specify output devices. Only works for LWJGL3 - Fix LWJGL3: Audio doesn't die anymore, if a device gets disconnected - API Addition: Added Haptics API with 4 different Input#vibrate() methods with complete Android and iOS implementations. - Fix: Fixed Android and iOS touch cancelled related issues, see #6871. - Javadoc: Add "-use" flag to javadoc generation - Android: gdx-setup now uses AGP 7.2.2 and SDK 32, requiring Android Studio Chipmunk or IntelliJ IDEA 2022.2 and JDK 11. - libGDX is now built using Java 11 due to new Android requirements. The rest of libGDX can still be built with JDK 8 and runtime compatibility of libGDX projects should be unaffected. - Fixed glViewport when using HdpiMode.Logical with the LWJGL3 backend. - Added Stage#actorRemoved to fire exit events just before an actor is removed. - ScrollPane#setScrollingDisabled avoids invalidate() if nothing changed. - Fixed incorrect ScrollPane#scrollTo. - API Addition: Added Texture3D support - Fix: Throw an exception when maximum Attribute count is reached to prevent silent failure. - API Fix: The cursor can now be catched on Android. - LWJGL3 Fix: Stereo audio can now be played on mono output devices. This may also improve downmixing to stereo and upmixing to surround. - API Addition: Added CheckBox#getImageDrawable. - FIX: HexagonalTiledMapRenderer now displays maps with the correct stagger index. - API Addition: Added I18NBundle#keys() method. - TOOLS Features: Save mode can be changed in Flame particle 3D editor. - API Addition: added WebGL 2.0 implementation to Gwt backend : you can enable it by GwtApplicationConfiguration#useGL30 - Added GLES31 and GLES32 support with Lwjgl3 backend implementation - API Addition: JsonReader#stop() to stop parsing. - API Change: TextureAtlas now uses FileHandle#reader so outside code can control the charset - API Fix: Intersector#isPointInTriangle - API Addition: The Skin serializer now supports useIntegerPositions - API Change: The skin serializer now treats scaledSize as a float - API Change: DataInput throws an EOF-Exception - API Fix: RenderBuffer leak in GLFrameBuffer class - API Change: Pixmap#setPixels will now verify it has been given a direct ByteBuffer - API Addition: glTexImage2D and glTexSubImage2D with offset parameter - API Addition: OrientedBoundingBox - API Addition: Tiled parallax factor support - API Fix: LWJGL 3’s borderless fullscreen works with negative monitor coords - API Fix: Update mouse x and y values immediately after calling #setCursorPosition - API Change: Never stall with AssetManager on GWT - API Change: Allow packed depth stencil buffer creation when not using GL30 - API Fix: Fixed DataInput#readString for non-ASCII - API Fix: LwjglGraphics.setupDisplay() is no longer choosing the wrong display mode - API Fix: MathUtils.lerpAngle() fixed for extreme inputs - MathUtils trigonometry improvements - Various Scene2D fixes and improvements - Fix: JsonValue#addChild now clears leftover list pointers, preventing inconsistent or looping JSON objects. [1.11.0] - [BREAKING CHANGE] iOS: Increased min supported iOS version to 9.0. Update your Info.plist file if necessary. - [BREAKING CHANGE] Removed Maven and Ant build systems. libGDX is now solely built with Gradle. See https://libgdx.com/dev/from-source/ for updated build instructions. - [BREAKING CHANGE] Android Moved natives loading out of static init block, see #5795 - [BREAKING CHANGE] Linux: Shared libraries are now built on Ubuntu 18.04 (up from Ubuntu 16.04) - [BREAKING CHANGE] The built-in font files arial-15.fnt and arial-15.png have been replaced with lsans-15.fnt and lsans-15.png; this may change some text layout that uses the built-in font, and code that expects arial-15 assets to be present must change to lsans-15. - [BREAKING CHANGE] Legacy LWJGL3 projects must update the sourceCompatibility to 1.8 or higher. - [BREAKING CHANGE] Android Removed hideStatusBar configuration, see #6683 - [BREAKING CHANGE] Lwjgl3ApplicationConfiguration#useOpenGL3 was replaced by #setOpenGLEmulation - Gradle build now takes -PjavaVersion=7|8|9... to specify the Java version against which to compile libGDX. Default is Java 7 for everything, except the LWJGL3 backend, which is compiled for Java 8. - LWJGL3 extension: Added gdx-lwjgl3-glfw-awt-macos extension. Fixes GLFW in such a way, that the LWJGL3/libGDX must no longer run on the main thread in macOS, which allows AWT to work in parallel, i.e. file dialogs, JFrames, ImageIO, etc. You no longer need to pass `-XstartOnFirstThread` when starting an LWJGL3 app on macOS. See `AwtTestLWJGL` in gdx-tests-lwjgl3. For more information, see https://github.com/libgdx/libgdx/pull/6772 - API Addition: Added LWJGL3 ANGLE support for x86_64 Windows, Linux, and macOS. Emulates OpenGL ES 2.0 through DirectX (Windows), desktop OpenGL (Linux), and Metal (macOS). May become the preferred method of rendering on macOS if Apple removes OpenGL support entirely. May fix some OpenGL driver issues. More information here: https://github.com/libgdx/libgdx/pull/6672 - iOS: Update to MobiVM 2.3.16 - Update to LWJGL 3.3.1 - API Addition: ObjLoader now supports ambientColor, ambientTexture, transparencyTexture, specularTexture and shininessTexture - API Addition: PointSpriteParticleBatch blending is now configurable. - TOOLS Features: Blending mode and sort mode can be changed in Flame particle 3D editor. - API Addition: Polygon methods setVertex, getVertex, getVertexCount, getCentroid. - API Addition: TMX built-in tile property "type" is now supported. - API Addition: Octree structure. - API Addition: Added StringBuilder#toStringAndClear() method. - FirstPersonCameraController keys mapping is now configurable - Fix: GlyphLayout: Several fixes for color markup runs with multi-line or wrapping texts - API change: GlyphLayout#GlyphRun is now one GlyphRun per line. "color" was removed from GlyphRun and is now handled by GlyphLayout. - Gdx Setup Tool: Target Android API 30 and update AGP plugin to 4.1.3 - API Fix: Sound IDs are now properly removed; this prevents changes to music instances with the same ID - API Fix: LWJGL3Net#openURI does now work on macOS & JDK >= 16 - API Fix: Fixed a possible deadlock with AssetManager#dispose() and #clear() - API Change: Enable the AL_DIRECT_CHANNELS_SOFT option for Sounds and AudioDevices as well to fix stereo sound - API Addition: CameraInputController#setInvertedControls(boolean) - API Removal: AnimatedTiledMapTile#frameCount - LWJGL 3 is now the default desktop backend. If you want to port your existing applications, take a look here: https://gist.github.com/crykn/eb37cb4f7a03d006b3a0ecad27292a2d - Brought the official and third-party extensions in gdx-setup up to date. Removed some unmaintained ones and added gdx-websockets & jbump. - API Fix: Escaped characters in XML attributes are now properly un-escaped - Bug Fix: AssetManager backslash conversion removed - fixes use of filenames containing backslashes - gdx-setup now places the assets directory in project root instead of android or core. See advanced settings (UI) or arguments (command line) if you don't want it in root. - API Fix: Resolved issues with LWJGL 3 and borderless fullscreen - API Addition: GeometryUtils,polygons isCCW, ensureClockwise, reverseVertices - API Addition: Added FreeTypeFontGenerator#hasCharGlyph method. - API Fix: Pool discard method now resets object by default. This fixes the known issue about Pool in libGDX 1.10.0. - API Addition: Split GWT reflection cache into two generated classes - API Fix: Fix Box2D memory leak with ropes on GWT - API Fix: Fix NPE in Type#getDeclaredAnnotation - API Addition: Add pause/resume methods to AudioDevice - API Fix: Protection against NullPointerException in World#destroyBody() - API Fix: Prevent repeated mipmap generation in FileTextureArrayData - API Fix: Fix issue with camera reference in CameraGroupStrategy’s default sorter - API Fix: Move vertex array index buffer limit to backends to fix issue with numIndices parameter - API Fix: TexturePacker: Fix wrong Y value when using padding - API Fix: Lwjgl3Net: Add fallback to xdg-open on Linux if Desktop.BROWSE is unavailable - API Addition: Add NWSEResize, NESWResize, AllResize, NotAllowed and None SystemCursors - API Addition: GWTApplication#getJavaHeap and getNativeHeap are now supported - API Addition: Box2D Shape now implements Disposable - API Addition: Added ChainShape#clear method - API Addition: Added Tooltip#setTouchIndependent; see #6758 - API Addition: Emulate Timer#isEmpty on GWT - API Addition: Bits add copy constructor public Bits (Bits bitsToCpy) - API Addition: Added List#drawSelection(). - API Addition: GwtApplicationConfiguration#xrCompatible - API Fix: setSystemCursor() now works on Android - API Fix: getDisplayMode() is now more accurate on Android and GWT. - API Addition: JsonValue#iterator(String) to more easily iterate a child that may not exist. - API Addition: Added ExtendViewport#setScaling, eg for use with Scaling.contain. - API Addition: Added application lifecycle methods to IOSAudio for custom audio implementations. - API Addition: Added getBoundingRectangle() to Polyline - API Addition: ShapeRenderer#check() has now protected visibility - API Addition: Add ability to host GWT module on a different domain than the site, see #6851 - API Addition: Addes Tooltip#setTouchIndependent; see #6758 - API ADDITION: Emulate Timer#isEmpty on GWT - API Addition: OrientedBoundingBox. [1.10.0] - [BREAKING CHANGE] Android armeabi support has been removed. To migrate your projects: remove any dependency with natives-armeabi qualifier from your gradle build file, this apply to gdx-platform, gdx-bullet-platform, gdx-freetype-platform and gdx-box2d-platform. - [BREAKING CHANGE] tvOS libraries have been removed. No migration steps required. - [BREAKING CHANGE] Linux x86 (32-bit) support has been removed. No migration steps required. - [BREAKING CHANGE] Requires Java 7 or above. - [BREAKING CHANGE] API Change: Scaling is now an object instead of an enum. This may change behavior when used with serialization. - [BREAKING CHANGE] Group#clear() and #clearChildren() now unfocus the children. Added clear(boolean) and clearChildren(boolean) for when this isn't wanted. Code that overrides clear()/clearChildren() probably should change to override the (boolean) method. #6423 - [BREAKING CHANGE] Lwjgl3WindowConfiguration#autoIconify is enabled by default. - [KNOWN ISSUE] Pool no longer reset freed objects when pool size is above its retention limit. Pool will discard objects instead. If you want to keep the old behavior, you should override Pool#discard method to reset discarded objects. - Scene2d.ui: Added new ParticleEffectActor to use particle effects on Stage - API addition: iOS: Added HdpiMode option to IOSApplicationConfiguration to allow users to set whether they want to work in logical or raw pixels (default logical). - Fix for #6377 Gdx.net.openURI not working with targetSdk 30 - Api Addition: Added a Pool#discard(T) method. - Architecture support: Linux ARM and AARCH64 support has been added. The gdx-xxx-natives.jar files now contain native libraries of these architectures as well. - API Addition: Desktop Sound now returns number of channels and sample rate. [1.9.14] - [BREAKING CHANGE] iOS: IOSUIViewController has been moved to its own separate class - [BREAKING CHANGE] API Change: G3D AnimationDesc#update now returns -1 (instead of 0) if animation not finished. - [BREAKING CHANGE] InputEventQueue no longer implements InputProcessor, pass InputProcessor to #drain. - [BREAKING CHANGE] HeadlessApplicationConfiguration#renderInterval was changed to #updatesPerSecond - API addition: Added Pixmap#setPixels(ByteBuffer). - API change: ScreenUtils#getFrameBufferPixmap is deprecated in favor to new method Pixmap#createFromFrameBuffer. - API Addition: Added overridable createFiles() methods to backend application classes to allow initializing custom module implementations. - API Addition: Add a Graphics#setForegroundFPS() method. [1.9.13] - [BREAKING CHANGE] Fixed keycode representations for ESCAPE, END, INSERT and F1 to F12. These keys are working on Android now, but if you hardcoded or saved the values you might need to migrate. - [BREAKING CHANGE] TextureAtlas.AtlasRegion and Region splits and pads fields have been removed and moved to name/value pairs, use #findValue("split") and #findValue("pad") instead. - iOS: Update to MobiVM 2.3.12 - GWT: Key codes set with Gdx.input.setCatchKey prevent default browser behaviour - Added Scaling.contain mode: Scales the source to fit the target while keeping the same aspect ratio, but the source is not scaled at all if smaller in both directions. - API Addition: Added hasContents() to Clipboard interface, to reduce clipboard notifications on iOS 14 - TOOLS Features: Blending mode can be changed in Flame particle 3D editor. - Input Keycodes added: CAPS_LOCK, PAUSE (aka Break), PRINT_SCREEN, SCROLL_LOCK, F13 to F24, NUMPAD_DIVIDE, NUMPAD_MULTIPLY, NUMPAD_SUBTRACT, NUMPAD_ADD, NUMPAD_DOT, NUMPAD_COMMA, NUMPAD_ENTER, NUMPAD_EQUALS, NUMPAD_LEFT_PAREN, NUMPAD_RIGHT_PAREN, NUM_LOCK. Following changes might be done depending on platform: Keys.STAR to Keys.NUMPAD_MULTIPLY, Keys.SLASH to Keys.NUMPAD_DIVIDE, Keys.NUM to Keys.NUM_LOCK, Keys.COMMA to Keys.NUMPAD_COMMA, Keys.PERIOD to Keys.NUMPAD_DOT, Keys.COMMA to Keys.NUMPAD_COMMA, Keys.ENTER to Keys.NUMPAD_ENTER, Keys.PLUS to Keys.NUMPAD_ADD, Keys.MINUS to Keys.NUMPAD_SUBTRACT - Added a QuadFloatTree class. - Desktop: Cubemap Seamless feature is now enabled by default when supported, can be changed via backend specific methods, see supportsCubeMapSeamless and enableCubeMapSeamless in both LwjglGraphics and Lwjgl3Graphics. - API Addition: TextureAtlas reads arbitrary name/value pairs for each region. See #6316. - TexturePacker writes using a new format when legacyOutput is false (default is true). TextureAtlas can read both old and new formats. See #6316. [1.9.12] - [BREAKING CHANGE] iOS: Changed how Retina/hdpi handled on iOS. See #3709. - [BREAKING CHANGE] API Change: InputProcessor scrolled method now receives scroll amount for X and Y. Changed type to float to support devices which report fractional scroll amounts. Updated InputEvent in scene2d accordingly: added scrollAmountX, scrollAmountY attributes and corresponding setters and getters. See #6154. - [BREAKING CHANGE] API Change: Vector2 angleRad(Vector2) now correctly returns counter-clockwise angles. See #5428 - [BREAKING CHANGE] Android: getDeltaTime() now returns the raw delta time instead of a smoothed one. See #6228. - Fixed vertices returned by Decal.getVertices() not being updated - Fixes Issue #5048. The function Intersector.overlapConvexPolygons now should return the right minimum translation vector values. - Update to MobiVM 2.3.11 - API Change: Removed Pool constructor with preFill parameter in favor of using Pool#fill() method. See #6117 - API Addition: Slider can now be configured to only trigger on certain mouse button clicks (Slider#setButton(int)). - Fixed GlyphLayout not laying out correctly with color markup. - Fixed TileDrawable not applying its scale correctly. - API Addition: Added epsilon methods to maps with float values. - API Addition: Added an insertRange method to array collections. - Fixed GestureDetector maxFlingDelay. - API Change: Changed default GestureDetector maxFlingDelay to Integer.MAX_VALUE (didn't work before, this matches that). - Gdx.files.external on Android now uses app external storage - see wiki article File handling for more information - Improved text, cursor and selection rendering in TextArea. - API Addition: Added setProgrammaticChangeEvents, updateVisualValue, round methods to ProgressBar/Slider. - iOS: Keyboard events working on RoboVM on iOS 13.5 and up, uses same API as on other platforms - API Addition: Added AndroidLiveWallpaper.notifyColorsChanged() to communicate visually significant colors back to the wallpaper engine. - API Change: AssetManager invokes the loaded callback when an asset is unloaded from the load queue if the asset is already loaded. - GWT: changed audio backend to WebAudio API. Now working on mobiles, pitch implemented. Configuration change: preferFlash removed. When updating existing projects, you can remove the soundmanager js files from your webapp folder and the references to it from index.html - GWT: added possibility to lazy load assets via AssetManager instead of preload them before game start. See GWT specifics wiki article for more information. - GWT: New configuration setting usePhysicalPixels to use native resolution on mobile / Retina / HDPI screens. When using this option, make sure to update your code in index.html and HTMLLauncher from setup template. - GWT: GwtApplicationConfiguration and GWT backend now support an application to be resizable or fixed size. You can remove your own resizing code from your HTMLLaunchers. - GWT: Assets in distribute build are renamed with md5 hash suffix to bypass browser cache on changes - GWT: Fixed GwtFileHandle that was only returning text assets when listing a directory, now returns all children - API Addition: Pixmap.downloadFromUrl() downloads an image from http(s) URLs and passes it back as a Pixmap on all platforms - Added support for Linux ARM builds. - 32-bit: ARMv7/armhf - 64-bit: ARMv8/AArch64 - API Change: Removed arm abi from SharedLibraryLoader - API Addition: Added a Lwjgl3ApplicationConfiguration#foregroundFPS option. - API Change: Utility classes are now final and have a private constructor to prevent instantiation. - API Change: ScrollPane now supports all combinations of scrollBarsOnTop and fadeScrollBars. - API Addition: Added new methods with a "deg" suffix in the method's name for all Vector2 degrees-based methods and deprecated the old ones. - API Addition: Added Slider#setVisualPercent. - API Change: Enabling fullscreen mode on the lwjgl3 backend now automatically sets the vsync setting again. - API Addition: Added put(key, value, defaultValue) for maps with primitive keys, so the old value can be returned. - API Addition: Added ObjectLongMap. - Added Intersector#intersectRayOrientedBoundsFast to detect if a ray intersects an oriented bounding box, see https://github.com/libgdx/libgdx/pull/6139 - API Addition: Added Table#clip() and Container#clip() methods. - API Addition: Added getBackgroundDrawable() to Button. - API Addition: Added imageCheckedDown and getImageDrawable() to ImageButton and ImageTextButton. - API Addition: Added focusedFontColor, checkedFocusedFontColor, and getFontColor() to TextButton and ImageTextButton. - API Addition: Added wrapReverse setting to HorizontalGroup. - API Addition: Added Slider style drawables for over and down: background, knobBefore, and knobAfter. - Fixed LwjglFrame not hiding the canvas in some situations. - API Change: Table#round uses ceil/floor and is applied during layout, rather than afterward. - Fixed blurry NinePatch rendering when using a single center region. - API Change: Upon changing the window size with the lwjgl3 backend, the window is centered on the monitor. - Fixed DepthShaderProvider no longer creates one DepthShader per bones count. Now it creates only one skinned variant and one non-skinned variant based on DepthShader/Config numBones. - API Addition: Added Intersector#intersectPlanes to calculate the point intersected by three planes, see https://github.com/libgdx/libgdx/pull/6217 - API Addition: Added alternative Android Audio implementation for performant sound. See https://github.com/libgdx/libgdx/pull/6243. - API Addition: Expose SpriteBatch and PolygonSpriteBatch setupMatrices() as protected. - API Addition: New parameter OnscreenKeyboardType for Input.setOnscreenKeyboardVisible and Input.getTextInput [1.9.11] - Update to MobiVM 2.3.8 - Update to LWJGL 3.2.3 - Fixed AndroidInput crashes due to missing array resize (pressure array). - API Change: Ray#set methods and Ray#mul(Matrix4) normalize direction vector. Use public field to set and avoid nor() - API Change: New internal implementation of all Map and Set classes (except ArrayMap) to avoid OutOfMemoryErrors when too many keys collide. This also helps resistance against malicious users who can choose problematic names. - API Addition: OrderedMap#alter(Object,Object) and OrderedMap#alterIndex(int,Object) allow swapping out a key in-place without changing its value; OrderedSet also has this. - API Addition: Json can now read/write: ObjectIntMap, ObjectFloatMap, IntMap, LongMap. - API Addition: Added @Null annotation for IDE null analysis. All parameters and return values should be considered non-null unless annotated (or javadoc'ed if not yet annotated). - API Addition: Added ParticleEmitter#preAllocateParticles() and ParticleEffect#preAllocateParticles() to avoid particle allocations during updates. - Fixed changing looping state of already playing sounds on Android by first pausing the sound before setting the looping state (see #5822). - API Change: scene2d: Table#getRow now returns -1 when over the table but not over a row (used to return the last row). - API Change: scene2d: Tree#addToTree and #removeFromTree now have an "int actorIndex" parameter. - API Addition: scene2d: Convenience method Actions#targeting(Actor, Action) to set an action's target. - API Change: scene2d: In TextField, only revert the text if the change event was cancelled. This allows the text to be manipulated in the change listener. - API Change: scene2d: Tree.Node#removeAll renamed to clearChildren. - API Addition: scene2d: Added SelectBox#setSelectedPrefWidth to make the pref width based on the selected item and SelectBoxStyle#overFontColor. - API Change: DefaultTextureBinder WEIGHTED strategy replaced by LRU strategy. - API Change: ShaderProgram begin and end methods are deprecated in favor to bind method. - API Addition: Added a OpenALAudio#getSourceId(long) method. - API Addition: Added a ShaderProgram#getHandle() method. - API Change: Replaced deprecated android support libraries with androidx. AndroidFragmentApplication is only affected. - API Addition: Created interfaces AndroidAudio and AndroidInput and added AndroidApplication#createAudio and AndroidApplication#createInput to allow initializing custom module implementations. - Allows up to 64k (65536) vertices in a Mesh instead of 32k before. Indices can use unsigned short range, so index above 32767 should be converted to int using bitwise mask, eg. int unsigneShortIndex = (shortIndex & 0xFFFF). - API Change: DragAndDrop only removes actors that were not already in the stage. This is to better support using a source actor as the drag actor, see #5675 and #5403. - API Change: Changed TiledMapTileLayer#tileWidth & #tileHeight from float to int - API Addition: convenient Matrix4 rotate methods: rotateTowardDirection and rotateTowardTarget - API Addition: Convenience method Actions#targeting(Actor, Action) to set an action's target. - API Change: Correction of TextField#ENTER_ANDROID renamed to NEWLINE and TextField#ENTER_DESKTOP renamed to CARRIAGE_RETURN. - API Change: Changed the visibility of TextField#BULLET, TextField#DELETE, TextField#TAB and TextField#BACKSPACE to protected. - API Addition: TextField and TextArea are providing the protected method TextField#checkFocusTraverse(char) to handle the focus traversal. - API Addition: UIUtils provides the constants UIUtils#isAndroid and UIUtils#isIos now. - Fixed: The behaving of TextFields and TextAreas new line and focus traversal works like intended on all platforms now. - API Change: Changed Base64Coder#encodeString() to use UTF-8 instead of the platform default encoding. See #6061 - Fixed: SphereShapeBuilder poles are now merged which removes lighting artifacts, see #6068 for more information. - API Change: Matrix3#setToRotation(Vector3, float float) now rotates counter-clockwise about the axis provided. This also changes Matrix3:setToRotation(Vector3, float) and the 3d particles will rotate counter-clockwise as well. - API Change: TexturePacker uses a dash when naming atlas page image files if the name ends with a digit or a digit + 'x'. - API Addition: Added Skin#setScale to control the size of drawables from the skin. This enables scaling a UI and using different sized images to match, without affecting layout. - API Change: Moved adding touch focus from Actor#notify to InputListener#handle (see #6082). Code that overrides InputListener#handle or otherwise handles InputEvent.Type.touchDown events must now call Stage#addTouchFocus to get touchDragged and touchUp events. - API Addition: Added AsynchronousAssetLoader#unloadAsync to fix memory leaks when an asset is unloaded during loading. - Fixed Label text wrapping when it shouldn't (#6098). - Fixed ShapeRenderer not being able to render alpha 0xff (was max 0xfe). - API Change: glGetActiveUniform and glGetActiveAttrib parameter changed from Buffer to IntBuffer. [1.9.10] - API Addition: Allow target display for maximization LWJGL3 backend - API Addition: Accelerometer support on GWT - API Change: Set default behaviour of iOS audio to allow use of iPod - API Change: IOSDevice is no longer an enum to allow users to add their own new devices when LibGDX is not up to date - API Addition: Add statusBarVisible configuration to IOSApplicationConfiguration - Update GWT Backend to GWT 2.8.2 - Update Android backend to build against API 28 (Android 9.0) - API Addition: Input.isButtonJustPressed - Update to LWJGL 2 backend to 2.9.3 - Update to MobiVM 2.3.6 release - Update to LWJGL 3.2.1 - API Addition: Input allows getting the maximum number of pointers supported by the backend - API Addition: Configuration option added to allow setting a max number of threads to use for net requests - API Change: NetJavaImpl now uses a cached thread pool to allow concurrent requests (by default, the thread pool is unbounded - use maxNetThreads in backend configurations to set a limit - set to 1 for previous behavior) - API Addition: New MathUtils norm and map methods - API Change: Pixmap blending was incorrect. Generated fonts may change for the better, but may require adjusting font settings. - API Change: Particle effects obtained from a ParticleEffectPool are now automatically started - Removed OSX 32-bit support - API Change: By default LWJGL2 backend no longer does pause/resume when becoming background/foreground window. New app config setting was added to enable the old behavior. - API Change: By default LWJGL2 backend now does pause/resume when window is minimized/restored. New app config setting was added to disable this behavior. - LWJGL3: Fixed window creation ignoring refresh rate of fullscreen mode. - TmxMapLoader and AtlasTmxMapLoader refactoring: Shared functionality was moved to BaseTmxMapLoader, duplicate code was removed. - AtlasTmxMapLoader supports group layers now (a positive side effect of the BaseTmxMapLoader refactoring). - API Change: TmxMapLoader and AtlasTmxMapLoader: load/loadAsync methods work exactly as before, but many methods of these classes had to change. This makes it possible implement new Tiled features. - API Addition: TextField#drawMessageText. - Fixed TextField rendering text outside the widget at small sizes. - API Addition: Group#getChild(int) - API Addition: notEmpty() for collections. - API Change: scene2d.ui Tree methods renamed for node set/getObject to set/getValue. - API Change: scene2d.ui Tree and Tree.Node require generics for the type of node, values, and actors. - API Change: For Selection in scene2d.utils "toggle" is now respected when !required and selected.size == 1. - API Addition: new InstanceBufferObject and InstanceBufferObjectSubData classes to enable instanced rendering. - API Addition: Support for InstancedRendering via Mesh - API Change: Cell#setLayout renamed to setTable. - API Addition: Added Collections#allocateIterators. When true, iterators are allocated. When false (default), iterators cannot be used nested. - API Addition: Added Group#removeActorAt(int,boolean) to avoid looking up the actor index. Subclasses intending to take action when an actor is removed may need to override this new method. - API Change: If Group#addActorAfter is called with an afterActor not in the group, the actor is added as the last child (not the first). [1.9.9] - API Addition: Add support for stripping whitespace in PixmapPacker - API Addition: Add support for 9 patch packing in PixmapPacker - API Addition: Pressure support for ios/android. https://github.com/libgdx/libgdx/pull/5270 - Update to Lwjgl 3.2.0 - Update android level we build against to 7.1 (API 25) - API Change: gdx-tools no longer bundles dependencies to be compatible with java 9 - Skin JSON files can now use the simple names of classes, i.e. "BitmapFont" rather than "com.badlogic.gdx.graphics.g2d.BitmapFont". Custom classes can be added by overriding Skin.getJsonLoader() and calling json.setClassTag(). - Skin supports cascading styles in JSON. Use the "parent" property to tag another style by name to use its values as defaults. See https://github.com/libgdx/libgdx/blob/master/tests/gdx-tests-android/assets/data/uiskin.json for example. - SkinLoader can be used on subclasses of Skin by overriding generateSkin(). - API addition: Tree indentation can be customized. - Fixed GlyphLayout not respecting BitmapFontData#down. - API Addition: Added faceIndex paramter to #FreeTypeFontGenerator(FileHandle, int). - API Change: BitmapFont#getSpaceWidth changed to BitmapFont#getSpaceXadvance. - Many GlyphLayout fixes. - API Addition: Added FileHandle#map(), can be used to memory map a file - API Change: BitmapFontData#getGlyphs changed for better glyph layout. See https://github.com/libgdx/libgdx/commit/9a7dfdff3c6374a5ebd2f33a819982aceb287dfa - API Change: Actor#hit is now responsible for returning null if invisible. #5264 - API Addition: Added [Collection]#isEmpty() method to all 22 custom LibGDX-collections (e.g. Array, ObjectMap, ObjectSet, Queue, ...) - API Addition: StringBuilder#clear() - API Addition: Color#WHITE_FLOAT_BITS - Table layout fixed when expand is used and the layout width is less than the table's min width. - InputMultiplexer#setProcessors(Array) now copies the items instead of using the specified array instance. - API Change: A wrapped HorizontalGroup or VerticalGroup will now size children down to their min size if the group is smaller than their pref size. - LWJGL3: useVSync() is now a per-window setting. Any additional windows should disable vsync to avoid frames dropping to (refresh rate / # of windows). - Batch and sprite implementations and SpriteCache store Color separately from the float packed color, since converting to/from float is lossy. - API Change: NumberUtils floatToIntColor expands the alpha from 0-254 to 0-255, so 255 doesn't become 254 from conversion from int to float to int. - API Change: Batch and Decal setColor(float) renamed to setPackedColor for differentiation, since the conversion from float to Color is lossy. - API Change: PolygonSprite getVertexColor renamed to getPackedColor to match other classes. - API Change: FreeTypeFontGenerator only generates a missing glyph if \0 is in the characters. - API Change: DragScrollListener no longer requires the touch/mouse cursor to be directly above/below the scroll pane. - API Change: List#toString(Object) changed from protected to public. Subclasses overriding this need to change to public. - API Change: List now handles more key presses. - API Change: TexturePacker ImageProcessor#addImage(File, String) now returns the Rect. [1.9.8] - Add iPhoneX images - Fix MacOS issue with GL_ARB_texture_float extension check - Fix AtlasTmxMapLoader tileset tile id offset - Bullet: updated to 2.87, see: http://bulletphysics.org/wordpress/?p=485 - API Addition: Possibility to specify TexturePacker settings for resampling when scaling. - API Addition: Support for customizing render buffer attachments in GLFrameBuffers - API Change: Revert to constructors for GLFrameBuffers for easier customization [1.9.7] - Update to MobiVM(RoboVM) 2.3.3 - Add iOS 11 support - Update to Lwjgl 3.1.3 - Update to MOE 1.4.0 - API Change: GLFrameBuffer has been refactored https://github.com/libgdx/libgdx/pull/4882. Create standard FrameBuffers with static methods. Customized FBOS with FrameBufferBuilder - API addition: Tiled group layer support - Fix Tiled properties, offset parsing for image layers - API addition: Added utility methods for Vector equals with epsilon - Fix Animation backing array type - Fix Mesh copying with 0 indices - Fix restoration of pooled particle effects scale - Fix loss of controller listeners on reconnect - Added basic kotlin project generation support in the setup tool - API addition: Allow APK expansion to be used in fragments and activities - API addition: Added color properties support from tiled maps - API Change: Added rotation vector sensor support on Android - API Change: GLProfiler refactored for OOP and lwjgl3 multi windows - LWJGL3: The creation of additional windows via Lwjgl3Application.newWindow() is now deferred, with postRunnable(), until all existing windows have been updated. This fixes a potential native crash with NVidia GL drivers on Windows, presumably caused by a GL context conflict. - API addition: Lwjgl3WindowListener.created() is called after a new window has been created. It's unsafe to call Lwjgl3Window functions in between Lwjgl3Application.newWindow() and this callback. - Updated LWJGL3 backend to 3.1.3. - Lwjgl3Graphics.setUndecorated() and Lwjgl3Graphics.setResizable() now delegate their work to the respective GLFW functions. - API addition: ProgressBar.isVertical() - returns whether a progress bar is vertical or horizontal. - API Change: SplitPane now by default does not allow the split amount to shrink children below their minimum sizes (cropping them). This behavior can be reverted by overriding clampSplitAmount or wrapping the children in Containers set to minSize(0) and fill(). SplitPane also now correctly includes the handle min size in its own min size calculations. - API Change: SplitPane.getSplit() renamed to SplitPane.getSplitAmount() to match other getter and setter names. - Improved internal Timer synchronization. - API Change: List#drawItem, added float width parameter. - API Addition: Make it possible to disable sound on the GWT-Backend with disableSound=true. - API Change: ScrollPane setWidget deprecated in favor of setActor to match other APIs. - API Change: removed JGLFW backend - Fixed mixed up use of TexturePacker.Settings.stripWhitespaceX|Y. - Added joystick POV support to LWJGL3 controller backend. - Added support for 2d particles sprite animation. - API Change: ParticleEmitter getSprite, setSprite, getImagePath, setImagePath are now getSprites, setSprites, getImagePaths, setImagePaths. - Added support for 2d particles independant scale X and Y. - API Change: ParticleEmitter getScale, matchSize are now getScaleX/getScaleY, matchSizeX/matchSizeY. Added scaleSize(float scaleX, float scaleY) - API Change: Added iconDropped() callback to AndroidWallpaperListener. [1.9.6] - Fix performance regression in LWJGL3 backend, use java.nio instead of BufferUtils. Those are intrinsics and quite a bit faster than BufferUtils on HotSpot. - Updated to latest Sound Manager 2 - Added mappings for Xbox 360 controller for Linux - Separated error log for vertex/fragment shaders for easier debugging - Minimum Android API level is now level 9 (Android 2.3) - API addition: Configurable TexturePacker bleed iterations - Updated IOS Multi-OS Engine backend to 1.3.6 - API Change: Pixmap.setBlending, Pixmap.setFilter are now instance methods - VertexAttribute expert constructors exposed. Short types can now be used for attributes. [1.9.5] - Fix NPE swallowing "video driver unsupported" error on LWJGL 2 backend. - Allow window icons to be set in Lwjgl3ApplicationConfiguration or Lwjgl3WindowConfiguration. - Allow window icon and title to be changed in Lwjgl3Window - API Addition: ApplicationLogger interface, allowing easier access to custom logging - DefaultRenderableSorter accounts for center of Renderable mesh, see https://github.com/libgdx/libgdx/pull/4319 - Bullet: added FilterableVehicleRaycaster, see https://github.com/libgdx/libgdx/pull/4361 - Bullet: updated to 2.85, see: http://bulletphysics.org/wordpress/?p=456 - Updated iOS native build scripts to iOS 10.1 and TVOS 10.0 - API Addition: BitmapFont#blankLineScale. - Fixed rounding of Drawables in ProgressBar. Allow rounding to be disabled with setRound(). - Updated LWJGL3 backend to LWJGL 3.1.0, see https://blog.lwjgl.org/lwjgl-3-1-0-released/ - LWJGL3 backend now supports non-continuous rendering, see https://github.com/libgdx/libgdx/pull/3772 - API Change: Lwjgl3WindowListener.refreshRequested() is called when the windowing system (GLFW) reports contents of a window are dirty and need to be redrawn. - API Change: Lwjgl3WindowListener.maximized() is called when a window enters or exits a maximized state. - API Change: Lwjgl3WindowListener.deiconified() removed, combined with .iconified(). - API Change: Lwjgl3Window.deiconify() renamed to .restore() since it can also be used to de-maximize a window. - Lwjgl3Window now has a maximize() method, and windows can be started maximized using the window or app configuration's setMaximized() method. - NinePatch can now be drawn rotated or scaled. - NinepatchDrawable is now a TransformDrawable. - API Change: Group add* methods no longer remove and re-add the actor if it is already in the group, instead they do nothing. - API Change: g2d.Animation is now generic so it can support Drawables, PolygonRegions, NinePatches, etc. To fix existing code, specify the TextureRegion type in animation declarations (and instantiations in Java 6), i.e. Animation<TextureRegion> myAnimation = new Animation<TextureRegion>(...); - TiledDrawable throws unsupported operation if trying to draw rotated/scaled. #4005 - API Change: DragAndDrop now puts default position of drag actor at pointer location. The original default offset from the pointer was (14, -20). - Added ShaderProgramLoader for AssetManager. - BoundingBox#isValid now returns also true when min==max, see: https://github.com/libgdx/libgdx/pull/4460 [1.9.4] - Moved snapping from ProgressBar to Slider to prevent snapping when setting the value programmatically. - Bullet: added btSoftBody#getLinkCount() and btSoftBody#getLink(int), see https://github.com/libgdx/libgdx/issues/4152 - API Change: Wrapping for scene2d's HorizontalGroup and VerticalGroup. - Fix hiero problem with certain unicode characters. See https://github.com/libgdx/libgdx/issues/4202 - Switched to RoboVM fork 2.2.0, fixes incompatibility with Android Gradle plugin and iOS 9.3.4 [1.9.3] - Switched to MobiDevelop's RoboVM fork (http://robovm.mobidevelop.com) - Addition of Intel Multi-OS Engine backend for deploying to iOS - Updated iOS native build scripts to iOS 9.3 and TVOS 9.2 - API Addition: GestureDetector#pinchStop() called when no longer pinching - API Addition: Gdx.graphics.setUndecorated/setResizable API added to Graphics https://github.com/libgdx/libgdx/pull/3847 - API Addition: Gdx.graphics.getGLVersion(), grab the GL version and implementation type. https://github.com/libgdx/libgdx/pull/3788 - API Change: Lwjgl3WindowListener -> filesDropped(String[] files) adds drag'n drop support for the lwjgl3 backend - Added isComplete() to ParticleEffect to make it easier to know when all the emitters are done, behaves the same as in the 2D API. - API Change: renamed Lwjgl3WindowListener.windowIsClosing() to closeRequested() to better communicate its intent. - Add IndexData.updateIndices method to increase performance when used with IndexBufferObjectSubData. - Added FlushablePool - Added ShapeCache see https://github.com/libgdx/libgdx/pull/3953 - API Change: moved shape builder logic out of MeshBuilder, see: https://github.com/libgdx/libgdx/pull/3996 - API Change: changed copy constructor OrderedMap(ObjectMap) to OrderedMap(OrderedMap) - API Change: Table reset now calls clearChildren, not clear. - Fixed crashes in AndroidMusic.java when isPlaying is called. Errors are now logged only rather than crashing the app. - Added emulation of ScreenUtils for GWT - Improved performance of glReadPixels() on GWT. New method is 20-30 times faster - Fixed crash on Mac when using LWJGL2, custom cursors and embedding the game in an AWT window - Fixed getDisplayModes(Monitor monitor) returning wrong data on LWJGL2 backend - Fixed Gdx.input.getCurrentEventTime() not being set on LWJGL3, fixes GestureDetector and flick scroll not working - Fixed not being able to select non-latin characters in TextFields - Bullet: added CustomActionInterface, see https://github.com/libgdx/libgdx/pull/4025 - Add window size limits option to LWJGL3 app and window configurations - Add handling of tag "<objectgroup>" within tags "<tile>" in TmxMap loaders. [1.9.2] - Added TextureArray wrapper see https://github.com/libgdx/libgdx/pull/3807 - Fixed bug in AndroidGL20.cpp which cast a pointer to a 32-bit int. Crash on 64-bit ARM, but only for a specific code path and address... - Fixed multiple controllers registering on same index with LWJGL3, see https://github.com/libgdx/libgdx/issues/3774 - Fixed the FreeTypeFontGenerator texture bleeding, see https://github.com/libgdx/libgdx/issues/3521 [1.9.1] - API Change: Override GwtApplication#createApplicationListener() to create your ApplicationListener on GWT, overriding GwtApplication#getApplicationListener() isn't needed anymore, see https://github.com/libgdx/libgdx/issues/3628 - Fixed ARM64 and x86_64 binaries for Android [1.9.0] - API Change: Lwjgl3ApplicationConfiguration#setBackbufferConfig -> setBackBufferConfig - Fixed HexagonalTiledMapRenderer, see https://github.com/libgdx/libgdx/pull/3654 - Added support for locking the screen orientation in GWT, see https://github.com/libgdx/libgdx/pull/3633 - Added Gdx-Kiwi and gdx-lml to extensions, see https://github.com/libgdx/libgdx/pull/3597 - Added Gyroscope support in Input, implemented for Android, see https://github.com/libgdx/libgdx/pull/3594 - Fixed touch mapping on iOS, see https://github.com/libgdx/libgdx/pull/3590 - Added orientation to Box2D Transform class, see https://github.com/libgdx/libgdx/pull/3308 - Added system cursors to GWT, fix 'Ibeam' system cursor not working on LWJGL3. - Added experimental AndroidApplicationConfiguration#useGL30 and IOSApplicationConfiguration#useGL30 for testing OpenGL ES 3.0 support on mobile devices, do not use in production. - Fix broken kerning for FreeType fonts, see https://github.com/libgdx/libgdx/pull/3756 - Added ARM64 and x86_64 binaries for Android - API Addition: FreeTypeFontParameter has an additional field for tweaking hinting, see https://github.com/libgdx/libgdx/pull/3757 [1.8.0] - API Change: Rewrote FreeType shadow rendering (much better). - Added spaceX/Y to FreeType fonts. - Higher quality FreeType font rendering. - Hiero updated to v5, now with FreeType support and other new features! - GlyphLayout now allocates much, much less memory when processing long text that wraps. - Added LWJGL 3 backend, see https://github.com/libgdx/libgdx/issues/3673 for more info. - Added Graphics#getBackBufferWidth and Graphics#getBackBufferHeight for HDPI handling - API Change: Added HdpiUtils. Instead of calling GL20#glViewport and GL20#glScissor yourself please use HdpiUtils instead. It will ensure that you handle HDPI monitors correctly when using those OpenGL functions. On HDPI monitors, the size reported by Gdx.graphics getWidth/getHeight is in logical coordinates as dictated by the operating system, usually half the HDPI resolution. The OpenGL drawing surface works in backbuffer coordinates at the full HDPI resolution. If you pass logical coordinates to glViewport and glScissor, you only affect a quarter of the real backbuffer size. Use HdpiUtils instead, it will do the right thing, while letting you continue to work in logical (aka returned by Gdx.graphics.getWidth/getHeight) coordinates. - API Change: Graphis#getDesktopDisplayMode() has been renamed to Graphics#getDisplayMode() and returns the current display mode of the monitor the window is shown on (primary monitor on all backends except LWJGL3, which supports real multi-monitor setups). - API Change: Graphics#getDisplayModes() return the display modes of the monitor the monitor the window is shown on (primary monitor on all backends except LWJGL3 which supports real multi-monitor setups). - API Change: Graphics#setDisplayMode(DisplayMode) has been renamed to Graphics#setFullscreenMode(). If the window is in windowed mode, it will be switched to fullscreen mode on the monitor from which the DisplayMode stems from. - API Change: Graphics#setDisplayMode(int, int, boolean) has been renamed to Graphics#setWindowedMode(int, int). This will NOT allow you to switch to fullscreen anymore, use Graphics#setFullscreenMode() instead. If the window is in fullscreen mode, it will be switched to windowed mode on the monitor the window was in fullscreen mode on. - API Addition: Graphics#Monitor, represents a monitor connected to the machine the app is running on. A monitor is defined by a name and it's position relative to other connected monitors. All backends except the LWJGL3 backend will report only the primary monitor - API Addition: Graphics#getPrimaryMonitor() returns the primary monitor you usually want to work with. - API Addition: Graphics#getMonitor() returns the monitor your app's window is shown on, which may not be the primary monitor in >= 2 monitor systems. All backends except the LWJGL3 backend will report only the primary monitor. - API Addition: Graphics#getMonitors() returns all monitors connected to the system. All backends except the LWJGL3 backend will only report the primary monitor. - API Addition: Graphics#getDisplayMode(Monitor) returns the display mode of the monitor the app's window is shown on. All backends except the LWJGL3 backend will report the primary monitor display mode instead of the actual monitor's display mode. Not a problem as all other backends run on systems with only a single monitor so far (primary monitor). - Added option to include credentials on cross-origin http requests (used only for GWT backend). - Added option to specify crossorigin attribute when loading images with AssetDownloader (GWT), see #3216. - API Change: removed Sound#setPriority, this was only implemented for the Android backend. However, Android itself never honored priority settings. - API Change: cursor API has been cleaned up. To create a custom cursor, call Graphics#newCursor(), to set the custom cursor call Graphics#setCursor(), to set a system cursor call Graphics#setSystemCursor(). The Cursor#setSystemCursor method has been removed as that was not the right place. Note that cursors only work on the LWJGL, LWJGL3 and GWT backends. Note that system cursors only fully work on LWJGL3 as the other two backends lack a means to set a specific system cursor. These backends fall back to displaying an arrow cursor when setting any system cursor. - API Addition: Added Lwjgl3WindowListener, allows you to hook into per-window iconficiation, focus and close events. Also allows you to prevent closing the window when a close event arrives. [1.7.2] - Added AndroidAudio#newMusic(FileDescriptor) to allow loading music from a file descriptor, see #2970 - Added GLOnlyTextureData, which is now the default for FrameBuffer and FrameBufferCubemap, see #3539 - Added rotationChanged() for Actor class, called when rotation changes, see https://github.com/libgdx/libgdx/pull/3563 - Fixed crash on MacOS when enumerating connected gamepads. - ParticleEmitter no longer says it's complete when it's set to continuous, see #3516 - Improved JSON parsing and object mapping error messages. - Updated FreeType from version 2.5.5 to 2.6.2. - Fixed corrupt FreeType rendering for some font sizes. - API Change: FreeTypeFontParameter has new fields for rendering borders and shadows. - FreeTypeFontParameter can render much better fonts at small sizes using gamma settings. - BitmapFont can now render missing (tofu) glyph for glyphs not in the font. - FreeTypeFontGenerator depreacted methods removed. - Fixed BitmapFont color tags changing glyph spacing versus not using color tags. BitmapFont#getGlyphs has a new paramter. See #3455. - Skin's TintedDrawable now works with TiledDrawable. #3627 - Updated jnigen to Java Parser 2.3.0 (http://javaparser.github.io/javaparser/). - FreeType fonts no longer look terrible at small size. This is a big deal! - Updated to RoboVM 1.12.0, includes tvOS support! [1.7.1] - Fixes AtlasTmxMapLoader region name loading to tileset name instead of filename - Changes TiledMapPacker output, region names are tileset names, adjusts gid, defaults to one atlas per map - API Change: members of Renderable and MeshPart are changed, see https://github.com/libgdx/libgdx/pull/3483 - Added Vector#setToRandomDirection(), see #3222 - Updated to stb_image v2.08 - Added Node#copy(), used when creating a ModelInstance from a Model to allow using custom nodes - Add ModelCache, see https://github.com/libgdx/libgdx/wiki/ModelCache - Updated bullet to v2.83.6 - Updated to RoboVM 1.9, for free life-time license read http://www.badlogicgames.com/wordpress/?p=3762 [1.7.0] - Gdx.input.setCursorImage removed, replaced with Gdx.graphics.setCursor and Gdx.graphics.newCursor see https://github.com/libgdx/libgdx/pull/2841/ - Fixed an issue with UTF8 decoding in GWT emulation of InputStreamReader - Updated to RoboVM 1.8 for iOS 9 support. [1.6.5] - Objects from animated tiles in TMX maps are now supported. - Made possible to use any actor for tooltips. - Improved cross-platform reflection api for annotations. - NinePatch#scale now also scales middle patch size. - GLFrameBuffer is now abstract, renamed setupTexture to createColorTexture, added disposeColorTexture - Added LwjglApplicationConfiguration#gles30Context*Version, see https://github.com/libgdx/libgdx/pull/2941 - Added OpenGL error checking to GLProfiler, see https://github.com/libgdx/libgdx/pull/2889 - Updated to RoboVM 1.6 [1.6.4] - TextField cursor and selection size changed. https://github.com/libgdx/libgdx/commit/2a830dea348948d2a37bd8f6338af2023fec9b09 - FreeTypeFontGenerator setting to improve shadows and borders. - ScrollPane scrolls smoothly when the scrolled area is much larger than the scrollbars. - TexturePacker sorts page regions by name. - GlyphLayout text wrapping changed to not trim whitespace. https://github.com/libgdx/libgdx/commit/ee42693da067da7c5ddd747f051c1423d262cb96 - Fixed BitmapFont computing space width incorrectly when padding is used and no space glyph is in the font. - Fixed TextArea cursor and selection drawing positions. - Fixed ActorGestureListener pan and zoom when the actor is rotated or scaled. - Fixed TextField for non-pixel display. - Allow ellipsis string to be set on Label. - AssetManager gets hook for handling loading failure. - TextField now fires a ChangeEvent when the text change. Can be cancelled too! - Added tooltips to scene2d.ui. - Updated to RoboVM 1.5 [1.6.3] - Updated to RoboVM 1.4 [1.6.2] - API Change: TiledMapImageLayer now uses floats instead of ints for positioning - API Change: Added GLFrameBuffer and FrameBufferCubemap: Framebuffer now extends GLFramebuffer, see #2933 [1.6.1] - Added optional hostname argument to Net.newServerSocket method to allow specific ip bindings for server applications made with gdx. - Changed the way iOS native libs are handled. Removed updateRoboVMXML and copyNatives task from ios/build.gradle. Instead natives are now packaged in jars, within the META-INF/robovm/ios folder. Additionally, a robovm.xml file is stored there that gets merged with the project's robovm.xml file by RoboVM. [1.6.0] - API Change: GlyphLayout xAdvances now have an additional entry at the beginning. This was required to implement tighter text bounds. #3034 - API Change: Label#getTextBounds changed to getGlyphLayout. This exposes all the runs, not just the width and height. - In the 2D ParticleEditor, all chart points can be dragged at once by holding ctrl. They can be dragged proportionally by holding ctrl-shift. - Added Merge button to the 2D ParticleEditor, for merging a loaded particle effect file with the currently open particle effect. - Added ability to retrieve method annotations to reflection api - Added PixmapPacker.updateTextureRegions() method. - Added ability to pack "anonymous" pixmaps into PixmapPacker, which will appear in the generated texture but not a generated or updated TextureAtlas - Added PixmapPacker.packDirectToTexture() methods. - API Change: PixmapPacker.generateTextureAtlas(...) now returns an atlas which can be updated with subsequent calls to PixmapPacker.updateTextureAtlas(...) - API Change: FreeTypeFontGenerator.generateFont(...) now works with a user-provided PixmapPacker. - Added DirectionalLightsAttribute, PointLightsAttribute and SpotLightsAttribute, removed Environment#directionalLights/pointLights/spotLights, added Environment#remove, lights are now just like any other attribute. See also https://github.com/libgdx/libgdx/wiki/Material-and-environment#lights - API Change: BitmapFont metrics now respect padding. #3074 - Update bullet wrapper to v2.83 - Added AnimatedTiledMapTile.getFrameTiles() method [1.5.6] - API Change: Refactored Window. https://github.com/libgdx/libgdx/commit/7d372b3c67d4fcfe4e82546b0ad6891d14d03242 - Added VertexBufferObjectWithVAO, see https://github.com/libgdx/libgdx/pull/2527 - API Change: Removed Mesh.create(...), use MeshBuilder instead - API Change: BitmapFontData, BitmapFont, and BitmapFontCache have been refactored. http://www.badlogicgames.com/wordpress/?p=3658 - FreeTypeFontGenerator can now render glyphs on the fly. - Attribute now implements Comparable, custom attributes might need to be updated, see: https://github.com/libgdx/libgdx/wiki/Material-and-environment#custom-attributes - API Change: Removed (previously deprecated) GLTexture#createTextureData/createGLHandle, Ray#getEndPoint(float), Color#tmp, Node#parent/children, VertexAttribute#Color(), Usage#Color, ModelBuilder#createFromMesh, BoundingBox#getCenter()/updateCorners()/getCorners(), Matrix4.tmp [1.5.5] - Added iOS ARM-64 bit support for Bullet physics - 3D Animation, NodeAnimation keyframes are separated into translation, rotation and scaling - Added capability to enable color markup from inside skin json file. - Exposed method ControllerManager#clearListeners on Controllers class - Net#openURI now returns a boolean to indicate whether the uri was actually opened. - DefaultShader now always combines material and environment attributes - Added ShapeRenderer constructor to pass a custom shader program to ImmediateModeRenderer20. - API Change: Group#toString now returns actor hierarchy. Group#print is gone. - Added SpotLight class, see https://github.com/libgdx/libgdx/pull/2907 - Added support for resolving file handles using classpaths (ClasspathFileHandleResolver) [1.5.4] - Added support for image layers in Tiled maps (TiledMapImageLayer) - Added support for loading texture objects from TMX Maps (TextureMapObject) - Added support for border and shadow with FreeTypeFontGenerator - see https://github.com/libgdx/libgdx/pull/2774 - Now unknown markup colors are silently ignored and considered as normal text. - Updated freetype from version 2.4.10 to 2.5.5 - Added 3rd party extensions to setup application, see - Updated to RoboVM 1.0.0-beta-04 - Updated to GWT 2.6.1, sadly GWT 2.7.0 isn't production ready yet. [1.5.3] - API Change: TextField#setRightAlign -> TextField#setAlignment - I18NBundle is now compatible with Android 2.2 - Fixed GWT reflection includes for 3D particles - 3D ParticleEffectLoader registered by default - Added HttpRequestBuilder, see https://github.com/libgdx/libgdx/pull/2698 - Added LwjglApplicationConfiguration.useHDPI for Mac OS X with retina displays. Allows you to get "real" pixel coordinates for mouse and display coordinates. - Updated RoboVM to 1.0.0-beta-03 [1.5.2] - Fixed issue #2433 with color markup and alpha animation. - Fixed natives loading for LWJGL on Mac OS X [1.5.1] - Gradle updated to 2.2 - Android Gradle tooling updated to 1.0.0 - API Change: Switched from Timer to AnimationScheduler for driving main loop on GWT. Removed fps field from GwtApplicationConfiguration to instead let the browser choose the most optimal rate. - API Change: Added pause and resume handling on GWT backend. When the browser supports the page visibility api, pause and resume will be called when the tab or window loses and gains visibility. - API Change: Added concept of target actor, separate from the actor the action is added to. This allows an action to be added to one actor but affect another. This is useful to create a sequence of actions that affect many different actors. Previously this would require adding actions to each actor and using delays to get them to play in the correct order. - Added 64-bit support for iOS sim and device - Deprecated Node#children and Node#parent, added inheritTransform flag and methods to add/get/remove children - API Change: By default keyframes are no longer copied from Model to ModelInstance but shared instead, can be changed using the `ModelInstance.defaultShareKeyframes` flag or `shareKeyframes` constructor argument. - JSON minimal format now makes commas optional: newline can be used in place of any comma. - JSON minimal format is now more lenient with unquoted strings: spaces and more are allowed. - API Change: Added support for KTX/ZKTX file format, https://github.com/libgdx/libgdx/pull/2431 - Update stb_image from v1.33 to v1.48, see https://github.com/libgdx/libgdx/pull/2668 - Bullet Wrapper: added Gimpact, see https://github.com/libgdx/libgdx/issues/2619 - API Addition: Added MeshPartBuilder#addMesh(...), can be used to more easily combine meshes/models - Update to LWJGL 2.9.2, fixes fullscreen mode on "retina" displays - Fixes to RoboVM backend which would crash if accelerometer is used. [1.5.0] - API Addition: IOSInput now uses CMCoreMotion for accelerometer and magnetometer - API Addition: Added getter for UITextField on IOS for keyboard customization - API Addition: Added ability to save PixmapPackers to atlas files. See PixmapPackerIO. - API Addition: Added HttpRequestHeader and HttpResponseHeader with constants for HTTP headers. - API Addition: HttpRequest is now poolable. - New PNG encoder that supports compression, more efficient vertical flipping, and minimal allocation when encoding multiple PNGs. - API Change: Label#setEllipse -> Label#setEllipsis. - API Change: BatchTiledMapRenderer *SpriteBatch fields and methods renamed to *Batch - API Change: ScrollPane#scrollToCenter -> ScrollPane#scrollTo; see optional boolean arguments centerHorizontal and centerVertical (scrollToCenter centered vertically only). - API Change: Changed Input#getTextInput to accept both text and hint, removed Input#getPlaceholderTextInput. - Bug Fix: Fixed potential NPE with immersive mode in the Android fragment backend. - iOS backend now supports sound ids, thanks Tomski! [1.4.1] - Update to the Gradle Integration plugin nightly build if you are on Eclipse 4.4.x! - Update Intellij IDEA to 13.1.5+, because Gradle! - Updated to Gradle 2.1 and Android build tools 20, default Android version to 20. You need to install the latest Android build tools via the SDK manager - API Change: deprecation of bounding box methods, see https://github.com/libgdx/libgdx/pull/2408 - Added non-continuous rendering to iOS backend, thanks Dominik! - Setup now uses Gradle 2.1 with default Android API level 20, build tools 20.0.0 - Non-continuous renderering implemented for iOS - Added color markup support for scene2d label and window title. - API Change: removed default constructor of DecalBatch, removed DefaultGroupStrategy - Updated to latests RoboVM release, 1.0.0-alpha-04, please update your RoboVM plugins/installations - Reduced I18NBundle loading times on Android and bypassed unclosed stream on iOS. - Removed the gdx-ai extension from the libGDX repository. Now it lives in its own repository under the libGDX umbrella, see https://github.com/libgdx/gdx-ai - API Addition: Added randomSign and randomTriangular methods to MathUtils. - API Addition: Decal has now a getter for the Color. - API Addition: now I18NBundle can be set so that no exception is thrown when the key can not be found. - API Addition: added annotation support in reflection layer, thanks code-disaster! https://github.com/libgdx/libgdx/pull/2215 - API Addition: shapes like Rect, Circle etc. now implement Shape2D interface so you can put them all into a single collection https://github.com/libgdx/libgdx/pull/2178 - API Addition: bitmap fonts can now be loaded from an atlas via AssetManager/BitmapFontLoader, see https://github.com/libgdx/libgdx/pull/2110 - API Change: updated to RoboVM 1.0.0-SNAPSHOT for now until the next alpha is released. - API Change: Table now uses padding from its background drawable by default. https://github.com/libgdx/libgdx/issues/2322 - Drawables now know their names, making debugging easier. - API Change: Table fill now respects the widget's minimum size. - Texture packer, fixed image size written to atlas file. - API Change: Cell no longer uses primitive wrappers in public API and boxing is minimized. - API Addition: TextureAttribute now supports uv transform (texture regions). - API Change: Added parameters to Elastic Interpolation. - API Change: Removed Actor#setCenterPosition, added setPosition(x,y,align). - API Change: JsonReader, forward slash added to characters an unquoted strings cannot start with. - API Change: Stage#cancelTouchFocus(EventListener,Actor) changed to cancelTouchFocusExcept. - API Change: Json/JsonWriter.setQuoteLongValues() quotes Long, BigDecimal and BigInteger types to prevent truncation in languages like JavaScript and PHP. [1.3.1] - API change: Viewport refactoring. https://github.com/libgdx/libgdx/pull/2220 - Fixed GWT issues [1.3.0] - Added Input.isKeyJustPressed. - API Addition: multiple recipients are now supported by MessageDispatcher, see https://github.com/libgdx/libgdx/wiki/Message-Handling#multiple-recipients - API Change: State#onMessage now takes the message receiver as argument. - API Addition: added StackStateMachine to the gdx-ai extension. - API change: ShapeRenderer: rect methods accept scale, more methods can work under both line and fill types, auto shape type changing. - API change: Built-in ShapeRenderer debugging for Stage, see https://github.com/libgdx/libgdx/pull/2011 - Files#getLocalStoragePath now returns the actual path instead of the empty string synonym on desktop (LWJGL and JGLFW). - Fixed and improved xorshift128+ PRNG implementation. - Added support for Tiled's animated tiles, and varying frame duration tile animations. - Fixed an issue with time granularity in MessageDispatcher. - Updated to Android API level 19 and build tools 19.1.0 which will require the latest Eclipse ADT 23.02, see http://stackoverflow.com/questions/24437564/update-eclipse-with-android-development-tools-23 for how things are broken this time... - Updated to RoboVM 0.0.14 and RoboVM Gradle plugin version 0.0.10 - API Addition: added FreeTypeFontLoader so you can transparently load BitmapFonts generated through gdx-freetype via AssetManager, see https://github.com/libgdx/libgdx/blob/master/tests/gdx-tests/src/com/badlogic/gdx/tests/FreeTypeFontLoaderTest.java - Preferences put methods now return "this" for chaining - Fixed issue 2048 where MessageDispatcher was dispatching delayed messages immediately. - API Addition: 3d particle system and accompanying editor, contributed by lordjone, see https://github.com/libgdx/libgdx/pull/2005 - API Addition: extended shape classes like Circle, Ellipse etc. with hashcode/equals and other helper methods, see https://github.com/libgdx/libgdx/pull/2018 - minor API change (will not increase minor revision number): fixed a bug in handling of atlasPrefixes, https://github.com/libgdx/libgdx/pull/2023 - Bullet: btManifoldPoint member getters/setters changed from btVector3 to Vector3, also it is no longer pooled, instead static instances are used for callback methods - Added Intersector#intersectRayRay to detect if two 2D rays intersect, see https://github.com/libgdx/libgdx/pull/2132 - Bullet: ClosestRayResultCallback, AllHitsRayResultCallback, LocalConvexResult, ClosestConvexResultCallback and subclasses now use getter/setters taking a Vector3 instead of btVector3, see https://github.com/libgdx/libgdx/pull/2176 - 2d particle system supports pre-multiplied alpha. - Bullet: btIDebugDrawer/DebugDrawer now use pooled Vector3 instances instead of btVector3, see https://github.com/libgdx/libgdx/issues/2174 [1.2.0] - API Addition: Some OpenGL profiling utilities have been added, see https://github.com/libgdx/libgdx/wiki/Profiling - API Addition: A FreeTypeFontGeneratorLoader has been added to the gdx-freetype extension - API change: Animation#frameDuration and #animationDuration are now hidden behind a getter/setter and dynamic - API Addition: Vector#setZero - API Addition: gdx-ai, extension for AI algorithms. Currently supports FSMs, see https://github.com/libgdx/libgdx/wiki/Artificial-Intelligence - API change: TableLayout has been forked and integrated into libgdx more tightly, see http://www.badlogicgames.com/wordpress/?p=3458 - API Addition: added equals/hashCode methods to Rectangle, may break old code (very, very unlikely) - API Addition: scene2D Actors now have a setCenterPosition method, see https://github.com/libgdx/libgdx/pull/2000 [1.1.0] - Updated to RoboVM 0.0.13 and RoboVM Gradle plugin 0.0.9 - Big improvements to setup-ui and build times in Intellij IDEA https://github.com/libgdx/libgdx/pull/1865 - Setup now uses android build tools version: 19.1.0 - BitmapFontCache now supports in-string colored text through a simple markup language, see https://github.com/libgdx/libgdx/wiki/Color-Markup-Language - Added i18n localization/internationalization support, thanks davebaol, see https://github.com/libgdx/libgdx/wiki/Internationalization-and-Localization - Possibility to override density on desktop to simulate mobile devices, see https://github.com/libgdx/libgdx/pull/1825 - Progressive JPEG support through JPGD (https://code.google.com/p/jpeg-compressor/). - Mavenized JGLFW backend - Box2D: Added MotorJoint and ghost vertices on EdgeShape - Updated GWT Box2D to latest version - Updated native Box2D to latest version 2.3.1, no API changes - API change: Matrix4.set(x,y,z, translation) changed, z axis is no more flipped - API addition: Matrix4.avg(Matrix4[],float[]) that lets weighted averaging multiple matrices, Quaternion.slerp(Quaternion[],float[]) that lets weighted slerping multiple Quaternions - fixed the long standing issue of the alpha=1 not actually being fully opaque, thanks kalle! https://github.com/libgdx/libgdx/issues/1815 - down to 25 issues on the tracker, 8 bugs, 17 enhancement requests :) [1.0.1] - updated to RoboVM 0.12 (and so should you!) - fixed GC issues on iOS with regards to touch (thanks Niklas!), see https://github.com/libgdx/libgdx/pull/1758 - updated gwt gradle plugin to 0.4, android build tools to 0.10, gradle version to 1.11 - Tiled maps are now always y-up - Tiled maps now support drawing offsets for tiles - FileHandle#list is now supported in GWT! - FileHandle#list now supports FileFilters - Controllers now reinitialize on the desktop when switching between windowed/fullscreen - added a Texture unpacker that will extract all images from a texture atlas, see https://github.com/libgdx/libgdx/pull/1774 - updates to gdx-setup - CustomCollisionDispatcher in bullet, see https://github.com/libgdx/libgdx/commit/916fc85cecf433c3461b458e00f8afc516ad21e3 [1.0.0] - Box2D is no longer in the core, it has been moved to an extension. See http://www.badlogicgames.com/wordpress/?p=3404 - Merged gdx-openal project into gdx-backend-lwjgl - Now LoadedCallback in AssetLoaderParameters is always called after loading an asset from AssetManager, even if the asset is already loaded - Added Payload as a new parameter to Source.dragStop, see https://github.com/libgdx/libgdx/pull/1666 - You can now load PolygonRegions via AssetLoader, see https://github.com/libgdx/libgdx/pull/1602 - implemented software keyboard support in RoboVM iOS backend - Fixed an issue where key event timestamp is not set by the android backend. - scene2d.ui, added to TextArea the preferred number of rows used to calculate the preferred height. - scene2d.actions, fixed infinite recursion for event listener's handle(event). - Various Quaternion changes. - scene2d.ui, fixed a drawing issue with knobBefore when there's no knob (typical progress bar). - Various MeshBuilder fixes and additions. - Math package: added cumulative distribution. - Fixed Music isPlaying() on iOS when is paused. - Added support for C-style comments to JsonReader (mainly used for json skin files). - Support for resource removal from Skin objects. - Added fling gesture to generate fling in scrollpane. - Vector classes now have mulAdd method for adding pre-multiplied values - Vector implementations no longer use squared value for margin comparisons, see: isZero(float margin), isUnit(float margin). - Vector2 now has isUnit and isZero methods (copied from Vector3) - Removed deprecated methods from Vector classes. - Added new headless backend for server applications - Support 'scaledSize' as a json skin data value for BitmapFont - Added setAlpha(float a) method to Sprite class - Added Input.Keys.toString(int keycode) and Input.Keys.valueOf(String keyname) methods - Added Immersive Mode support to Android backend - Added userObject to Actor in scene2d, allowing for custom data storage - Altered Android's hide status bar behavior - Changed the way wakelocks are implemented. You no longer need any special permissions for the libgdx wakelock - BitmapFontCache setColor changes to match SpriteBatch and friends. http://www.badlogicgames.com/forum/viewtopic.php?f=23&t=12112 - Changed ParticleEffect: the ParticleEffect.save method now takes a Writer instead of a File - TexturePacker2 renamed to TexturePacker, added grid and scaling settings. - Added support for custom prefrences on the desktop backends. - Fixed double resume calls on iOS. - Android Music no longer throws exceptions if MediaPlayer is null. - PolygonSpriteBatch implements Batch. - New scene2d actions: EventAction, CountdownEventAction. - Adds cancelHttpRequest() method to Net interface - Updated GWT/HTML5 Backend to GWT 2.6.0 - Minimal Android version is 2.2, see http://www.badlogicgames.com/wordpress/?p=3297 - Updated to LWJGL 2.9.1 - Can now embed your libgdx app as a fragment, more info on the wiki - scene2d.ui, renamed Actor methods translate, rotate, scale, size to moveBy, rotateBy, scaleBy, sizeBy. May have conflicts with Actions static import, eg you'll need to use "Actions.moveBy" - scene2d.ui, Table background is now drawn usign the table's transform - scene2d.ui, added Container which is similar to a Table with one cell, but more lightweight - Added texture filters and mip map generation to BitMapFontLoader and FreeTypeFontGenerator - scene2d.ui, VerticalGroup and HorizontalGroup got pad, fill and an API similar to Table/Container - Removed OpenGL ES 1.0, 1.1 support; see http://www.badlogicgames.com/wordpress/?p=3311 - Added OpenGL ES 3 support - Updated Android backend, demos, tests to 4.4 - Added Viewport, changed Stage to have a Viewport instead of a Camera (API change, see http://www.badlogicgames.com/wordpress/?p=3322 ). - Changed play mode constants of Animation class to enumeration, see http://www.badlogicgames.com/wordpress/?p=3330 - Updated to RoboVM 0.0.11 and RoboVM Gradle plugin 0.0.6, see http://www.badlogicgames.com/wordpress/?p=3351 - Updated to Swig 3.0 for Bullet, disabled SIMD on Mac OS X as alignements are broken in Bullet, see https://github.com/libgdx/libgdx/pull/1595 - TextureData can only be Custom or Pixmap; compressed image files are considered custom [0.9.9] - added setCursorImage method to Input interface to support custom mouse cursors on the desktop - removed Xamarin backend, see http://www.badlogicgames.com/wordpress/?p=3213 - added Select class for selecting kth ordered statistic from arrays (see Array.selectRanked() method) - refactored Box2D to use badlogic Arrays instead of java.util.ArrayLists - MipMapGenerator methods now don't take disposePixmap argument anymore - added GLTexture, base class for all textures, encapsulates target (2d, cubemap, ...) - added CubeMap, 6 sided texture - changed TextureData#consumeCompressedData, takes target now - added RoboVM backend jar and native libs (libObjectAL, libgdx, in ios/ folder of distribution) - added RoboVM backend to build - changed Bullet wrapper API, see http://www.badlogicgames.com/wordpress/?p=3150 - changed MusicLoader and SoundLoader to be asynchronous loaders - changed behaviour of Net#sendHttpRequest() so HttpResponseListener#handleHttpResponse() callback is executed in worker thread instead of main thread - added Bresenham2, for drawing lines on an integer 2D grid - added GridPoint2 and GridPoint3, representing integer points in a 2D or 3D grid - added attribute location caching for VertexData/Mesh. Hand vertex attribs to a ShaderProgram, get back int[], pass that to Mesh - added Android x86 builds, removed libandroidgl20.so, it's now build as part of gdx-core for Android - changed method signature on Box2D World#getBodies and World#getJoints, pass in an Array to fill - removed glGetShaderSource from GL20, use ShaderProgram#getVertexShaderSource/getFragmentShaderSource instead - added reflection api - added AsynchExecutor, execute tasks asynchronously. Used for GWT mainly. - removed FileHandle#file(), has no business in there. - removed box2deditor - removed custom typedarrays in gwt backend - added classpath files support for gwt backend (limited) - moved AndroidWallpaperListener to Android Backend - added new VertexAttribute Usage flags, bone weight, tangent, binormal. previously encoded as Usage.Generic. Also added field "unit" to VertexAttribute, used by texture coordinates and bone weights to specify index/unit. - setup-ui template for iOS disables pngcrush, also updated wiki iOS article - add Pixmap#fillTriangle via jni gdx2d_fill_triangle() to fill a triangle based on its vertices. - add asynchronous download with continuous progress feedback to GWT asset preloader, see https://github.com/libgdx/libgdx/pull/409?w=1 - add capability to add/exclude package/classes GWT Reflection system, see https://github.com/libgdx/libgdx/pull/409?w=1 - add updated gdx-tiled-preprocessor, generate one single TextureAtlas for all the specified Tiled maps, see http://www.badlogicgames.com/forum/viewtopic.php?f=17&t=8911 - maps API, add new AtlasTiledMapLoader for loading maps produced by the tiled preprocessor tool - ImageProcessor, TexturePacker2 now accepts BufferedImage objects as input - TexturePacker2 now avoids duplicated aliases - Updated to LWJGL 2.9.0 - refactored JSON API, see http://www.badlogicgames.com/wordpress/?p=2993 - Updated Box2D to the latest trunk. Body#applyXXX methods now take an additional boolean parameter. - TmxMapLoader has a flag in Parameters that lets you specify whether to generate mipmaps - Animation#isAnimationFinished was fixed to behave as per javadocs (ignores looping) - remove GLU interface and implementations. Use Matrix4 et al instead. see http://www.badlogicgames.com/wordpress/?p=2886 - new maps API, see http://www.badlogicgames.com/wordpress/?p=2870 - removed static public tmp Vector2 instances, manage such temporary vars yourself, see http://www.badlogicgames.com/wordpress/?p=2840 - changed Scene2D Group#clear(), see http://www.badlogicgames.com/wordpress/?p=2837 - changed the build system, natives are now fetched from the build server, see http://www.badlogicgames.com/wordpress/?p=2821 - freetype extension supported on iOS, see http://www.badlogicgames.com/wordpress/?p=2819 - changed ShapeRenderer API, see http://www.badlogicgames.com/wordpress/?p=2809 - changed Actions.add to addAction, changed parameter order, and added removeAction, addListener, removeListener - Box2d joints now allow for user data - Changes to Intersector, Circle, Rectangle and BoundingBox for consistency in #overlap, #intersect and #contains methods, see https://github.com/libgdx/libgdx/pull/312 - Removed LwjglApplicationConfiguration CPU sync. Added foreground and background target framerate. - scene2d, no longer use getters/setters internally for Actor x, y, width, height, scalex, scaley and rotation. - Array, detect nested iterator usage and throw exception. - Added getVolume to Music class and Android, IOS and GWT backends - 1381, fixed JSON parsing of longs. In addition to Float, it now parses Long if no decimal point is found. - Changed Array constructors that took an array to have offset and count - scene2d, Actor parentToLocalCoordinates and localToParentCoordinates refactoring, see http://www.badlogicgames.com/forum/viewtopic.php?p=40441#p40441 - scene2d, Action#setActor no longer calls reset if the Action has no pool. This allows non-pooled actions to be add and removed from actors, restarted, and reused. - ScrollBar#setForceOverscroll renamed to setForceScroll, as it affects more than just overscroll. - ArrayMap#addAll renamed to putAll to match the other maps. - Added ObjectSet and IntSet. - Added completion listener to Music. - Added Music#setPan. - Sound#play and Sound#loop on Android now return -1 on failure, to match other backends. - DelegateAction subclasses need to implement delegate() instead of act(). http://www.badlogicgames.com/forum/viewtopic.php?p=43576#p43576 - Added pause and resume methods to Sound. - Changed AssetErrorListener#error to have AssetDescriptor to enable access to parameters of failed asset. - Changed SelectBoxStyle to have ScrollPaneStyle and ListStyle for fully customizing the drop down list. http://www.badlogicgames.com/wordpress/?p=3110 - AssetLoader now takes a FileHandle that is the resolved file name. The AssetLoader no longer has to resolve the file name, so we can prevent it from being resolved twice. - Rewrote EarClippingTriangulator to not allocate (no more Vector2s). - Added ParticleEffectLoader to make AssetManager load ParticleEffects - Added GeometryUtils, more Intersector functions, DelaunayTriangulator, ConvexHull. - Added getBoundingBox to ParticleEffect - EarClippingTriangulator changed to return triangle indices. - PolygonSpriteBatch and friends refactored to use triangle indices. - Added add(T, float), remove(int), remove(T) and clear() methods to BinaryHeap - Bitmap Font changes: - FreeTypeFontGenerator allows you to specify the PixmapPacker now, to create an atlas with many different fonts (see FreeTypePackTest) - BitmapFont, BitmapFontCache and FreeTypeFontGenerator now support fonts with multiple texture pages. (see BitmapFontTest and FreeTypePackTest) - BitmapFontData.imagePath and getImagePath() is depreacted, use imagePaths[] and getImagePath(int) instead - Added two BitmapFont constructors for convenience; no need to specify flip boolean - Added getCache() to BitmapFont, for expert users who wish to use the BitmapFontCache (see BitmapFontTest) - FreeTypeFontGenerator now includes setMaxTextureSize and getMaxTextureSize to cap the generated glyph atlas size (default 1024) - added render-hooks beginRender() and endRender() to BatchTiledMapRenderer - Added panStop to GestureListener interface. - ScissorStack#calculateScissors changed to take viewport, enabling it to work with glViewport. - Added Bits#getAndClear, Bits#getAndSet and Bits#containsAll - Added setX and setY to TextureAtlas.AtlasSprite so it matches expected behavior [0.9.8] - see http://www.badlogicgames.com/wordpress/?p=2791 [0.9.7] - see http://www.badlogicgames.com/wordpress/?p=2664 [0.9.6] - see http://www.badlogicgames.com/wordpress/?p=2513
1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./gdx/res/com/badlogic/gdx.gwt.xml
<?xml version="1.0" encoding="UTF-8"?> <module rename-to="com.badlogic.gdx"> <source path="gdx"> <!-- --> <include name="AbstractGraphics.java"/> <include name="AbstractInput.java"/> <include name="Application.java"/> <include name="ApplicationAdapter.java"/> <include name="ApplicationListener.java"/> <include name="ApplicationLogger.java"/> <include name="Audio.java"/> <include name="Files.java"/> <include name="Game.java"/> <include name="Gdx.java"/> <include name="Graphics.java"/> <include name="Input.java"/> <include name="InputAdapter.java"/> <include name="InputMultiplexer.java"/> <include name="InputProcessor.java"/> <include name="InputProcessorQueue.java"/> <include name="LifecycleListener.java"/> <include name="Net.java"/> <include name="Preferences.java"/> <include name="Screen.java"/> <include name="ScreenAdapter.java"/> <include name="Version.java"/> <!-- assets --> <include name="assets/AssetDescriptor.java"/> <include name="assets/AssetErrorListener.java"/> <include name="assets/AssetLoaderParameters.java"/> <include name="assets/AssetLoadingTask.java"/> <include name="assets/AssetManager.java"/> <include name="assets/RefCountedContainer.java"/> <!-- assets/loaders --> <include name="assets/loaders/AssetLoader.java"/> <include name="assets/loaders/AsynchronousAssetLoader.java"/> <include name="assets/loaders/BitmapFontLoader.java"/> <exclude name="assets/loaders/CubemapLoader.java"/> <!-- relies on KTXTextureData --> <include name="assets/loaders/FileHandleResolver.java"/> <include name="assets/loaders/I18NBundleLoader.java"/> <include name="assets/loaders/ModelLoader.java"/> <include name="assets/loaders/MusicLoader.java"/> <include name="assets/loaders/ParticleEffectLoader.java"/> <include name="assets/loaders/PixmapLoader.java"/> <include name="assets/loaders/ShaderProgramLoader.java"/> <include name="assets/loaders/SkinLoader.java"/> <include name="assets/loaders/SoundLoader.java"/> <include name="assets/loaders/SynchronousAssetLoader.java"/> <include name="assets/loaders/TextureAtlasLoader.java"/> <include name="assets/loaders/TextureLoader.java"/> <!-- Emulated --> <!-- assets/loaders/resolvers --> <include name="assets/loaders/resolvers/AbsoluteFileHandleResolver.java"/> <include name="assets/loaders/resolvers/LocalFileHandleResolver.java"/> <include name="assets/loaders/resolvers/ExternalFileHandleResolver.java"/> <include name="assets/loaders/resolvers/InternalFileHandleResolver.java"/> <include name="assets/loaders/resolvers/ClasspathFileHandleResolver.java"/> <include name="assets/loaders/resolvers/ResolutionFileResolver.java"/> <!-- Emulated --> <!-- audio --> <include name="audio/AudioDevice.java"/> <include name="audio/AudioRecorder.java"/> <include name="audio/Music.java"/> <include name="audio/Sound.java"/> <!-- files --> <include name="files/FileHandle.java"/> <!-- Emulated --> <include name="files/FileHandleStream.java"/> <!-- Emulated --> <!-- graphics --> <include name="graphics/Camera.java"/> <include name="graphics/Color.java"/> <include name="graphics/Colors.java"/> <include name="graphics/Cubemap.java"/> <include name="graphics/CubemapData.java"/> <include name="graphics/Cursor.java"/> <include name="graphics/FPSLogger.java"/> <include name="graphics/GL20.java"/> <include name="graphics/GL30.java"/> <include name="graphics/GL31.java"/> <include name="graphics/GL32.java"/> <include name="graphics/GLCommon.java"/> <include name="graphics/GLTexture.java"/> <include name="graphics/Mesh.java"/> <include name="graphics/OrthographicCamera.java"/> <include name="graphics/PerspectiveCamera.java"/> <include name="graphics/Pixmap.java"/> <!-- Emulated --> <exclude name="graphics/PixmapIO.java"/> <!-- Reason: No DeflaterOutputStream --> <include name="graphics/Texture.java"/> <include name="graphics/Texture3D.java"/> <!-- GLES 3.0 --> <include name="graphics/Texture3DData.java"/> <!-- GLES 3.0 --> <include name="graphics/TextureArray.java"/> <!-- GLES 3.0 --> <include name="graphics/TextureArrayData.java"/> <!-- GLES 3.0 --> <exclude name="graphics/TextureData.java"/> <!-- emulated: TextureData.Factory requires ETC1 --> <include name="graphics/VertexAttribute.java"/> <include name="graphics/VertexAttributes.java"/> <!-- graphics/g2d --> <include name="graphics/g2d/Animation.java"/> <include name="graphics/g2d/Batch.java"/> <include name="graphics/g2d/PolygonBatch.java"/> <include name="graphics/g2d/BitmapFont.java"/> <include name="graphics/g2d/BitmapFontCache.java"/> <include name="graphics/g2d/CpuSpriteBatch.java"/> <include name="graphics/g2d/DistanceFieldFont.java"/> <exclude name="graphics/g2d/Gdx2DPixmap.java"/> <!-- Reason: JNI --> <include name="graphics/g2d/GlyphLayout.java"/> <include name="graphics/g2d/NinePatch.java"/> <include name="graphics/g2d/ParticleEffect.java"/> <!-- Emulated: Not supporting save --> <include name="graphics/g2d/ParticleEffectPool.java"/> <include name="graphics/g2d/ParticleEmitter.java"/> <include name="graphics/g2d/ParticleEmitterBox2D.java"/> <include name="graphics/g2d/PixmapPacker.java"/> <exclude name="graphics/g2d/PixmapPackerIO.java"/> <include name="graphics/g2d/PolygonRegion.java"/> <include name="graphics/g2d/PolygonRegionLoader.java"/> <include name="graphics/g2d/PolygonSprite.java"/> <include name="graphics/g2d/RepeatablePolygonSprite.java"/> <include name="graphics/g2d/PolygonSpriteBatch.java"/> <include name="graphics/g2d/Sprite.java"/> <include name="graphics/g2d/SpriteBatch.java"/> <include name="graphics/g2d/SpriteCache.java"/> <include name="graphics/g2d/TextureAtlas.java"/> <include name="graphics/g2d/TextureRegion.java"/> <!-- graphics/g3d --> <include name="graphics/g3d/Attribute.java"/> <include name="graphics/g3d/Attributes.java"/> <include name="graphics/g3d/Environment.java"/> <include name="graphics/g3d/Material.java"/> <include name="graphics/g3d/Model.java"/> <include name="graphics/g3d/ModelBatch.java"/> <include name="graphics/g3d/ModelCache.java"/> <include name="graphics/g3d/ModelInstance.java"/> <include name="graphics/g3d/Renderable.java"/> <include name="graphics/g3d/RenderableProvider.java"/> <include name="graphics/g3d/Shader.java"/> <!-- graphics/g3d/attributes --> <include name="graphics/g3d/attributes/BlendingAttribute.java"/> <include name="graphics/g3d/attributes/ColorAttribute.java"/> <include name="graphics/g3d/attributes/CubemapAttribute.java"/> <include name="graphics/g3d/attributes/DepthTestAttribute.java"/> <include name="graphics/g3d/attributes/FloatAttribute.java"/> <include name="graphics/g3d/attributes/IntAttribute.java"/> <include name="graphics/g3d/attributes/TextureAttribute.java"/> <include name="graphics/g3d/attributes/DirectionalLightsAttribute.java"/> <include name="graphics/g3d/attributes/PointLightsAttribute.java"/> <include name="graphics/g3d/attributes/SpotLightsAttribute.java"/> <!-- graphics/g3d/decals --> <include name="graphics/g3d/decals/CameraGroupStrategy.java"/> <include name="graphics/g3d/decals/Decal.java"/> <include name="graphics/g3d/decals/DecalBatch.java"/> <include name="graphics/g3d/decals/DecalMaterial.java"/> <include name="graphics/g3d/decals/DefaultGroupStrategy.java"/> <include name="graphics/g3d/decals/GroupPlug.java"/> <include name="graphics/g3d/decals/GroupStrategy.java"/> <include name="graphics/g3d/decals/PluggableGroupStrategy.java"/> <include name="graphics/g3d/decals/SimpleOrthoGroupStrategy.java"/> <!-- graphics/g3d/environment --> <include name="graphics/g3d/environment/AmbientCubemap.java"/> <include name="graphics/g3d/environment/BaseLight.java"/> <include name="graphics/g3d/environment/DirectionalLight.java"/> <include name="graphics/g3d/environment/DirectionalShadowLight.java"/> <include name="graphics/g3d/environment/PointLight.java"/> <include name="graphics/g3d/environment/SpotLight.java"/> <include name="graphics/g3d/environment/ShadowMap.java"/> <include name="graphics/g3d/environment/Sphericalharmonics.java"/> <!-- graphics/g3d/loader --> <include name="graphics/g3d/loader/G3dModelLoader.java"/> <include name="graphics/g3d/loader/ObjLoader.java"/> <!-- graphics/g3d/model --> <include name="graphics/g3d/model/Animation.java"/> <include name="graphics/g3d/model/MeshPart.java"/> <include name="graphics/g3d/model/Node.java"/> <include name="graphics/g3d/model/NodeAnimation.java"/> <include name="graphics/g3d/model/NodeKeyframe.java"/> <include name="graphics/g3d/model/NodePart.java"/> <!-- graphics/g3d/model/data --> <include name="graphics/g3d/model/data/ModelAnimation.java"/> <include name="graphics/g3d/model/data/ModelData.java"/> <include name="graphics/g3d/model/data/ModelMaterial.java"/> <include name="graphics/g3d/model/data/ModelMesh.java"/> <include name="graphics/g3d/model/data/ModelMeshPart.java"/> <include name="graphics/g3d/model/data/ModelNode.java"/> <include name="graphics/g3d/model/data/ModelNodeAnimation.java"/> <include name="graphics/g3d/model/data/ModelNodeKeyframe.java"/> <include name="graphics/g3d/model/data/ModelNodePart.java"/> <include name="graphics/g3d/model/data/ModelTexture.java"/> <!-- graphics/g3d/particles --> <include name="graphics/g3d/particles/**/*.java"/> <!-- graphics/g3d/shaders --> <include name="graphics/g3d/shaders/BaseShader.java"/> <include name="graphics/g3d/shaders/DefaultShader.java"/> <include name="graphics/g3d/shaders/DepthShader.java"/> <include name="graphics/g3d/shaders/GLES10Shader.java"/> <!-- graphics/g3d/utils --> <include name="graphics/g3d/utils/AnimationController.java"/> <include name="graphics/g3d/utils/BaseAnimationController.java"/> <include name="graphics/g3d/utils/BaseShaderProvider.java"/> <include name="graphics/g3d/utils/CameraInputController.java"/> <include name="graphics/g3d/utils/DefaultRenderableSorter.java"/> <include name="graphics/g3d/utils/DefaultShaderProvider.java"/> <include name="graphics/g3d/utils/DefaultTextureBinder.java"/> <include name="graphics/g3d/utils/DepthShaderProvider.java"/> <include name="graphics/g3d/utils/FirstPersonCameraController.java"/> <include name="graphics/g3d/utils/MeshBuilder.java"/> <include name="graphics/g3d/utils/MeshPartBuilder.java"/> <include name="graphics/g3d/utils/ModelBuilder.java"/> <include name="graphics/g3d/utils/RenderableSorter.java"/> <include name="graphics/g3d/utils/RenderContext.java"/> <include name="graphics/g3d/utils/ShaderProvider.java"/> <include name="graphics/g3d/utils/ShapeCache.java"/> <include name="graphics/g3d/utils/TextureBinder.java"/> <include name="graphics/g3d/utils/TextureDescriptor.java"/> <include name="graphics/g3d/utils/TextureProvider.java"/> <!-- graphics/g3d/utils/shapebuilders --> <include name="graphics/g3d/utils/shapebuilders/ArrowShapeBuilder.java"/> <include name="graphics/g3d/utils/shapebuilders/BaseShapeBuilder.java"/> <include name="graphics/g3d/utils/shapebuilders/BoxShapeBuilder.java"/> <include name="graphics/g3d/utils/shapebuilders/CapsuleShapeBuilder.java"/> <include name="graphics/g3d/utils/shapebuilders/ConeShapeBuilder.java"/> <include name="graphics/g3d/utils/shapebuilders/CylinderShapeBuilder.java"/> <include name="graphics/g3d/utils/shapebuilders/EllipseShapeBuilder.java"/> <include name="graphics/g3d/utils/shapebuilders/FrustumShapeBuilder.java"/> <include name="graphics/g3d/utils/shapebuilders/PatchShapeBuilder.java"/> <include name="graphics/g3d/utils/shapebuilders/RenderableShapeBuilder.java"/> <include name="graphics/g3d/utils/shapebuilders/SphereShapeBuilder.java"/> <!-- graphics/glutils --> <include name="graphics/glutils/CustomTexture3DData.java"/> <!-- GLES 3.0 --> <exclude name="graphics/glutils/ETC1.java"/> <!-- Reason: No ETC1 Support --> <include name="graphics/glutils/ETC1TextureData.java"/> <!-- Emulated: explodes on construction --> <include name="graphics/glutils/FacedCubemapData.java"/> <include name="graphics/glutils/FileTextureArrayData.java"/> <!-- GLES 3.0 --> <include name="graphics/glutils/FileTextureData.java"/> <!-- Emulated: No PixmapIO --> <include name="graphics/glutils/FloatFrameBuffer.java"/> <include name="graphics/glutils/FloatTextureData.java"/> <include name="graphics/glutils/FrameBuffer.java"/> <include name="graphics/glutils/FrameBufferCubemap.java"/> <include name="graphics/glutils/GLFrameBuffer.java"/> <include name="graphics/glutils/GLOnlyTextureData.java"/> <include name="graphics/glutils/GLVersion.java"/> <include name="graphics/glutils/HdpiMode.java"/> <include name="graphics/glutils/HdpiUtils.java"/> <include name="graphics/glutils/ImmediateModeRenderer.java"/> <include name="graphics/glutils/ImmediateModeRenderer10.java"/> <include name="graphics/glutils/ImmediateModeRenderer20.java"/> <include name="graphics/glutils/IndexArray.java"/> <!-- Emulated --> <include name="graphics/glutils/IndexBufferObject.java"/> <!-- Emulated --> <include name="graphics/glutils/IndexBufferObjectSubData.java"/> <include name="graphics/glutils/IndexData.java"/> <include name="graphics/glutils/InstanceData.java"/> <include name="graphics/glutils/InstanceBufferObject.java"/> <!-- Emulated --> <exclude name="graphics/glutils/KTXTextureData.java"/> <!-- Rely on ETC1 --> <include name="graphics/glutils/MipMapGenerator.java"/> <include name="graphics/glutils/PixmapTextureData.java"/> <include name="graphics/glutils/ShaderProgram.java"/> <include name="graphics/glutils/ShapeRenderer.java"/> <include name="graphics/glutils/VertexArray.java"/> <!-- Emulated --> <include name="graphics/glutils/VertexBufferObject.java"/> <!-- Emulated --> <include name="graphics/glutils/VertexBufferObjectSubData.java"/> <include name="graphics/glutils/VertexBufferObjectWithVAO.java"/> <!-- Emulated --> <include name="graphics/glutils/VertexData.java"/> <!-- graphics/profiling --> <include name="graphics/profiling/GL20Interceptor.java"/> <include name="graphics/profiling/GL30Interceptor.java"/> <include name="graphics/profiling/GL31Interceptor.java"/> <include name="graphics/profiling/GL32Interceptor.java"/> <include name="graphics/profiling/GLInterceptor.java"/> <include name="graphics/profiling/GLProfiler.java"/> <include name="graphics/profiling/GLErrorListener.java"/> <!-- Emulated --> <!-- input --> <include name="input/GestureDetector.java"/> <exclude name="input/RemoteInput.java"/> <!-- Reason: Networking --> <exclude name="input/RemoteSender.java"/> <!-- Reason: Networking --> <!-- maps --> <include name="maps/ImageResolver.java"/> <include name="maps/Map.java"/> <include name="maps/MapLayer.java"/> <include name="maps/MapGroupLayer.java"/> <include name="maps/MapLayers.java"/> <include name="maps/MapObject.java"/> <include name="maps/MapObjects.java"/> <include name="maps/MapProperties.java"/> <include name="maps/MapRenderer.java"/> <!-- maps/objects --> <include name="maps/objects/CircleMapObject.java"/> <include name="maps/objects/EllipseMapObject.java"/> <include name="maps/objects/PolygonMapObject.java"/> <include name="maps/objects/PolylineMapObject.java"/> <include name="maps/objects/RectangleMapObject.java"/> <include name="maps/objects/TextureMapObject.java"/> <!-- maps/tiled --> <include name="maps/tiled/AtlasTmxMapLoader.java"/> <include name="maps/tiled/BaseTmxMapLoader.java"/> <include name="maps/tiled/TideMapLoader.java"/> <include name="maps/tiled/TiledMap.java"/> <include name="maps/tiled/TiledMapRenderer.java"/> <include name="maps/tiled/TiledMapTile.java"/> <include name="maps/tiled/TiledMapTileLayer.java"/> <include name="maps/tiled/TiledMapTileSet.java"/> <include name="maps/tiled/TiledMapTileSets.java"/> <include name="maps/tiled/TiledMapImageLayer.java"/> <include name="maps/tiled/TmxMapHelper.java"/> <include name="maps/tiled/TmxMapLoader.java"/> <!-- maps/tiled/renderers --> <include name="maps/tiled/renderers/BatchTiledMapRenderer.java"/> <include name="maps/tiled/renderers/HexagonalTiledMapRenderer.java"/> <include name="maps/tiled/renderers/IsometricStaggeredTiledMapRenderer.java"/> <include name="maps/tiled/renderers/IsometricTiledMapRenderer.java"/> <include name="maps/tiled/renderers/OrthoCachedTiledMapRenderer.java"/> <include name="maps/tiled/renderers/OrthogonalTiledMapRenderer.java"/> <!-- maps/tiled/tiles --> <include name="maps/tiled/tiles/AnimatedTiledMapTile.java"/> <include name="maps/tiled/tiles/StaticTiledMapTile.java"/> <!-- maps/tiled/objects --> <include name="maps/tiled/objects/TiledMapTileMapObject.java"/> <!-- math --> <include name="math/Affine2.java"/> <include name="math/Bezier.java"/> <include name="math/Bresenham2.java"/> <include name="math/BSpline.java"/> <include name="math/CatmullRomSpline.java"/> <include name="math/Circle.java"/> <include name="math/ConvexHull.java"/> <include name="math/CumulativeDistribution.java"/> <include name="math/DelaunayTriangulator.java"/> <include name="math/EarClippingTriangulator.java"/> <include name="math/Ellipse.java"/> <include name="math/FloatCounter.java"/> <include name="math/Frustum.java"/> <include name="math/GeometryUtils.java"/> <include name="math/GridPoint2.java"/> <include name="math/GridPoint3.java"/> <include name="math/Interpolation.java"/> <include name="math/Intersector.java"/> <include name="math/MathUtils.java"/> <include name="math/Matrix3.java"/> <include name="math/Matrix4.java"/> <!-- Emulated: JNI --> <include name="math/Octree.java"/> <include name="math/Path.java"/> <include name="math/Plane.java"/> <include name="math/Polygon.java"/> <include name="math/Polyline.java"/> <include name="math/Quaternion.java"/> <include name="math/RandomXS128.java"/> <include name="math/Rectangle.java"/> <include name="math/Shape2D.java"/> <include name="math/Vector.java"/> <include name="math/Vector2.java"/> <include name="math/Vector3.java"/> <include name="math/WindowedMean.java"/> <!-- math/collision --> <include name="math/collision/BoundingBox.java"/> <include name="math/collision/OrientedBoundingBox.java"/> <include name="math/collision/Ray.java"/> <include name="math/collision/Segment.java"/> <include name="math/collision/Sphere.java"/> <!-- net --> <include name="net/HttpParametersUtils.java"/> <include name="net/HttpStatus.java"/> <exclude name="net/NetJavaImpl.java"/> <!-- Reason: Networking --> <exclude name="net/NetJavaServerSocketImpl.java"/> <!-- Reason: Networking --> <exclude name="net/NetJavaSocketImpl.java"/> <!-- Reason: Networking --> <include name="net/ServerSocket.java"/> <include name="net/ServerSocketHints.java"/> <include name="net/Socket.java"/> <include name="net/SocketHints.java"/> <include name="net/HttpRequestBuilder.java"/> <!-- physics/box2d --> <!-- Box2d is fully emulated in GWT backend --> <!-- physics/box2d/joints --> <!-- Box2d is fully emulated in GWT backend --> <!-- scenes/scene2d --> <include name="scenes/scene2d/**/*.java"/> <!-- utils --> <include name="utils/Align.java"/> <include name="utils/Array.java"/> <!-- Emulated: Reflection --> <include name="utils/ArrayMap.java"/> <!-- Emulated: Reflection --> <include name="utils/AtomicQueue.java"/> <include name="utils/Base64Coder.java"/> <include name="utils/BaseJsonReader.java"/> <include name="utils/BinaryHeap.java"/> <include name="utils/Bits.java"/> <include name="utils/BooleanArray.java"/> <include name="utils/BufferUtils.java"/> <!-- Emulated --> <include name="utils/ByteArray.java"/> <include name="utils/CharArray.java"/> <include name="utils/Clipboard.java"/> <include name="utils/Collections.java"/> <include name="utils/ComparableTimSort.java"/> <include name="utils/DataInput.java"/> <include name="utils/DataOutput.java"/> <include name="utils/DelayedRemovalArray.java"/> <include name="utils/Disposable.java"/> <include name="utils/FloatArray.java"/> <include name="utils/FlushablePool.java"/> <exclude name="utils/GdxNativesLoader.java"/> <!-- Reason: Natives --> <include name="utils/GdxRuntimeException.java"/> <include name="utils/I18NBundle.java"/> <include name="utils/IdentityMap.java"/> <include name="utils/IntArray.java"/> <include name="utils/IntFloatMap.java"/> <include name="utils/IntIntMap.java"/> <include name="utils/IntMap.java"/> <include name="utils/IntSet.java"/> <include name="utils/Json.java"/> <include name="utils/JsonReader.java"/> <include name="utils/JsonValue.java"/> <include name="utils/JsonWriter.java"/> <include name="utils/LittleEndianInputStream.java"/> <include name="utils/Logger.java"/> <include name="utils/LongArray.java"/> <include name="utils/LongMap.java"/> <include name="utils/LongQueue.java"/> <include name="utils/NumberUtils.java"/> <!-- Emulated --> <include name="utils/ObjectFloatMap.java"/> <include name="utils/ObjectIntMap.java"/> <include name="utils/ObjectLongMap.java"/> <include name="utils/ObjectMap.java"/> <include name="utils/ObjectSet.java"/> <include name="utils/OrderedMap.java"/> <include name="utils/OrderedSet.java"/> <exclude name="utils/PauseableThread.java"/> <!-- Reason: Threading --> <include name="utils/PerformanceCounter.java"/> <include name="utils/PerformanceCounters.java"/> <include name="utils/Pool.java"/> <include name="utils/PooledLinkedList.java"/> <include name="utils/Pools.java"/> <include name="utils/Predicate.java"/> <include name="utils/PropertiesUtils.java"/> <include name="utils/QuadTreeFloat.java"/> <include name="utils/Queue.java"/> <include name="utils/QuickSelect.java"/> <include name="utils/ReflectionPool.java"/> <include name="utils/Scaling.java"/> <include name="utils/ScreenUtils.java"/> <include name="utils/Select.java"/> <include name="utils/SerializationException.java"/> <!-- Emulated: Reflection --> <exclude name="utils/SharedLibraryLoader.java"/> <!-- Reason: Natives --> <include name="utils/ShortArray.java"/> <include name="utils/SnapshotArray.java"/> <include name="utils/Sort.java"/> <include name="utils/SortedIntList.java"/> <include name="utils/StreamUtils.java"/> <include name="utils/StringBuilder.java"/> <include name="utils/TextFormatter.java"/> <!-- Emulated: MessageFormat --> <include name="utils/Timer.java"/> <!-- Emulated: Threading --> <include name="utils/TimeUtils.java"/> <!-- Emulated: nanoTime() --> <include name="utils/TimSort.java"/> <include name="utils/UBJsonReader.java"/> <include name="utils/UBJsonWriter.java"/> <include name="utils/XmlReader.java"/> <include name="utils/XmlWriter.java"/> <!-- utils/async --> <include name="utils/async/AsyncExecutor.java"/> <!-- Emulated: Threading --> <include name="utils/async/AsyncResult.java"/> <!-- Emulated: Threading --> <include name="utils/async/AsyncTask.java"/> <!-- Emulated: Threading --> <include name="utils/async/ThreadUtils.java"/> <!-- Emulated: Threading --> <!-- utils/compression --> <include name="utils/compression/CRC.java"/> <include name="utils/compression/ICodeProgress.java"/> <include name="utils/compression/Lzma.java"/> <!-- utils/compression/lz --> <include name="utils/compression/lz/BinTree.java"/> <include name="utils/compression/lz/InWindow.java"/> <include name="utils/compression/lz/OutWindow.java"/> <!-- utils/compression/lzma --> <include name="utils/compression/lzma/Base.java"/> <include name="utils/compression/lzma/Decoder.java"/> <include name="utils/compression/lzma/Encoder.java"/> <!-- utils/compression/rangecoder --> <include name="utils/compression/rangecoder/BitTreeDecoder.java"/> <include name="utils/compression/rangecoder/BitTreeEncoder.java"/> <include name="utils/compression/rangecoder/Decoder.java"/> <include name="utils/compression/rangecoder/Encoder.java"/> <!-- utils/reflect --> <include name="utils/reflect/ArrayReflection.java"/> <!-- Emulated --> <include name="utils/reflect/ClassReflection.java"/> <!-- Emulated --> <include name="utils/reflect/Constructor.java"/> <!-- Emulated --> <include name="utils/reflect/Field.java"/> <!-- Emulated --> <include name="utils/reflect/Method.java"/> <!-- Emulated --> <include name="utils/reflect/ReflectionException.java"/> <!-- utils/viewport --> <include name="utils/viewport/**/*.java"/> </source> <define-configuration-property name="gdx.files.classpath" is-multi-valued="true" /> <extend-configuration-property name="gdx.files.classpath" value="com/badlogic/gdx/graphics/g3d/particles/particles.fragment.glsl" /> <extend-configuration-property name="gdx.files.classpath" value="com/badlogic/gdx/graphics/g3d/particles/particles.vertex.glsl" /> <extend-configuration-property name="gdx.files.classpath" value="com/badlogic/gdx/graphics/g3d/shaders/default.fragment.glsl" /> <extend-configuration-property name="gdx.files.classpath" value="com/badlogic/gdx/graphics/g3d/shaders/default.vertex.glsl" /> <extend-configuration-property name="gdx.files.classpath" value="com/badlogic/gdx/graphics/g3d/shaders/depth.fragment.glsl" /> <extend-configuration-property name="gdx.files.classpath" value="com/badlogic/gdx/graphics/g3d/shaders/depth.vertex.glsl" /> <extend-configuration-property name="gdx.files.classpath" value="com/badlogic/gdx/utils/lsans-15.fnt" /> <extend-configuration-property name="gdx.files.classpath" value="com/badlogic/gdx/utils/lsans-15.png" /> </module>
<?xml version="1.0" encoding="UTF-8"?> <module rename-to="com.badlogic.gdx"> <source path="gdx"> <!-- --> <include name="AbstractGraphics.java"/> <include name="AbstractInput.java"/> <include name="Application.java"/> <include name="ApplicationAdapter.java"/> <include name="ApplicationListener.java"/> <include name="ApplicationLogger.java"/> <include name="Audio.java"/> <include name="Files.java"/> <include name="Game.java"/> <include name="Gdx.java"/> <include name="Graphics.java"/> <include name="Input.java"/> <include name="InputAdapter.java"/> <include name="InputMultiplexer.java"/> <include name="InputProcessor.java"/> <include name="InputProcessorQueue.java"/> <include name="LifecycleListener.java"/> <include name="Net.java"/> <include name="Preferences.java"/> <include name="Screen.java"/> <include name="ScreenAdapter.java"/> <include name="Version.java"/> <!-- assets --> <include name="assets/AssetDescriptor.java"/> <include name="assets/AssetErrorListener.java"/> <include name="assets/AssetLoaderParameters.java"/> <include name="assets/AssetLoadingTask.java"/> <include name="assets/AssetManager.java"/> <include name="assets/RefCountedContainer.java"/> <!-- assets/loaders --> <include name="assets/loaders/AssetLoader.java"/> <include name="assets/loaders/AsynchronousAssetLoader.java"/> <include name="assets/loaders/BitmapFontLoader.java"/> <exclude name="assets/loaders/CubemapLoader.java"/> <!-- relies on KTXTextureData --> <include name="assets/loaders/FileHandleResolver.java"/> <include name="assets/loaders/I18NBundleLoader.java"/> <include name="assets/loaders/ModelLoader.java"/> <include name="assets/loaders/MusicLoader.java"/> <include name="assets/loaders/ParticleEffectLoader.java"/> <include name="assets/loaders/PixmapLoader.java"/> <include name="assets/loaders/ShaderProgramLoader.java"/> <include name="assets/loaders/SkinLoader.java"/> <include name="assets/loaders/SoundLoader.java"/> <include name="assets/loaders/SynchronousAssetLoader.java"/> <include name="assets/loaders/TextureAtlasLoader.java"/> <include name="assets/loaders/TextureLoader.java"/> <!-- Emulated --> <!-- assets/loaders/resolvers --> <include name="assets/loaders/resolvers/AbsoluteFileHandleResolver.java"/> <include name="assets/loaders/resolvers/LocalFileHandleResolver.java"/> <include name="assets/loaders/resolvers/ExternalFileHandleResolver.java"/> <include name="assets/loaders/resolvers/InternalFileHandleResolver.java"/> <include name="assets/loaders/resolvers/ClasspathFileHandleResolver.java"/> <include name="assets/loaders/resolvers/ResolutionFileResolver.java"/> <!-- Emulated --> <!-- audio --> <include name="audio/AudioDevice.java"/> <include name="audio/AudioRecorder.java"/> <include name="audio/Music.java"/> <include name="audio/Sound.java"/> <!-- files --> <include name="files/FileHandle.java"/> <!-- Emulated --> <include name="files/FileHandleStream.java"/> <!-- Emulated --> <!-- graphics --> <include name="graphics/Camera.java"/> <include name="graphics/Color.java"/> <include name="graphics/Colors.java"/> <include name="graphics/Cubemap.java"/> <include name="graphics/CubemapData.java"/> <include name="graphics/Cursor.java"/> <include name="graphics/FPSLogger.java"/> <include name="graphics/GL20.java"/> <include name="graphics/GL30.java"/> <include name="graphics/GL31.java"/> <include name="graphics/GL32.java"/> <include name="graphics/GLCommon.java"/> <include name="graphics/GLTexture.java"/> <include name="graphics/Mesh.java"/> <include name="graphics/OrthographicCamera.java"/> <include name="graphics/PerspectiveCamera.java"/> <include name="graphics/Pixmap.java"/> <!-- Emulated --> <exclude name="graphics/PixmapIO.java"/> <!-- Reason: No DeflaterOutputStream --> <include name="graphics/Texture.java"/> <include name="graphics/Texture3D.java"/> <!-- GLES 3.0 --> <include name="graphics/Texture3DData.java"/> <!-- GLES 3.0 --> <include name="graphics/TextureArray.java"/> <!-- GLES 3.0 --> <include name="graphics/TextureArrayData.java"/> <!-- GLES 3.0 --> <exclude name="graphics/TextureData.java"/> <!-- emulated: TextureData.Factory requires ETC1 --> <include name="graphics/VertexAttribute.java"/> <include name="graphics/VertexAttributes.java"/> <!-- graphics/g2d --> <include name="graphics/g2d/Animation.java"/> <include name="graphics/g2d/Batch.java"/> <include name="graphics/g2d/PolygonBatch.java"/> <include name="graphics/g2d/BitmapFont.java"/> <include name="graphics/g2d/BitmapFontCache.java"/> <include name="graphics/g2d/CpuSpriteBatch.java"/> <include name="graphics/g2d/DistanceFieldFont.java"/> <exclude name="graphics/g2d/Gdx2DPixmap.java"/> <!-- Reason: JNI --> <include name="graphics/g2d/GlyphLayout.java"/> <include name="graphics/g2d/NinePatch.java"/> <include name="graphics/g2d/ParticleEffect.java"/> <!-- Emulated: Not supporting save --> <include name="graphics/g2d/ParticleEffectPool.java"/> <include name="graphics/g2d/ParticleEmitter.java"/> <include name="graphics/g2d/ParticleEmitterBox2D.java"/> <include name="graphics/g2d/PixmapPacker.java"/> <exclude name="graphics/g2d/PixmapPackerIO.java"/> <include name="graphics/g2d/PolygonRegion.java"/> <include name="graphics/g2d/PolygonRegionLoader.java"/> <include name="graphics/g2d/PolygonSprite.java"/> <include name="graphics/g2d/RepeatablePolygonSprite.java"/> <include name="graphics/g2d/PolygonSpriteBatch.java"/> <include name="graphics/g2d/Sprite.java"/> <include name="graphics/g2d/SpriteBatch.java"/> <include name="graphics/g2d/SpriteCache.java"/> <include name="graphics/g2d/TextureAtlas.java"/> <include name="graphics/g2d/TextureRegion.java"/> <!-- graphics/g3d --> <include name="graphics/g3d/Attribute.java"/> <include name="graphics/g3d/Attributes.java"/> <include name="graphics/g3d/Environment.java"/> <include name="graphics/g3d/Material.java"/> <include name="graphics/g3d/Model.java"/> <include name="graphics/g3d/ModelBatch.java"/> <include name="graphics/g3d/ModelCache.java"/> <include name="graphics/g3d/ModelInstance.java"/> <include name="graphics/g3d/Renderable.java"/> <include name="graphics/g3d/RenderableProvider.java"/> <include name="graphics/g3d/Shader.java"/> <!-- graphics/g3d/attributes --> <include name="graphics/g3d/attributes/BlendingAttribute.java"/> <include name="graphics/g3d/attributes/ColorAttribute.java"/> <include name="graphics/g3d/attributes/CubemapAttribute.java"/> <include name="graphics/g3d/attributes/DepthTestAttribute.java"/> <include name="graphics/g3d/attributes/FloatAttribute.java"/> <include name="graphics/g3d/attributes/IntAttribute.java"/> <include name="graphics/g3d/attributes/TextureAttribute.java"/> <include name="graphics/g3d/attributes/DirectionalLightsAttribute.java"/> <include name="graphics/g3d/attributes/PointLightsAttribute.java"/> <include name="graphics/g3d/attributes/SpotLightsAttribute.java"/> <!-- graphics/g3d/decals --> <include name="graphics/g3d/decals/CameraGroupStrategy.java"/> <include name="graphics/g3d/decals/Decal.java"/> <include name="graphics/g3d/decals/DecalBatch.java"/> <include name="graphics/g3d/decals/DecalMaterial.java"/> <include name="graphics/g3d/decals/DefaultGroupStrategy.java"/> <include name="graphics/g3d/decals/GroupPlug.java"/> <include name="graphics/g3d/decals/GroupStrategy.java"/> <include name="graphics/g3d/decals/PluggableGroupStrategy.java"/> <include name="graphics/g3d/decals/SimpleOrthoGroupStrategy.java"/> <!-- graphics/g3d/environment --> <include name="graphics/g3d/environment/AmbientCubemap.java"/> <include name="graphics/g3d/environment/BaseLight.java"/> <include name="graphics/g3d/environment/DirectionalLight.java"/> <include name="graphics/g3d/environment/DirectionalShadowLight.java"/> <include name="graphics/g3d/environment/PointLight.java"/> <include name="graphics/g3d/environment/SpotLight.java"/> <include name="graphics/g3d/environment/ShadowMap.java"/> <include name="graphics/g3d/environment/Sphericalharmonics.java"/> <!-- graphics/g3d/loader --> <include name="graphics/g3d/loader/G3dModelLoader.java"/> <include name="graphics/g3d/loader/ObjLoader.java"/> <!-- graphics/g3d/model --> <include name="graphics/g3d/model/Animation.java"/> <include name="graphics/g3d/model/MeshPart.java"/> <include name="graphics/g3d/model/Node.java"/> <include name="graphics/g3d/model/NodeAnimation.java"/> <include name="graphics/g3d/model/NodeKeyframe.java"/> <include name="graphics/g3d/model/NodePart.java"/> <!-- graphics/g3d/model/data --> <include name="graphics/g3d/model/data/ModelAnimation.java"/> <include name="graphics/g3d/model/data/ModelData.java"/> <include name="graphics/g3d/model/data/ModelMaterial.java"/> <include name="graphics/g3d/model/data/ModelMesh.java"/> <include name="graphics/g3d/model/data/ModelMeshPart.java"/> <include name="graphics/g3d/model/data/ModelNode.java"/> <include name="graphics/g3d/model/data/ModelNodeAnimation.java"/> <include name="graphics/g3d/model/data/ModelNodeKeyframe.java"/> <include name="graphics/g3d/model/data/ModelNodePart.java"/> <include name="graphics/g3d/model/data/ModelTexture.java"/> <!-- graphics/g3d/particles --> <include name="graphics/g3d/particles/**/*.java"/> <!-- graphics/g3d/shaders --> <include name="graphics/g3d/shaders/BaseShader.java"/> <include name="graphics/g3d/shaders/DefaultShader.java"/> <include name="graphics/g3d/shaders/DepthShader.java"/> <include name="graphics/g3d/shaders/GLES10Shader.java"/> <!-- graphics/g3d/utils --> <include name="graphics/g3d/utils/AnimationController.java"/> <include name="graphics/g3d/utils/BaseAnimationController.java"/> <include name="graphics/g3d/utils/BaseShaderProvider.java"/> <include name="graphics/g3d/utils/CameraInputController.java"/> <include name="graphics/g3d/utils/DefaultRenderableSorter.java"/> <include name="graphics/g3d/utils/DefaultShaderProvider.java"/> <include name="graphics/g3d/utils/DefaultTextureBinder.java"/> <include name="graphics/g3d/utils/DepthShaderProvider.java"/> <include name="graphics/g3d/utils/FirstPersonCameraController.java"/> <include name="graphics/g3d/utils/MeshBuilder.java"/> <include name="graphics/g3d/utils/MeshPartBuilder.java"/> <include name="graphics/g3d/utils/ModelBuilder.java"/> <include name="graphics/g3d/utils/RenderableSorter.java"/> <include name="graphics/g3d/utils/RenderContext.java"/> <include name="graphics/g3d/utils/ShaderProvider.java"/> <include name="graphics/g3d/utils/ShapeCache.java"/> <include name="graphics/g3d/utils/TextureBinder.java"/> <include name="graphics/g3d/utils/TextureDescriptor.java"/> <include name="graphics/g3d/utils/TextureProvider.java"/> <!-- graphics/g3d/utils/shapebuilders --> <include name="graphics/g3d/utils/shapebuilders/ArrowShapeBuilder.java"/> <include name="graphics/g3d/utils/shapebuilders/BaseShapeBuilder.java"/> <include name="graphics/g3d/utils/shapebuilders/BoxShapeBuilder.java"/> <include name="graphics/g3d/utils/shapebuilders/CapsuleShapeBuilder.java"/> <include name="graphics/g3d/utils/shapebuilders/ConeShapeBuilder.java"/> <include name="graphics/g3d/utils/shapebuilders/CylinderShapeBuilder.java"/> <include name="graphics/g3d/utils/shapebuilders/EllipseShapeBuilder.java"/> <include name="graphics/g3d/utils/shapebuilders/FrustumShapeBuilder.java"/> <include name="graphics/g3d/utils/shapebuilders/PatchShapeBuilder.java"/> <include name="graphics/g3d/utils/shapebuilders/RenderableShapeBuilder.java"/> <include name="graphics/g3d/utils/shapebuilders/SphereShapeBuilder.java"/> <!-- graphics/glutils --> <include name="graphics/glutils/CustomTexture3DData.java"/> <!-- GLES 3.0 --> <exclude name="graphics/glutils/ETC1.java"/> <!-- Reason: No ETC1 Support --> <include name="graphics/glutils/ETC1TextureData.java"/> <!-- Emulated: explodes on construction --> <include name="graphics/glutils/FacedCubemapData.java"/> <include name="graphics/glutils/FileTextureArrayData.java"/> <!-- GLES 3.0 --> <include name="graphics/glutils/FileTextureData.java"/> <!-- Emulated: No PixmapIO --> <include name="graphics/glutils/FloatFrameBuffer.java"/> <include name="graphics/glutils/FloatTextureData.java"/> <include name="graphics/glutils/FrameBuffer.java"/> <include name="graphics/glutils/FrameBufferCubemap.java"/> <include name="graphics/glutils/GLFrameBuffer.java"/> <include name="graphics/glutils/GLOnlyTextureData.java"/> <include name="graphics/glutils/GLVersion.java"/> <include name="graphics/glutils/HdpiMode.java"/> <include name="graphics/glutils/HdpiUtils.java"/> <include name="graphics/glutils/ImmediateModeRenderer.java"/> <include name="graphics/glutils/ImmediateModeRenderer10.java"/> <include name="graphics/glutils/ImmediateModeRenderer20.java"/> <include name="graphics/glutils/IndexArray.java"/> <!-- Emulated --> <include name="graphics/glutils/IndexBufferObject.java"/> <!-- Emulated --> <include name="graphics/glutils/IndexBufferObjectSubData.java"/> <include name="graphics/glutils/IndexData.java"/> <include name="graphics/glutils/InstanceData.java"/> <include name="graphics/glutils/InstanceBufferObject.java"/> <!-- Emulated --> <exclude name="graphics/glutils/KTXTextureData.java"/> <!-- Rely on ETC1 --> <include name="graphics/glutils/MipMapGenerator.java"/> <include name="graphics/glutils/PixmapTextureData.java"/> <include name="graphics/glutils/ShaderProgram.java"/> <include name="graphics/glutils/ShapeRenderer.java"/> <include name="graphics/glutils/VertexArray.java"/> <!-- Emulated --> <include name="graphics/glutils/VertexBufferObject.java"/> <!-- Emulated --> <include name="graphics/glutils/VertexBufferObjectSubData.java"/> <include name="graphics/glutils/VertexBufferObjectWithVAO.java"/> <!-- Emulated --> <include name="graphics/glutils/VertexData.java"/> <!-- graphics/profiling --> <include name="graphics/profiling/GL20Interceptor.java"/> <include name="graphics/profiling/GL30Interceptor.java"/> <include name="graphics/profiling/GL31Interceptor.java"/> <include name="graphics/profiling/GL32Interceptor.java"/> <include name="graphics/profiling/GLInterceptor.java"/> <include name="graphics/profiling/GLProfiler.java"/> <include name="graphics/profiling/GLErrorListener.java"/> <!-- Emulated --> <!-- input --> <include name="input/GestureDetector.java"/> <exclude name="input/RemoteInput.java"/> <!-- Reason: Networking --> <exclude name="input/RemoteSender.java"/> <!-- Reason: Networking --> <!-- maps --> <include name="maps/ImageResolver.java"/> <include name="maps/Map.java"/> <include name="maps/MapLayer.java"/> <include name="maps/MapGroupLayer.java"/> <include name="maps/MapLayers.java"/> <include name="maps/MapObject.java"/> <include name="maps/MapObjects.java"/> <include name="maps/MapProperties.java"/> <include name="maps/MapRenderer.java"/> <!-- maps/objects --> <include name="maps/objects/CircleMapObject.java"/> <include name="maps/objects/EllipseMapObject.java"/> <include name="maps/objects/PolygonMapObject.java"/> <include name="maps/objects/PolylineMapObject.java"/> <include name="maps/objects/RectangleMapObject.java"/> <include name="maps/objects/TextureMapObject.java"/> <!-- maps/tiled --> <include name="maps/tiled/AtlasTmxMapLoader.java"/> <include name="maps/tiled/BaseTmxMapLoader.java"/> <include name="maps/tiled/TideMapLoader.java"/> <include name="maps/tiled/TiledMap.java"/> <include name="maps/tiled/TiledMapRenderer.java"/> <include name="maps/tiled/TiledMapTile.java"/> <include name="maps/tiled/TiledMapTileLayer.java"/> <include name="maps/tiled/TiledMapTileSet.java"/> <include name="maps/tiled/TiledMapTileSets.java"/> <include name="maps/tiled/TiledMapImageLayer.java"/> <include name="maps/tiled/TmxMapHelper.java"/> <include name="maps/tiled/TmxMapLoader.java"/> <!-- maps/tiled/renderers --> <include name="maps/tiled/renderers/BatchTiledMapRenderer.java"/> <include name="maps/tiled/renderers/HexagonalTiledMapRenderer.java"/> <include name="maps/tiled/renderers/IsometricStaggeredTiledMapRenderer.java"/> <include name="maps/tiled/renderers/IsometricTiledMapRenderer.java"/> <include name="maps/tiled/renderers/OrthoCachedTiledMapRenderer.java"/> <include name="maps/tiled/renderers/OrthogonalTiledMapRenderer.java"/> <!-- maps/tiled/tiles --> <include name="maps/tiled/tiles/AnimatedTiledMapTile.java"/> <include name="maps/tiled/tiles/StaticTiledMapTile.java"/> <!-- maps/tiled/objects --> <include name="maps/tiled/objects/TiledMapTileMapObject.java"/> <!-- math --> <include name="math/Affine2.java"/> <include name="math/Bezier.java"/> <include name="math/Bresenham2.java"/> <include name="math/BSpline.java"/> <include name="math/CatmullRomSpline.java"/> <include name="math/Circle.java"/> <include name="math/ConvexHull.java"/> <include name="math/CumulativeDistribution.java"/> <include name="math/DelaunayTriangulator.java"/> <include name="math/EarClippingTriangulator.java"/> <include name="math/Ellipse.java"/> <include name="math/FloatCounter.java"/> <include name="math/Frustum.java"/> <include name="math/GeometryUtils.java"/> <include name="math/GridPoint2.java"/> <include name="math/GridPoint3.java"/> <include name="math/Interpolation.java"/> <include name="math/Intersector.java"/> <include name="math/MathUtils.java"/> <include name="math/Matrix3.java"/> <include name="math/Matrix4.java"/> <!-- Emulated: JNI --> <include name="math/Octree.java"/> <include name="math/Path.java"/> <include name="math/Plane.java"/> <include name="math/Polygon.java"/> <include name="math/Polyline.java"/> <include name="math/Quaternion.java"/> <include name="math/RandomXS128.java"/> <include name="math/Rectangle.java"/> <include name="math/Shape2D.java"/> <include name="math/Vector.java"/> <include name="math/Vector2.java"/> <include name="math/Vector3.java"/> <include name="math/Vector4.java"/> <include name="math/WindowedMean.java"/> <!-- math/collision --> <include name="math/collision/BoundingBox.java"/> <include name="math/collision/OrientedBoundingBox.java"/> <include name="math/collision/Ray.java"/> <include name="math/collision/Segment.java"/> <include name="math/collision/Sphere.java"/> <!-- net --> <include name="net/HttpParametersUtils.java"/> <include name="net/HttpStatus.java"/> <exclude name="net/NetJavaImpl.java"/> <!-- Reason: Networking --> <exclude name="net/NetJavaServerSocketImpl.java"/> <!-- Reason: Networking --> <exclude name="net/NetJavaSocketImpl.java"/> <!-- Reason: Networking --> <include name="net/ServerSocket.java"/> <include name="net/ServerSocketHints.java"/> <include name="net/Socket.java"/> <include name="net/SocketHints.java"/> <include name="net/HttpRequestBuilder.java"/> <!-- physics/box2d --> <!-- Box2d is fully emulated in GWT backend --> <!-- physics/box2d/joints --> <!-- Box2d is fully emulated in GWT backend --> <!-- scenes/scene2d --> <include name="scenes/scene2d/**/*.java"/> <!-- utils --> <include name="utils/Align.java"/> <include name="utils/Array.java"/> <!-- Emulated: Reflection --> <include name="utils/ArrayMap.java"/> <!-- Emulated: Reflection --> <include name="utils/AtomicQueue.java"/> <include name="utils/Base64Coder.java"/> <include name="utils/BaseJsonReader.java"/> <include name="utils/BinaryHeap.java"/> <include name="utils/Bits.java"/> <include name="utils/BooleanArray.java"/> <include name="utils/BufferUtils.java"/> <!-- Emulated --> <include name="utils/ByteArray.java"/> <include name="utils/CharArray.java"/> <include name="utils/Clipboard.java"/> <include name="utils/Collections.java"/> <include name="utils/ComparableTimSort.java"/> <include name="utils/DataInput.java"/> <include name="utils/DataOutput.java"/> <include name="utils/DelayedRemovalArray.java"/> <include name="utils/Disposable.java"/> <include name="utils/FloatArray.java"/> <include name="utils/FlushablePool.java"/> <exclude name="utils/GdxNativesLoader.java"/> <!-- Reason: Natives --> <include name="utils/GdxRuntimeException.java"/> <include name="utils/I18NBundle.java"/> <include name="utils/IdentityMap.java"/> <include name="utils/IntArray.java"/> <include name="utils/IntFloatMap.java"/> <include name="utils/IntIntMap.java"/> <include name="utils/IntMap.java"/> <include name="utils/IntSet.java"/> <include name="utils/Json.java"/> <include name="utils/JsonReader.java"/> <include name="utils/JsonValue.java"/> <include name="utils/JsonWriter.java"/> <include name="utils/LittleEndianInputStream.java"/> <include name="utils/Logger.java"/> <include name="utils/LongArray.java"/> <include name="utils/LongMap.java"/> <include name="utils/LongQueue.java"/> <include name="utils/NumberUtils.java"/> <!-- Emulated --> <include name="utils/ObjectFloatMap.java"/> <include name="utils/ObjectIntMap.java"/> <include name="utils/ObjectLongMap.java"/> <include name="utils/ObjectMap.java"/> <include name="utils/ObjectSet.java"/> <include name="utils/OrderedMap.java"/> <include name="utils/OrderedSet.java"/> <exclude name="utils/PauseableThread.java"/> <!-- Reason: Threading --> <include name="utils/PerformanceCounter.java"/> <include name="utils/PerformanceCounters.java"/> <include name="utils/Pool.java"/> <include name="utils/PooledLinkedList.java"/> <include name="utils/Pools.java"/> <include name="utils/Predicate.java"/> <include name="utils/PropertiesUtils.java"/> <include name="utils/QuadTreeFloat.java"/> <include name="utils/Queue.java"/> <include name="utils/QuickSelect.java"/> <include name="utils/ReflectionPool.java"/> <include name="utils/Scaling.java"/> <include name="utils/ScreenUtils.java"/> <include name="utils/Select.java"/> <include name="utils/SerializationException.java"/> <!-- Emulated: Reflection --> <exclude name="utils/SharedLibraryLoader.java"/> <!-- Reason: Natives --> <include name="utils/ShortArray.java"/> <include name="utils/SnapshotArray.java"/> <include name="utils/Sort.java"/> <include name="utils/SortedIntList.java"/> <include name="utils/StreamUtils.java"/> <include name="utils/StringBuilder.java"/> <include name="utils/TextFormatter.java"/> <!-- Emulated: MessageFormat --> <include name="utils/Timer.java"/> <!-- Emulated: Threading --> <include name="utils/TimeUtils.java"/> <!-- Emulated: nanoTime() --> <include name="utils/TimSort.java"/> <include name="utils/UBJsonReader.java"/> <include name="utils/UBJsonWriter.java"/> <include name="utils/XmlReader.java"/> <include name="utils/XmlWriter.java"/> <!-- utils/async --> <include name="utils/async/AsyncExecutor.java"/> <!-- Emulated: Threading --> <include name="utils/async/AsyncResult.java"/> <!-- Emulated: Threading --> <include name="utils/async/AsyncTask.java"/> <!-- Emulated: Threading --> <include name="utils/async/ThreadUtils.java"/> <!-- Emulated: Threading --> <!-- utils/compression --> <include name="utils/compression/CRC.java"/> <include name="utils/compression/ICodeProgress.java"/> <include name="utils/compression/Lzma.java"/> <!-- utils/compression/lz --> <include name="utils/compression/lz/BinTree.java"/> <include name="utils/compression/lz/InWindow.java"/> <include name="utils/compression/lz/OutWindow.java"/> <!-- utils/compression/lzma --> <include name="utils/compression/lzma/Base.java"/> <include name="utils/compression/lzma/Decoder.java"/> <include name="utils/compression/lzma/Encoder.java"/> <!-- utils/compression/rangecoder --> <include name="utils/compression/rangecoder/BitTreeDecoder.java"/> <include name="utils/compression/rangecoder/BitTreeEncoder.java"/> <include name="utils/compression/rangecoder/Decoder.java"/> <include name="utils/compression/rangecoder/Encoder.java"/> <!-- utils/reflect --> <include name="utils/reflect/ArrayReflection.java"/> <!-- Emulated --> <include name="utils/reflect/ClassReflection.java"/> <!-- Emulated --> <include name="utils/reflect/Constructor.java"/> <!-- Emulated --> <include name="utils/reflect/Field.java"/> <!-- Emulated --> <include name="utils/reflect/Method.java"/> <!-- Emulated --> <include name="utils/reflect/ReflectionException.java"/> <!-- utils/viewport --> <include name="utils/viewport/**/*.java"/> </source> <define-configuration-property name="gdx.files.classpath" is-multi-valued="true" /> <extend-configuration-property name="gdx.files.classpath" value="com/badlogic/gdx/graphics/g3d/particles/particles.fragment.glsl" /> <extend-configuration-property name="gdx.files.classpath" value="com/badlogic/gdx/graphics/g3d/particles/particles.vertex.glsl" /> <extend-configuration-property name="gdx.files.classpath" value="com/badlogic/gdx/graphics/g3d/shaders/default.fragment.glsl" /> <extend-configuration-property name="gdx.files.classpath" value="com/badlogic/gdx/graphics/g3d/shaders/default.vertex.glsl" /> <extend-configuration-property name="gdx.files.classpath" value="com/badlogic/gdx/graphics/g3d/shaders/depth.fragment.glsl" /> <extend-configuration-property name="gdx.files.classpath" value="com/badlogic/gdx/graphics/g3d/shaders/depth.vertex.glsl" /> <extend-configuration-property name="gdx.files.classpath" value="com/badlogic/gdx/utils/lsans-15.fnt" /> <extend-configuration-property name="gdx.files.classpath" value="com/badlogic/gdx/utils/lsans-15.png" /> </module>
1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./gdx/src/com/badlogic/gdx/graphics/glutils/ShaderProgram.java
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.graphics.glutils; import java.nio.Buffer; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.FloatBuffer; import java.nio.IntBuffer; import com.badlogic.gdx.Application; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.Mesh; import com.badlogic.gdx.math.Matrix3; import com.badlogic.gdx.math.Matrix4; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.BufferUtils; import com.badlogic.gdx.utils.Disposable; import com.badlogic.gdx.utils.ObjectIntMap; import com.badlogic.gdx.utils.ObjectMap; /** * <p> * A shader program encapsulates a vertex and fragment shader pair linked to form a shader program. * </p> * * <p> * After construction a ShaderProgram can be used to draw {@link Mesh}. To make the GPU use a specific ShaderProgram the programs * {@link ShaderProgram#bind()} method must be used which effectively binds the program. * </p> * * <p> * When a ShaderProgram is bound one can set uniforms, vertex attributes and attributes as needed via the respective methods. * </p> * * <p> * A ShaderProgram must be disposed via a call to {@link ShaderProgram#dispose()} when it is no longer needed * </p> * * <p> * ShaderPrograms are managed. In case the OpenGL context is lost all shaders get invalidated and have to be reloaded. This * happens on Android when a user switches to another application or receives an incoming call. Managed ShaderPrograms are * automatically reloaded when the OpenGL context is recreated so you don't have to do this manually. * </p> * * @author mzechner */ public class ShaderProgram implements Disposable { /** default name for position attributes **/ public static final String POSITION_ATTRIBUTE = "a_position"; /** default name for normal attributes **/ public static final String NORMAL_ATTRIBUTE = "a_normal"; /** default name for color attributes **/ public static final String COLOR_ATTRIBUTE = "a_color"; /** default name for texcoords attributes, append texture unit number **/ public static final String TEXCOORD_ATTRIBUTE = "a_texCoord"; /** default name for tangent attribute **/ public static final String TANGENT_ATTRIBUTE = "a_tangent"; /** default name for binormal attribute **/ public static final String BINORMAL_ATTRIBUTE = "a_binormal"; /** default name for boneweight attribute **/ public static final String BONEWEIGHT_ATTRIBUTE = "a_boneWeight"; /** flag indicating whether attributes & uniforms must be present at all times **/ public static boolean pedantic = true; /** code that is always added to the vertex shader code, typically used to inject a #version line. Note that this is added * as-is, you should include a newline (`\n`) if needed. */ public static String prependVertexCode = ""; /** code that is always added to every fragment shader code, typically used to inject a #version line. Note that this is added * as-is, you should include a newline (`\n`) if needed. */ public static String prependFragmentCode = ""; /** the list of currently available shaders **/ private final static ObjectMap<Application, Array<ShaderProgram>> shaders = new ObjectMap<Application, Array<ShaderProgram>>(); /** the log **/ private String log = ""; /** whether this program compiled successfully **/ private boolean isCompiled; /** uniform lookup **/ private final ObjectIntMap<String> uniforms = new ObjectIntMap<String>(); /** uniform types **/ private final ObjectIntMap<String> uniformTypes = new ObjectIntMap<String>(); /** uniform sizes **/ private final ObjectIntMap<String> uniformSizes = new ObjectIntMap<String>(); /** uniform names **/ private String[] uniformNames; /** attribute lookup **/ private final ObjectIntMap<String> attributes = new ObjectIntMap<String>(); /** attribute types **/ private final ObjectIntMap<String> attributeTypes = new ObjectIntMap<String>(); /** attribute sizes **/ private final ObjectIntMap<String> attributeSizes = new ObjectIntMap<String>(); /** attribute names **/ private String[] attributeNames; /** program handle **/ private int program; /** vertex shader handle **/ private int vertexShaderHandle; /** fragment shader handle **/ private int fragmentShaderHandle; /** matrix float buffer **/ private final FloatBuffer matrix; /** vertex shader source **/ private final String vertexShaderSource; /** fragment shader source **/ private final String fragmentShaderSource; /** whether this shader was invalidated **/ private boolean invalidated; /** reference count **/ private int refCount = 0; /** Constructs a new ShaderProgram and immediately compiles it. * * @param vertexShader the vertex shader * @param fragmentShader the fragment shader */ public ShaderProgram (String vertexShader, String fragmentShader) { if (vertexShader == null) throw new IllegalArgumentException("vertex shader must not be null"); if (fragmentShader == null) throw new IllegalArgumentException("fragment shader must not be null"); if (prependVertexCode != null && prependVertexCode.length() > 0) vertexShader = prependVertexCode + vertexShader; if (prependFragmentCode != null && prependFragmentCode.length() > 0) fragmentShader = prependFragmentCode + fragmentShader; this.vertexShaderSource = vertexShader; this.fragmentShaderSource = fragmentShader; this.matrix = BufferUtils.newFloatBuffer(16); compileShaders(vertexShader, fragmentShader); if (isCompiled()) { fetchAttributes(); fetchUniforms(); addManagedShader(Gdx.app, this); } } public ShaderProgram (FileHandle vertexShader, FileHandle fragmentShader) { this(vertexShader.readString(), fragmentShader.readString()); } /** Loads and compiles the shaders, creates a new program and links the shaders. * * @param vertexShader * @param fragmentShader */ private void compileShaders (String vertexShader, String fragmentShader) { vertexShaderHandle = loadShader(GL20.GL_VERTEX_SHADER, vertexShader); fragmentShaderHandle = loadShader(GL20.GL_FRAGMENT_SHADER, fragmentShader); if (vertexShaderHandle == -1 || fragmentShaderHandle == -1) { isCompiled = false; return; } program = linkProgram(createProgram()); if (program == -1) { isCompiled = false; return; } isCompiled = true; } private int loadShader (int type, String source) { GL20 gl = Gdx.gl20; IntBuffer intbuf = BufferUtils.newIntBuffer(1); int shader = gl.glCreateShader(type); if (shader == 0) return -1; gl.glShaderSource(shader, source); gl.glCompileShader(shader); gl.glGetShaderiv(shader, GL20.GL_COMPILE_STATUS, intbuf); int compiled = intbuf.get(0); if (compiled == 0) { // gl.glGetShaderiv(shader, GL20.GL_INFO_LOG_LENGTH, intbuf); // int infoLogLength = intbuf.get(0); // if (infoLogLength > 1) { String infoLog = gl.glGetShaderInfoLog(shader); log += type == GL20.GL_VERTEX_SHADER ? "Vertex shader\n" : "Fragment shader:\n"; log += infoLog; // } return -1; } return shader; } protected int createProgram () { GL20 gl = Gdx.gl20; int program = gl.glCreateProgram(); return program != 0 ? program : -1; } private int linkProgram (int program) { GL20 gl = Gdx.gl20; if (program == -1) return -1; gl.glAttachShader(program, vertexShaderHandle); gl.glAttachShader(program, fragmentShaderHandle); gl.glLinkProgram(program); ByteBuffer tmp = ByteBuffer.allocateDirect(4); tmp.order(ByteOrder.nativeOrder()); IntBuffer intbuf = tmp.asIntBuffer(); gl.glGetProgramiv(program, GL20.GL_LINK_STATUS, intbuf); int linked = intbuf.get(0); if (linked == 0) { // Gdx.gl20.glGetProgramiv(program, GL20.GL_INFO_LOG_LENGTH, intbuf); // int infoLogLength = intbuf.get(0); // if (infoLogLength > 1) { log = Gdx.gl20.glGetProgramInfoLog(program); // } return -1; } return program; } final static IntBuffer intbuf = BufferUtils.newIntBuffer(1); /** @return the log info for the shader compilation and program linking stage. The shader needs to be bound for this method to * have an effect. */ public String getLog () { if (isCompiled) { // Gdx.gl20.glGetProgramiv(program, GL20.GL_INFO_LOG_LENGTH, intbuf); // int infoLogLength = intbuf.get(0); // if (infoLogLength > 1) { log = Gdx.gl20.glGetProgramInfoLog(program); // } return log; } else { return log; } } /** @return whether this ShaderProgram compiled successfully. */ public boolean isCompiled () { return isCompiled; } private int fetchAttributeLocation (String name) { GL20 gl = Gdx.gl20; // -2 == not yet cached // -1 == cached but not found int location; if ((location = attributes.get(name, -2)) == -2) { location = gl.glGetAttribLocation(program, name); attributes.put(name, location); } return location; } private int fetchUniformLocation (String name) { return fetchUniformLocation(name, pedantic); } public int fetchUniformLocation (String name, boolean pedantic) { // -2 == not yet cached // -1 == cached but not found int location; if ((location = uniforms.get(name, -2)) == -2) { location = Gdx.gl20.glGetUniformLocation(program, name); if (location == -1 && pedantic) { if (isCompiled) throw new IllegalArgumentException("No uniform with name '" + name + "' in shader"); throw new IllegalStateException("An attempted fetch uniform from uncompiled shader \n" + getLog()); } uniforms.put(name, location); } return location; } /** Sets the uniform with the given name. The {@link ShaderProgram} must be bound for this to work. * * @param name the name of the uniform * @param value the value */ public void setUniformi (String name, int value) { GL20 gl = Gdx.gl20; checkManaged(); int location = fetchUniformLocation(name); gl.glUniform1i(location, value); } public void setUniformi (int location, int value) { GL20 gl = Gdx.gl20; checkManaged(); gl.glUniform1i(location, value); } /** Sets the uniform with the given name. The {@link ShaderProgram} must be bound for this to work. * * @param name the name of the uniform * @param value1 the first value * @param value2 the second value */ public void setUniformi (String name, int value1, int value2) { GL20 gl = Gdx.gl20; checkManaged(); int location = fetchUniformLocation(name); gl.glUniform2i(location, value1, value2); } public void setUniformi (int location, int value1, int value2) { GL20 gl = Gdx.gl20; checkManaged(); gl.glUniform2i(location, value1, value2); } /** Sets the uniform with the given name. The {@link ShaderProgram} must be bound for this to work. * * @param name the name of the uniform * @param value1 the first value * @param value2 the second value * @param value3 the third value */ public void setUniformi (String name, int value1, int value2, int value3) { GL20 gl = Gdx.gl20; checkManaged(); int location = fetchUniformLocation(name); gl.glUniform3i(location, value1, value2, value3); } public void setUniformi (int location, int value1, int value2, int value3) { GL20 gl = Gdx.gl20; checkManaged(); gl.glUniform3i(location, value1, value2, value3); } /** Sets the uniform with the given name. The {@link ShaderProgram} must be bound for this to work. * * @param name the name of the uniform * @param value1 the first value * @param value2 the second value * @param value3 the third value * @param value4 the fourth value */ public void setUniformi (String name, int value1, int value2, int value3, int value4) { GL20 gl = Gdx.gl20; checkManaged(); int location = fetchUniformLocation(name); gl.glUniform4i(location, value1, value2, value3, value4); } public void setUniformi (int location, int value1, int value2, int value3, int value4) { GL20 gl = Gdx.gl20; checkManaged(); gl.glUniform4i(location, value1, value2, value3, value4); } /** Sets the uniform with the given name. The {@link ShaderProgram} must be bound for this to work. * * @param name the name of the uniform * @param value the value */ public void setUniformf (String name, float value) { GL20 gl = Gdx.gl20; checkManaged(); int location = fetchUniformLocation(name); gl.glUniform1f(location, value); } public void setUniformf (int location, float value) { GL20 gl = Gdx.gl20; checkManaged(); gl.glUniform1f(location, value); } /** Sets the uniform with the given name. The {@link ShaderProgram} must be bound for this to work. * * @param name the name of the uniform * @param value1 the first value * @param value2 the second value */ public void setUniformf (String name, float value1, float value2) { GL20 gl = Gdx.gl20; checkManaged(); int location = fetchUniformLocation(name); gl.glUniform2f(location, value1, value2); } public void setUniformf (int location, float value1, float value2) { GL20 gl = Gdx.gl20; checkManaged(); gl.glUniform2f(location, value1, value2); } /** Sets the uniform with the given name. The {@link ShaderProgram} must be bound for this to work. * * @param name the name of the uniform * @param value1 the first value * @param value2 the second value * @param value3 the third value */ public void setUniformf (String name, float value1, float value2, float value3) { GL20 gl = Gdx.gl20; checkManaged(); int location = fetchUniformLocation(name); gl.glUniform3f(location, value1, value2, value3); } public void setUniformf (int location, float value1, float value2, float value3) { GL20 gl = Gdx.gl20; checkManaged(); gl.glUniform3f(location, value1, value2, value3); } /** Sets the uniform with the given name. The {@link ShaderProgram} must be bound for this to work. * * @param name the name of the uniform * @param value1 the first value * @param value2 the second value * @param value3 the third value * @param value4 the fourth value */ public void setUniformf (String name, float value1, float value2, float value3, float value4) { GL20 gl = Gdx.gl20; checkManaged(); int location = fetchUniformLocation(name); gl.glUniform4f(location, value1, value2, value3, value4); } public void setUniformf (int location, float value1, float value2, float value3, float value4) { GL20 gl = Gdx.gl20; checkManaged(); gl.glUniform4f(location, value1, value2, value3, value4); } public void setUniform1fv (String name, float[] values, int offset, int length) { GL20 gl = Gdx.gl20; checkManaged(); int location = fetchUniformLocation(name); gl.glUniform1fv(location, length, values, offset); } public void setUniform1fv (int location, float[] values, int offset, int length) { GL20 gl = Gdx.gl20; checkManaged(); gl.glUniform1fv(location, length, values, offset); } public void setUniform2fv (String name, float[] values, int offset, int length) { GL20 gl = Gdx.gl20; checkManaged(); int location = fetchUniformLocation(name); gl.glUniform2fv(location, length / 2, values, offset); } public void setUniform2fv (int location, float[] values, int offset, int length) { GL20 gl = Gdx.gl20; checkManaged(); gl.glUniform2fv(location, length / 2, values, offset); } public void setUniform3fv (String name, float[] values, int offset, int length) { GL20 gl = Gdx.gl20; checkManaged(); int location = fetchUniformLocation(name); gl.glUniform3fv(location, length / 3, values, offset); } public void setUniform3fv (int location, float[] values, int offset, int length) { GL20 gl = Gdx.gl20; checkManaged(); gl.glUniform3fv(location, length / 3, values, offset); } public void setUniform4fv (String name, float[] values, int offset, int length) { GL20 gl = Gdx.gl20; checkManaged(); int location = fetchUniformLocation(name); gl.glUniform4fv(location, length / 4, values, offset); } public void setUniform4fv (int location, float[] values, int offset, int length) { GL20 gl = Gdx.gl20; checkManaged(); gl.glUniform4fv(location, length / 4, values, offset); } /** Sets the uniform matrix with the given name. The {@link ShaderProgram} must be bound for this to work. * * @param name the name of the uniform * @param matrix the matrix */ public void setUniformMatrix (String name, Matrix4 matrix) { setUniformMatrix(name, matrix, false); } /** Sets the uniform matrix with the given name. The {@link ShaderProgram} must be bound for this to work. * * @param name the name of the uniform * @param matrix the matrix * @param transpose whether the matrix should be transposed */ public void setUniformMatrix (String name, Matrix4 matrix, boolean transpose) { setUniformMatrix(fetchUniformLocation(name), matrix, transpose); } public void setUniformMatrix (int location, Matrix4 matrix) { setUniformMatrix(location, matrix, false); } public void setUniformMatrix (int location, Matrix4 matrix, boolean transpose) { GL20 gl = Gdx.gl20; checkManaged(); gl.glUniformMatrix4fv(location, 1, transpose, matrix.val, 0); } /** Sets the uniform matrix with the given name. The {@link ShaderProgram} must be bound for this to work. * * @param name the name of the uniform * @param matrix the matrix */ public void setUniformMatrix (String name, Matrix3 matrix) { setUniformMatrix(name, matrix, false); } /** Sets the uniform matrix with the given name. The {@link ShaderProgram} must be bound for this to work. * * @param name the name of the uniform * @param matrix the matrix * @param transpose whether the uniform matrix should be transposed */ public void setUniformMatrix (String name, Matrix3 matrix, boolean transpose) { setUniformMatrix(fetchUniformLocation(name), matrix, transpose); } public void setUniformMatrix (int location, Matrix3 matrix) { setUniformMatrix(location, matrix, false); } public void setUniformMatrix (int location, Matrix3 matrix, boolean transpose) { GL20 gl = Gdx.gl20; checkManaged(); gl.glUniformMatrix3fv(location, 1, transpose, matrix.val, 0); } /** Sets an array of uniform matrices with the given name. The {@link ShaderProgram} must be bound for this to work. * * @param name the name of the uniform * @param buffer buffer containing the matrix data * @param transpose whether the uniform matrix should be transposed */ public void setUniformMatrix3fv (String name, FloatBuffer buffer, int count, boolean transpose) { GL20 gl = Gdx.gl20; checkManaged(); ((Buffer)buffer).position(0); int location = fetchUniformLocation(name); gl.glUniformMatrix3fv(location, count, transpose, buffer); } /** Sets an array of uniform matrices with the given name. The {@link ShaderProgram} must be bound for this to work. * * @param name the name of the uniform * @param buffer buffer containing the matrix data * @param transpose whether the uniform matrix should be transposed */ public void setUniformMatrix4fv (String name, FloatBuffer buffer, int count, boolean transpose) { GL20 gl = Gdx.gl20; checkManaged(); ((Buffer)buffer).position(0); int location = fetchUniformLocation(name); gl.glUniformMatrix4fv(location, count, transpose, buffer); } public void setUniformMatrix4fv (int location, float[] values, int offset, int length) { GL20 gl = Gdx.gl20; checkManaged(); gl.glUniformMatrix4fv(location, length / 16, false, values, offset); } public void setUniformMatrix4fv (String name, float[] values, int offset, int length) { setUniformMatrix4fv(fetchUniformLocation(name), values, offset, length); } /** Sets the uniform with the given name. The {@link ShaderProgram} must be bound for this to work. * * @param name the name of the uniform * @param values x and y as the first and second values respectively */ public void setUniformf (String name, Vector2 values) { setUniformf(name, values.x, values.y); } public void setUniformf (int location, Vector2 values) { setUniformf(location, values.x, values.y); } /** Sets the uniform with the given name. The {@link ShaderProgram} must be bound for this to work. * * @param name the name of the uniform * @param values x, y and z as the first, second and third values respectively */ public void setUniformf (String name, Vector3 values) { setUniformf(name, values.x, values.y, values.z); } public void setUniformf (int location, Vector3 values) { setUniformf(location, values.x, values.y, values.z); } /** Sets the uniform with the given name. The {@link ShaderProgram} must be bound for this to work. * * @param name the name of the uniform * @param values r, g, b and a as the first through fourth values respectively */ public void setUniformf (String name, Color values) { setUniformf(name, values.r, values.g, values.b, values.a); } public void setUniformf (int location, Color values) { setUniformf(location, values.r, values.g, values.b, values.a); } /** Sets the vertex attribute with the given name. The {@link ShaderProgram} must be bound for this to work. * * @param name the attribute name * @param size the number of components, must be >= 1 and <= 4 * @param type the type, must be one of GL20.GL_BYTE, GL20.GL_UNSIGNED_BYTE, GL20.GL_SHORT, * GL20.GL_UNSIGNED_SHORT,GL20.GL_FIXED, or GL20.GL_FLOAT. GL_FIXED will not work on the desktop * @param normalize whether fixed point data should be normalized. Will not work on the desktop * @param stride the stride in bytes between successive attributes * @param buffer the buffer containing the vertex attributes. */ public void setVertexAttribute (String name, int size, int type, boolean normalize, int stride, Buffer buffer) { GL20 gl = Gdx.gl20; checkManaged(); int location = fetchAttributeLocation(name); if (location == -1) return; gl.glVertexAttribPointer(location, size, type, normalize, stride, buffer); } public void setVertexAttribute (int location, int size, int type, boolean normalize, int stride, Buffer buffer) { GL20 gl = Gdx.gl20; checkManaged(); gl.glVertexAttribPointer(location, size, type, normalize, stride, buffer); } /** Sets the vertex attribute with the given name. The {@link ShaderProgram} must be bound for this to work. * * @param name the attribute name * @param size the number of components, must be >= 1 and <= 4 * @param type the type, must be one of GL20.GL_BYTE, GL20.GL_UNSIGNED_BYTE, GL20.GL_SHORT, * GL20.GL_UNSIGNED_SHORT,GL20.GL_FIXED, or GL20.GL_FLOAT. GL_FIXED will not work on the desktop * @param normalize whether fixed point data should be normalized. Will not work on the desktop * @param stride the stride in bytes between successive attributes * @param offset byte offset into the vertex buffer object bound to GL20.GL_ARRAY_BUFFER. */ public void setVertexAttribute (String name, int size, int type, boolean normalize, int stride, int offset) { GL20 gl = Gdx.gl20; checkManaged(); int location = fetchAttributeLocation(name); if (location == -1) return; gl.glVertexAttribPointer(location, size, type, normalize, stride, offset); } public void setVertexAttribute (int location, int size, int type, boolean normalize, int stride, int offset) { GL20 gl = Gdx.gl20; checkManaged(); gl.glVertexAttribPointer(location, size, type, normalize, stride, offset); } /** @deprecated use {@link #bind()} instead, this method will be remove in future version */ @Deprecated public void begin () { bind(); } public void bind () { GL20 gl = Gdx.gl20; checkManaged(); gl.glUseProgram(program); } /** @deprecated no longer necessary, this method will be remove in future version */ @Deprecated public void end () { } /** Disposes all resources associated with this shader. Must be called when the shader is no longer used. */ public void dispose () { GL20 gl = Gdx.gl20; gl.glUseProgram(0); gl.glDeleteShader(vertexShaderHandle); gl.glDeleteShader(fragmentShaderHandle); gl.glDeleteProgram(program); if (shaders.get(Gdx.app) != null) shaders.get(Gdx.app).removeValue(this, true); } /** Disables the vertex attribute with the given name * * @param name the vertex attribute name */ public void disableVertexAttribute (String name) { GL20 gl = Gdx.gl20; checkManaged(); int location = fetchAttributeLocation(name); if (location == -1) return; gl.glDisableVertexAttribArray(location); } public void disableVertexAttribute (int location) { GL20 gl = Gdx.gl20; checkManaged(); gl.glDisableVertexAttribArray(location); } /** Enables the vertex attribute with the given name * * @param name the vertex attribute name */ public void enableVertexAttribute (String name) { GL20 gl = Gdx.gl20; checkManaged(); int location = fetchAttributeLocation(name); if (location == -1) return; gl.glEnableVertexAttribArray(location); } public void enableVertexAttribute (int location) { GL20 gl = Gdx.gl20; checkManaged(); gl.glEnableVertexAttribArray(location); } private void checkManaged () { if (invalidated) { compileShaders(vertexShaderSource, fragmentShaderSource); invalidated = false; } } private void addManagedShader (Application app, ShaderProgram shaderProgram) { Array<ShaderProgram> managedResources = shaders.get(app); if (managedResources == null) managedResources = new Array<ShaderProgram>(); managedResources.add(shaderProgram); shaders.put(app, managedResources); } /** Invalidates all shaders so the next time they are used new handles are generated * @param app */ public static void invalidateAllShaderPrograms (Application app) { if (Gdx.gl20 == null) return; Array<ShaderProgram> shaderArray = shaders.get(app); if (shaderArray == null) return; for (int i = 0; i < shaderArray.size; i++) { shaderArray.get(i).invalidated = true; shaderArray.get(i).checkManaged(); } } public static void clearAllShaderPrograms (Application app) { shaders.remove(app); } public static String getManagedStatus () { StringBuilder builder = new StringBuilder(); int i = 0; builder.append("Managed shaders/app: { "); for (Application app : shaders.keys()) { builder.append(shaders.get(app).size); builder.append(" "); } builder.append("}"); return builder.toString(); } /** @return the number of managed shader programs currently loaded */ public static int getNumManagedShaderPrograms () { return shaders.get(Gdx.app).size; } /** Sets the given attribute * * @param name the name of the attribute * @param value1 the first value * @param value2 the second value * @param value3 the third value * @param value4 the fourth value */ public void setAttributef (String name, float value1, float value2, float value3, float value4) { GL20 gl = Gdx.gl20; int location = fetchAttributeLocation(name); gl.glVertexAttrib4f(location, value1, value2, value3, value4); } IntBuffer params = BufferUtils.newIntBuffer(1); IntBuffer type = BufferUtils.newIntBuffer(1); private void fetchUniforms () { ((Buffer)params).clear(); Gdx.gl20.glGetProgramiv(program, GL20.GL_ACTIVE_UNIFORMS, params); int numUniforms = params.get(0); uniformNames = new String[numUniforms]; for (int i = 0; i < numUniforms; i++) { ((Buffer)params).clear(); params.put(0, 1); ((Buffer)type).clear(); String name = Gdx.gl20.glGetActiveUniform(program, i, params, type); int location = Gdx.gl20.glGetUniformLocation(program, name); uniforms.put(name, location); uniformTypes.put(name, type.get(0)); uniformSizes.put(name, params.get(0)); uniformNames[i] = name; } } private void fetchAttributes () { ((Buffer)params).clear(); Gdx.gl20.glGetProgramiv(program, GL20.GL_ACTIVE_ATTRIBUTES, params); int numAttributes = params.get(0); attributeNames = new String[numAttributes]; for (int i = 0; i < numAttributes; i++) { ((Buffer)params).clear(); params.put(0, 1); ((Buffer)type).clear(); String name = Gdx.gl20.glGetActiveAttrib(program, i, params, type); int location = Gdx.gl20.glGetAttribLocation(program, name); attributes.put(name, location); attributeTypes.put(name, type.get(0)); attributeSizes.put(name, params.get(0)); attributeNames[i] = name; } } /** @param name the name of the attribute * @return whether the attribute is available in the shader */ public boolean hasAttribute (String name) { return attributes.containsKey(name); } /** @param name the name of the attribute * @return the type of the attribute, one of {@link GL20#GL_FLOAT}, {@link GL20#GL_FLOAT_VEC2} etc. */ public int getAttributeType (String name) { return attributeTypes.get(name, 0); } /** @param name the name of the attribute * @return the location of the attribute or -1. */ public int getAttributeLocation (String name) { return attributes.get(name, -1); } /** @param name the name of the attribute * @return the size of the attribute or 0. */ public int getAttributeSize (String name) { return attributeSizes.get(name, 0); } /** @param name the name of the uniform * @return whether the uniform is available in the shader */ public boolean hasUniform (String name) { return uniforms.containsKey(name); } /** @param name the name of the uniform * @return the type of the uniform, one of {@link GL20#GL_FLOAT}, {@link GL20#GL_FLOAT_VEC2} etc. */ public int getUniformType (String name) { return uniformTypes.get(name, 0); } /** @param name the name of the uniform * @return the location of the uniform or -1. */ public int getUniformLocation (String name) { return uniforms.get(name, -1); } /** @param name the name of the uniform * @return the size of the uniform or 0. */ public int getUniformSize (String name) { return uniformSizes.get(name, 0); } /** @return the attributes */ public String[] getAttributes () { return attributeNames; } /** @return the uniforms */ public String[] getUniforms () { return uniformNames; } /** @return the source of the vertex shader */ public String getVertexShaderSource () { return vertexShaderSource; } /** @return the source of the fragment shader */ public String getFragmentShaderSource () { return fragmentShaderSource; } /** @return the handle of the shader program */ public int getHandle () { return program; } }
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.graphics.glutils; import java.nio.Buffer; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.FloatBuffer; import java.nio.IntBuffer; import com.badlogic.gdx.Application; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.Mesh; import com.badlogic.gdx.math.Matrix3; import com.badlogic.gdx.math.Matrix4; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.math.Vector4; import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.BufferUtils; import com.badlogic.gdx.utils.Disposable; import com.badlogic.gdx.utils.ObjectIntMap; import com.badlogic.gdx.utils.ObjectMap; /** * <p> * A shader program encapsulates a vertex and fragment shader pair linked to form a shader program. * </p> * * <p> * After construction a ShaderProgram can be used to draw {@link Mesh}. To make the GPU use a specific ShaderProgram the programs * {@link ShaderProgram#bind()} method must be used which effectively binds the program. * </p> * * <p> * When a ShaderProgram is bound one can set uniforms, vertex attributes and attributes as needed via the respective methods. * </p> * * <p> * A ShaderProgram must be disposed via a call to {@link ShaderProgram#dispose()} when it is no longer needed * </p> * * <p> * ShaderPrograms are managed. In case the OpenGL context is lost all shaders get invalidated and have to be reloaded. This * happens on Android when a user switches to another application or receives an incoming call. Managed ShaderPrograms are * automatically reloaded when the OpenGL context is recreated so you don't have to do this manually. * </p> * * @author mzechner */ public class ShaderProgram implements Disposable { /** default name for position attributes **/ public static final String POSITION_ATTRIBUTE = "a_position"; /** default name for normal attributes **/ public static final String NORMAL_ATTRIBUTE = "a_normal"; /** default name for color attributes **/ public static final String COLOR_ATTRIBUTE = "a_color"; /** default name for texcoords attributes, append texture unit number **/ public static final String TEXCOORD_ATTRIBUTE = "a_texCoord"; /** default name for tangent attribute **/ public static final String TANGENT_ATTRIBUTE = "a_tangent"; /** default name for binormal attribute **/ public static final String BINORMAL_ATTRIBUTE = "a_binormal"; /** default name for boneweight attribute **/ public static final String BONEWEIGHT_ATTRIBUTE = "a_boneWeight"; /** flag indicating whether attributes & uniforms must be present at all times **/ public static boolean pedantic = true; /** code that is always added to the vertex shader code, typically used to inject a #version line. Note that this is added * as-is, you should include a newline (`\n`) if needed. */ public static String prependVertexCode = ""; /** code that is always added to every fragment shader code, typically used to inject a #version line. Note that this is added * as-is, you should include a newline (`\n`) if needed. */ public static String prependFragmentCode = ""; /** the list of currently available shaders **/ private final static ObjectMap<Application, Array<ShaderProgram>> shaders = new ObjectMap<Application, Array<ShaderProgram>>(); /** the log **/ private String log = ""; /** whether this program compiled successfully **/ private boolean isCompiled; /** uniform lookup **/ private final ObjectIntMap<String> uniforms = new ObjectIntMap<String>(); /** uniform types **/ private final ObjectIntMap<String> uniformTypes = new ObjectIntMap<String>(); /** uniform sizes **/ private final ObjectIntMap<String> uniformSizes = new ObjectIntMap<String>(); /** uniform names **/ private String[] uniformNames; /** attribute lookup **/ private final ObjectIntMap<String> attributes = new ObjectIntMap<String>(); /** attribute types **/ private final ObjectIntMap<String> attributeTypes = new ObjectIntMap<String>(); /** attribute sizes **/ private final ObjectIntMap<String> attributeSizes = new ObjectIntMap<String>(); /** attribute names **/ private String[] attributeNames; /** program handle **/ private int program; /** vertex shader handle **/ private int vertexShaderHandle; /** fragment shader handle **/ private int fragmentShaderHandle; /** matrix float buffer **/ private final FloatBuffer matrix; /** vertex shader source **/ private final String vertexShaderSource; /** fragment shader source **/ private final String fragmentShaderSource; /** whether this shader was invalidated **/ private boolean invalidated; /** reference count **/ private int refCount = 0; /** Constructs a new ShaderProgram and immediately compiles it. * * @param vertexShader the vertex shader * @param fragmentShader the fragment shader */ public ShaderProgram (String vertexShader, String fragmentShader) { if (vertexShader == null) throw new IllegalArgumentException("vertex shader must not be null"); if (fragmentShader == null) throw new IllegalArgumentException("fragment shader must not be null"); if (prependVertexCode != null && prependVertexCode.length() > 0) vertexShader = prependVertexCode + vertexShader; if (prependFragmentCode != null && prependFragmentCode.length() > 0) fragmentShader = prependFragmentCode + fragmentShader; this.vertexShaderSource = vertexShader; this.fragmentShaderSource = fragmentShader; this.matrix = BufferUtils.newFloatBuffer(16); compileShaders(vertexShader, fragmentShader); if (isCompiled()) { fetchAttributes(); fetchUniforms(); addManagedShader(Gdx.app, this); } } public ShaderProgram (FileHandle vertexShader, FileHandle fragmentShader) { this(vertexShader.readString(), fragmentShader.readString()); } /** Loads and compiles the shaders, creates a new program and links the shaders. * * @param vertexShader * @param fragmentShader */ private void compileShaders (String vertexShader, String fragmentShader) { vertexShaderHandle = loadShader(GL20.GL_VERTEX_SHADER, vertexShader); fragmentShaderHandle = loadShader(GL20.GL_FRAGMENT_SHADER, fragmentShader); if (vertexShaderHandle == -1 || fragmentShaderHandle == -1) { isCompiled = false; return; } program = linkProgram(createProgram()); if (program == -1) { isCompiled = false; return; } isCompiled = true; } private int loadShader (int type, String source) { GL20 gl = Gdx.gl20; IntBuffer intbuf = BufferUtils.newIntBuffer(1); int shader = gl.glCreateShader(type); if (shader == 0) return -1; gl.glShaderSource(shader, source); gl.glCompileShader(shader); gl.glGetShaderiv(shader, GL20.GL_COMPILE_STATUS, intbuf); int compiled = intbuf.get(0); if (compiled == 0) { // gl.glGetShaderiv(shader, GL20.GL_INFO_LOG_LENGTH, intbuf); // int infoLogLength = intbuf.get(0); // if (infoLogLength > 1) { String infoLog = gl.glGetShaderInfoLog(shader); log += type == GL20.GL_VERTEX_SHADER ? "Vertex shader\n" : "Fragment shader:\n"; log += infoLog; // } return -1; } return shader; } protected int createProgram () { GL20 gl = Gdx.gl20; int program = gl.glCreateProgram(); return program != 0 ? program : -1; } private int linkProgram (int program) { GL20 gl = Gdx.gl20; if (program == -1) return -1; gl.glAttachShader(program, vertexShaderHandle); gl.glAttachShader(program, fragmentShaderHandle); gl.glLinkProgram(program); ByteBuffer tmp = ByteBuffer.allocateDirect(4); tmp.order(ByteOrder.nativeOrder()); IntBuffer intbuf = tmp.asIntBuffer(); gl.glGetProgramiv(program, GL20.GL_LINK_STATUS, intbuf); int linked = intbuf.get(0); if (linked == 0) { // Gdx.gl20.glGetProgramiv(program, GL20.GL_INFO_LOG_LENGTH, intbuf); // int infoLogLength = intbuf.get(0); // if (infoLogLength > 1) { log = Gdx.gl20.glGetProgramInfoLog(program); // } return -1; } return program; } final static IntBuffer intbuf = BufferUtils.newIntBuffer(1); /** @return the log info for the shader compilation and program linking stage. The shader needs to be bound for this method to * have an effect. */ public String getLog () { if (isCompiled) { // Gdx.gl20.glGetProgramiv(program, GL20.GL_INFO_LOG_LENGTH, intbuf); // int infoLogLength = intbuf.get(0); // if (infoLogLength > 1) { log = Gdx.gl20.glGetProgramInfoLog(program); // } return log; } else { return log; } } /** @return whether this ShaderProgram compiled successfully. */ public boolean isCompiled () { return isCompiled; } private int fetchAttributeLocation (String name) { GL20 gl = Gdx.gl20; // -2 == not yet cached // -1 == cached but not found int location; if ((location = attributes.get(name, -2)) == -2) { location = gl.glGetAttribLocation(program, name); attributes.put(name, location); } return location; } private int fetchUniformLocation (String name) { return fetchUniformLocation(name, pedantic); } public int fetchUniformLocation (String name, boolean pedantic) { // -2 == not yet cached // -1 == cached but not found int location; if ((location = uniforms.get(name, -2)) == -2) { location = Gdx.gl20.glGetUniformLocation(program, name); if (location == -1 && pedantic) { if (isCompiled) throw new IllegalArgumentException("No uniform with name '" + name + "' in shader"); throw new IllegalStateException("An attempted fetch uniform from uncompiled shader \n" + getLog()); } uniforms.put(name, location); } return location; } /** Sets the uniform with the given name. The {@link ShaderProgram} must be bound for this to work. * * @param name the name of the uniform * @param value the value */ public void setUniformi (String name, int value) { GL20 gl = Gdx.gl20; checkManaged(); int location = fetchUniformLocation(name); gl.glUniform1i(location, value); } public void setUniformi (int location, int value) { GL20 gl = Gdx.gl20; checkManaged(); gl.glUniform1i(location, value); } /** Sets the uniform with the given name. The {@link ShaderProgram} must be bound for this to work. * * @param name the name of the uniform * @param value1 the first value * @param value2 the second value */ public void setUniformi (String name, int value1, int value2) { GL20 gl = Gdx.gl20; checkManaged(); int location = fetchUniformLocation(name); gl.glUniform2i(location, value1, value2); } public void setUniformi (int location, int value1, int value2) { GL20 gl = Gdx.gl20; checkManaged(); gl.glUniform2i(location, value1, value2); } /** Sets the uniform with the given name. The {@link ShaderProgram} must be bound for this to work. * * @param name the name of the uniform * @param value1 the first value * @param value2 the second value * @param value3 the third value */ public void setUniformi (String name, int value1, int value2, int value3) { GL20 gl = Gdx.gl20; checkManaged(); int location = fetchUniformLocation(name); gl.glUniform3i(location, value1, value2, value3); } public void setUniformi (int location, int value1, int value2, int value3) { GL20 gl = Gdx.gl20; checkManaged(); gl.glUniform3i(location, value1, value2, value3); } /** Sets the uniform with the given name. The {@link ShaderProgram} must be bound for this to work. * * @param name the name of the uniform * @param value1 the first value * @param value2 the second value * @param value3 the third value * @param value4 the fourth value */ public void setUniformi (String name, int value1, int value2, int value3, int value4) { GL20 gl = Gdx.gl20; checkManaged(); int location = fetchUniformLocation(name); gl.glUniform4i(location, value1, value2, value3, value4); } public void setUniformi (int location, int value1, int value2, int value3, int value4) { GL20 gl = Gdx.gl20; checkManaged(); gl.glUniform4i(location, value1, value2, value3, value4); } /** Sets the uniform with the given name. The {@link ShaderProgram} must be bound for this to work. * * @param name the name of the uniform * @param value the value */ public void setUniformf (String name, float value) { GL20 gl = Gdx.gl20; checkManaged(); int location = fetchUniformLocation(name); gl.glUniform1f(location, value); } public void setUniformf (int location, float value) { GL20 gl = Gdx.gl20; checkManaged(); gl.glUniform1f(location, value); } /** Sets the uniform with the given name. The {@link ShaderProgram} must be bound for this to work. * * @param name the name of the uniform * @param value1 the first value * @param value2 the second value */ public void setUniformf (String name, float value1, float value2) { GL20 gl = Gdx.gl20; checkManaged(); int location = fetchUniformLocation(name); gl.glUniform2f(location, value1, value2); } public void setUniformf (int location, float value1, float value2) { GL20 gl = Gdx.gl20; checkManaged(); gl.glUniform2f(location, value1, value2); } /** Sets the uniform with the given name. The {@link ShaderProgram} must be bound for this to work. * * @param name the name of the uniform * @param value1 the first value * @param value2 the second value * @param value3 the third value */ public void setUniformf (String name, float value1, float value2, float value3) { GL20 gl = Gdx.gl20; checkManaged(); int location = fetchUniformLocation(name); gl.glUniform3f(location, value1, value2, value3); } public void setUniformf (int location, float value1, float value2, float value3) { GL20 gl = Gdx.gl20; checkManaged(); gl.glUniform3f(location, value1, value2, value3); } /** Sets the uniform with the given name. The {@link ShaderProgram} must be bound for this to work. * * @param name the name of the uniform * @param value1 the first value * @param value2 the second value * @param value3 the third value * @param value4 the fourth value */ public void setUniformf (String name, float value1, float value2, float value3, float value4) { GL20 gl = Gdx.gl20; checkManaged(); int location = fetchUniformLocation(name); gl.glUniform4f(location, value1, value2, value3, value4); } public void setUniformf (int location, float value1, float value2, float value3, float value4) { GL20 gl = Gdx.gl20; checkManaged(); gl.glUniform4f(location, value1, value2, value3, value4); } public void setUniform1fv (String name, float[] values, int offset, int length) { GL20 gl = Gdx.gl20; checkManaged(); int location = fetchUniformLocation(name); gl.glUniform1fv(location, length, values, offset); } public void setUniform1fv (int location, float[] values, int offset, int length) { GL20 gl = Gdx.gl20; checkManaged(); gl.glUniform1fv(location, length, values, offset); } public void setUniform2fv (String name, float[] values, int offset, int length) { GL20 gl = Gdx.gl20; checkManaged(); int location = fetchUniformLocation(name); gl.glUniform2fv(location, length / 2, values, offset); } public void setUniform2fv (int location, float[] values, int offset, int length) { GL20 gl = Gdx.gl20; checkManaged(); gl.glUniform2fv(location, length / 2, values, offset); } public void setUniform3fv (String name, float[] values, int offset, int length) { GL20 gl = Gdx.gl20; checkManaged(); int location = fetchUniformLocation(name); gl.glUniform3fv(location, length / 3, values, offset); } public void setUniform3fv (int location, float[] values, int offset, int length) { GL20 gl = Gdx.gl20; checkManaged(); gl.glUniform3fv(location, length / 3, values, offset); } public void setUniform4fv (String name, float[] values, int offset, int length) { GL20 gl = Gdx.gl20; checkManaged(); int location = fetchUniformLocation(name); gl.glUniform4fv(location, length / 4, values, offset); } public void setUniform4fv (int location, float[] values, int offset, int length) { GL20 gl = Gdx.gl20; checkManaged(); gl.glUniform4fv(location, length / 4, values, offset); } /** Sets the uniform matrix with the given name. The {@link ShaderProgram} must be bound for this to work. * * @param name the name of the uniform * @param matrix the matrix */ public void setUniformMatrix (String name, Matrix4 matrix) { setUniformMatrix(name, matrix, false); } /** Sets the uniform matrix with the given name. The {@link ShaderProgram} must be bound for this to work. * * @param name the name of the uniform * @param matrix the matrix * @param transpose whether the matrix should be transposed */ public void setUniformMatrix (String name, Matrix4 matrix, boolean transpose) { setUniformMatrix(fetchUniformLocation(name), matrix, transpose); } public void setUniformMatrix (int location, Matrix4 matrix) { setUniformMatrix(location, matrix, false); } public void setUniformMatrix (int location, Matrix4 matrix, boolean transpose) { GL20 gl = Gdx.gl20; checkManaged(); gl.glUniformMatrix4fv(location, 1, transpose, matrix.val, 0); } /** Sets the uniform matrix with the given name. The {@link ShaderProgram} must be bound for this to work. * * @param name the name of the uniform * @param matrix the matrix */ public void setUniformMatrix (String name, Matrix3 matrix) { setUniformMatrix(name, matrix, false); } /** Sets the uniform matrix with the given name. The {@link ShaderProgram} must be bound for this to work. * * @param name the name of the uniform * @param matrix the matrix * @param transpose whether the uniform matrix should be transposed */ public void setUniformMatrix (String name, Matrix3 matrix, boolean transpose) { setUniformMatrix(fetchUniformLocation(name), matrix, transpose); } public void setUniformMatrix (int location, Matrix3 matrix) { setUniformMatrix(location, matrix, false); } public void setUniformMatrix (int location, Matrix3 matrix, boolean transpose) { GL20 gl = Gdx.gl20; checkManaged(); gl.glUniformMatrix3fv(location, 1, transpose, matrix.val, 0); } /** Sets an array of uniform matrices with the given name. The {@link ShaderProgram} must be bound for this to work. * * @param name the name of the uniform * @param buffer buffer containing the matrix data * @param transpose whether the uniform matrix should be transposed */ public void setUniformMatrix3fv (String name, FloatBuffer buffer, int count, boolean transpose) { GL20 gl = Gdx.gl20; checkManaged(); ((Buffer)buffer).position(0); int location = fetchUniformLocation(name); gl.glUniformMatrix3fv(location, count, transpose, buffer); } /** Sets an array of uniform matrices with the given name. The {@link ShaderProgram} must be bound for this to work. * * @param name the name of the uniform * @param buffer buffer containing the matrix data * @param transpose whether the uniform matrix should be transposed */ public void setUniformMatrix4fv (String name, FloatBuffer buffer, int count, boolean transpose) { GL20 gl = Gdx.gl20; checkManaged(); ((Buffer)buffer).position(0); int location = fetchUniformLocation(name); gl.glUniformMatrix4fv(location, count, transpose, buffer); } public void setUniformMatrix4fv (int location, float[] values, int offset, int length) { GL20 gl = Gdx.gl20; checkManaged(); gl.glUniformMatrix4fv(location, length / 16, false, values, offset); } public void setUniformMatrix4fv (String name, float[] values, int offset, int length) { setUniformMatrix4fv(fetchUniformLocation(name), values, offset, length); } /** Sets the uniform with the given name. The {@link ShaderProgram} must be bound for this to work. * * @param name the name of the uniform * @param values x and y as the first and second values respectively */ public void setUniformf (String name, Vector2 values) { setUniformf(name, values.x, values.y); } public void setUniformf (int location, Vector2 values) { setUniformf(location, values.x, values.y); } /** Sets the uniform with the given name. The {@link ShaderProgram} must be bound for this to work. * * @param name the name of the uniform * @param values x, y and z as the first, second and third values respectively */ public void setUniformf (String name, Vector3 values) { setUniformf(name, values.x, values.y, values.z); } public void setUniformf (int location, Vector3 values) { setUniformf(location, values.x, values.y, values.z); } /** Sets the uniform with the given name. The {@link ShaderProgram} must be bound for this to work. * * @param name the name of the uniform * @param values x, y, z, and w as the first, second, third, and fourth values respectively */ public void setUniformf (String name, Vector4 values) { setUniformf(name, values.x, values.y, values.z, values.w); } public void setUniformf (int location, Vector4 values) { setUniformf(location, values.x, values.y, values.z, values.w); } /** Sets the uniform with the given name. The {@link ShaderProgram} must be bound for this to work. * * @param name the name of the uniform * @param values r, g, b and a as the first through fourth values respectively */ public void setUniformf (String name, Color values) { setUniformf(name, values.r, values.g, values.b, values.a); } public void setUniformf (int location, Color values) { setUniformf(location, values.r, values.g, values.b, values.a); } /** Sets the vertex attribute with the given name. The {@link ShaderProgram} must be bound for this to work. * * @param name the attribute name * @param size the number of components, must be >= 1 and <= 4 * @param type the type, must be one of GL20.GL_BYTE, GL20.GL_UNSIGNED_BYTE, GL20.GL_SHORT, * GL20.GL_UNSIGNED_SHORT,GL20.GL_FIXED, or GL20.GL_FLOAT. GL_FIXED will not work on the desktop * @param normalize whether fixed point data should be normalized. Will not work on the desktop * @param stride the stride in bytes between successive attributes * @param buffer the buffer containing the vertex attributes. */ public void setVertexAttribute (String name, int size, int type, boolean normalize, int stride, Buffer buffer) { GL20 gl = Gdx.gl20; checkManaged(); int location = fetchAttributeLocation(name); if (location == -1) return; gl.glVertexAttribPointer(location, size, type, normalize, stride, buffer); } public void setVertexAttribute (int location, int size, int type, boolean normalize, int stride, Buffer buffer) { GL20 gl = Gdx.gl20; checkManaged(); gl.glVertexAttribPointer(location, size, type, normalize, stride, buffer); } /** Sets the vertex attribute with the given name. The {@link ShaderProgram} must be bound for this to work. * * @param name the attribute name * @param size the number of components, must be >= 1 and <= 4 * @param type the type, must be one of GL20.GL_BYTE, GL20.GL_UNSIGNED_BYTE, GL20.GL_SHORT, * GL20.GL_UNSIGNED_SHORT,GL20.GL_FIXED, or GL20.GL_FLOAT. GL_FIXED will not work on the desktop * @param normalize whether fixed point data should be normalized. Will not work on the desktop * @param stride the stride in bytes between successive attributes * @param offset byte offset into the vertex buffer object bound to GL20.GL_ARRAY_BUFFER. */ public void setVertexAttribute (String name, int size, int type, boolean normalize, int stride, int offset) { GL20 gl = Gdx.gl20; checkManaged(); int location = fetchAttributeLocation(name); if (location == -1) return; gl.glVertexAttribPointer(location, size, type, normalize, stride, offset); } public void setVertexAttribute (int location, int size, int type, boolean normalize, int stride, int offset) { GL20 gl = Gdx.gl20; checkManaged(); gl.glVertexAttribPointer(location, size, type, normalize, stride, offset); } /** @deprecated use {@link #bind()} instead, this method will be remove in future version */ @Deprecated public void begin () { bind(); } public void bind () { GL20 gl = Gdx.gl20; checkManaged(); gl.glUseProgram(program); } /** @deprecated no longer necessary, this method will be remove in future version */ @Deprecated public void end () { } /** Disposes all resources associated with this shader. Must be called when the shader is no longer used. */ public void dispose () { GL20 gl = Gdx.gl20; gl.glUseProgram(0); gl.glDeleteShader(vertexShaderHandle); gl.glDeleteShader(fragmentShaderHandle); gl.glDeleteProgram(program); if (shaders.get(Gdx.app) != null) shaders.get(Gdx.app).removeValue(this, true); } /** Disables the vertex attribute with the given name * * @param name the vertex attribute name */ public void disableVertexAttribute (String name) { GL20 gl = Gdx.gl20; checkManaged(); int location = fetchAttributeLocation(name); if (location == -1) return; gl.glDisableVertexAttribArray(location); } public void disableVertexAttribute (int location) { GL20 gl = Gdx.gl20; checkManaged(); gl.glDisableVertexAttribArray(location); } /** Enables the vertex attribute with the given name * * @param name the vertex attribute name */ public void enableVertexAttribute (String name) { GL20 gl = Gdx.gl20; checkManaged(); int location = fetchAttributeLocation(name); if (location == -1) return; gl.glEnableVertexAttribArray(location); } public void enableVertexAttribute (int location) { GL20 gl = Gdx.gl20; checkManaged(); gl.glEnableVertexAttribArray(location); } private void checkManaged () { if (invalidated) { compileShaders(vertexShaderSource, fragmentShaderSource); invalidated = false; } } private void addManagedShader (Application app, ShaderProgram shaderProgram) { Array<ShaderProgram> managedResources = shaders.get(app); if (managedResources == null) managedResources = new Array<ShaderProgram>(); managedResources.add(shaderProgram); shaders.put(app, managedResources); } /** Invalidates all shaders so the next time they are used new handles are generated * @param app */ public static void invalidateAllShaderPrograms (Application app) { if (Gdx.gl20 == null) return; Array<ShaderProgram> shaderArray = shaders.get(app); if (shaderArray == null) return; for (int i = 0; i < shaderArray.size; i++) { shaderArray.get(i).invalidated = true; shaderArray.get(i).checkManaged(); } } public static void clearAllShaderPrograms (Application app) { shaders.remove(app); } public static String getManagedStatus () { StringBuilder builder = new StringBuilder(); int i = 0; builder.append("Managed shaders/app: { "); for (Application app : shaders.keys()) { builder.append(shaders.get(app).size); builder.append(" "); } builder.append("}"); return builder.toString(); } /** @return the number of managed shader programs currently loaded */ public static int getNumManagedShaderPrograms () { return shaders.get(Gdx.app).size; } /** Sets the given attribute * * @param name the name of the attribute * @param value1 the first value * @param value2 the second value * @param value3 the third value * @param value4 the fourth value */ public void setAttributef (String name, float value1, float value2, float value3, float value4) { GL20 gl = Gdx.gl20; int location = fetchAttributeLocation(name); gl.glVertexAttrib4f(location, value1, value2, value3, value4); } IntBuffer params = BufferUtils.newIntBuffer(1); IntBuffer type = BufferUtils.newIntBuffer(1); private void fetchUniforms () { ((Buffer)params).clear(); Gdx.gl20.glGetProgramiv(program, GL20.GL_ACTIVE_UNIFORMS, params); int numUniforms = params.get(0); uniformNames = new String[numUniforms]; for (int i = 0; i < numUniforms; i++) { ((Buffer)params).clear(); params.put(0, 1); ((Buffer)type).clear(); String name = Gdx.gl20.glGetActiveUniform(program, i, params, type); int location = Gdx.gl20.glGetUniformLocation(program, name); uniforms.put(name, location); uniformTypes.put(name, type.get(0)); uniformSizes.put(name, params.get(0)); uniformNames[i] = name; } } private void fetchAttributes () { ((Buffer)params).clear(); Gdx.gl20.glGetProgramiv(program, GL20.GL_ACTIVE_ATTRIBUTES, params); int numAttributes = params.get(0); attributeNames = new String[numAttributes]; for (int i = 0; i < numAttributes; i++) { ((Buffer)params).clear(); params.put(0, 1); ((Buffer)type).clear(); String name = Gdx.gl20.glGetActiveAttrib(program, i, params, type); int location = Gdx.gl20.glGetAttribLocation(program, name); attributes.put(name, location); attributeTypes.put(name, type.get(0)); attributeSizes.put(name, params.get(0)); attributeNames[i] = name; } } /** @param name the name of the attribute * @return whether the attribute is available in the shader */ public boolean hasAttribute (String name) { return attributes.containsKey(name); } /** @param name the name of the attribute * @return the type of the attribute, one of {@link GL20#GL_FLOAT}, {@link GL20#GL_FLOAT_VEC2} etc. */ public int getAttributeType (String name) { return attributeTypes.get(name, 0); } /** @param name the name of the attribute * @return the location of the attribute or -1. */ public int getAttributeLocation (String name) { return attributes.get(name, -1); } /** @param name the name of the attribute * @return the size of the attribute or 0. */ public int getAttributeSize (String name) { return attributeSizes.get(name, 0); } /** @param name the name of the uniform * @return whether the uniform is available in the shader */ public boolean hasUniform (String name) { return uniforms.containsKey(name); } /** @param name the name of the uniform * @return the type of the uniform, one of {@link GL20#GL_FLOAT}, {@link GL20#GL_FLOAT_VEC2} etc. */ public int getUniformType (String name) { return uniformTypes.get(name, 0); } /** @param name the name of the uniform * @return the location of the uniform or -1. */ public int getUniformLocation (String name) { return uniforms.get(name, -1); } /** @param name the name of the uniform * @return the size of the uniform or 0. */ public int getUniformSize (String name) { return uniformSizes.get(name, 0); } /** @return the attributes */ public String[] getAttributes () { return attributeNames; } /** @return the uniforms */ public String[] getUniforms () { return uniformNames; } /** @return the source of the vertex shader */ public String getVertexShaderSource () { return vertexShaderSource; } /** @return the source of the fragment shader */ public String getFragmentShaderSource () { return fragmentShaderSource; } /** @return the handle of the shader program */ public int getHandle () { return program; } }
1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./gdx/src/com/badlogic/gdx/math/Vector.java
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.math; /** Encapsulates a general vector. Allows chaining operations by returning a reference to itself in all modification methods. See * {@link Vector2} and {@link Vector3} for specific implementations. * @author Xoppa */ public interface Vector<T extends Vector<T>> { /** @return a copy of this vector */ T cpy (); /** @return The euclidean length */ float len (); /** This method is faster than {@link Vector#len()} because it avoids calculating a square root. It is useful for comparisons, * but not for getting exact lengths, as the return value is the square of the actual length. * @return The squared euclidean length */ float len2 (); /** Limits the length of this vector, based on the desired maximum length. * @param limit desired maximum length for this vector * @return this vector for chaining */ T limit (float limit); /** Limits the length of this vector, based on the desired maximum length squared. * <p /> * This method is slightly faster than limit(). * @param limit2 squared desired maximum length for this vector * @return this vector for chaining * @see #len2() */ T limit2 (float limit2); /** Sets the length of this vector. Does nothing if this vector is zero. * @param len desired length for this vector * @return this vector for chaining */ T setLength (float len); /** Sets the length of this vector, based on the square of the desired length. Does nothing if this vector is zero. * <p /> * This method is slightly faster than setLength(). * @param len2 desired square of the length for this vector * @return this vector for chaining * @see #len2() */ T setLength2 (float len2); /** Clamps this vector's length to given min and max values * @param min Min length * @param max Max length * @return This vector for chaining */ T clamp (float min, float max); /** Sets this vector from the given vector * @param v The vector * @return This vector for chaining */ T set (T v); /** Subtracts the given vector from this vector. * @param v The vector * @return This vector for chaining */ T sub (T v); /** Normalizes this vector. Does nothing if it is zero. * @return This vector for chaining */ T nor (); /** Adds the given vector to this vector * @param v The vector * @return This vector for chaining */ T add (T v); /** @param v The other vector * @return The dot product between this and the other vector */ float dot (T v); /** Scales this vector by a scalar * @param scalar The scalar * @return This vector for chaining */ T scl (float scalar); /** Scales this vector by another vector * @return This vector for chaining */ T scl (T v); /** @param v The other vector * @return the distance between this and the other vector */ float dst (T v); /** This method is faster than {@link Vector#dst(Vector)} because it avoids calculating a square root. It is useful for * comparisons, but not for getting accurate distances, as the return value is the square of the actual distance. * @param v The other vector * @return the squared distance between this and the other vector */ float dst2 (T v); /** Linearly interpolates between this vector and the target vector by alpha which is in the range [0,1]. The result is stored * in this vector. * @param target The target vector * @param alpha The interpolation coefficient * @return This vector for chaining. */ T lerp (T target, float alpha); /** Interpolates between this vector and the given target vector by alpha (within range [0,1]) using the given Interpolation * method. the result is stored in this vector. * @param target The target vector * @param alpha The interpolation coefficient * @param interpolator An Interpolation object describing the used interpolation method * @return This vector for chaining. */ T interpolate (T target, float alpha, Interpolation interpolator); /** Sets this vector to the unit vector with a random direction * @return This vector for chaining */ T setToRandomDirection (); /** @return Whether this vector is a unit length vector */ boolean isUnit (); /** @return Whether this vector is a unit length vector within the given margin. */ boolean isUnit (final float margin); /** @return Whether this vector is a zero vector */ boolean isZero (); /** @return Whether the length of this vector is smaller than the given margin */ boolean isZero (final float margin); /** @return true if this vector is in line with the other vector (either in the same or the opposite direction) */ boolean isOnLine (T other, float epsilon); /** @return true if this vector is in line with the other vector (either in the same or the opposite direction) */ boolean isOnLine (T other); /** @return true if this vector is collinear with the other vector ({@link #isOnLine(Vector, float)} && * {@link #hasSameDirection(Vector)}). */ boolean isCollinear (T other, float epsilon); /** @return true if this vector is collinear with the other vector ({@link #isOnLine(Vector)} && * {@link #hasSameDirection(Vector)}). */ boolean isCollinear (T other); /** @return true if this vector is opposite collinear with the other vector ({@link #isOnLine(Vector, float)} && * {@link #hasOppositeDirection(Vector)}). */ boolean isCollinearOpposite (T other, float epsilon); /** @return true if this vector is opposite collinear with the other vector ({@link #isOnLine(Vector)} && * {@link #hasOppositeDirection(Vector)}). */ boolean isCollinearOpposite (T other); /** @return Whether this vector is perpendicular with the other vector. True if the dot product is 0. */ boolean isPerpendicular (T other); /** @return Whether this vector is perpendicular with the other vector. True if the dot product is 0. * @param epsilon a positive small number close to zero */ boolean isPerpendicular (T other, float epsilon); /** @return Whether this vector has similar direction compared to the other vector. True if the normalized dot product is > * 0. */ boolean hasSameDirection (T other); /** @return Whether this vector has opposite direction compared to the other vector. True if the normalized dot product is < * 0. */ boolean hasOppositeDirection (T other); /** Compares this vector with the other vector, using the supplied epsilon for fuzzy equality testing. * @param other * @param epsilon * @return whether the vectors have fuzzy equality. */ boolean epsilonEquals (T other, float epsilon); /** First scale a supplied vector, then add it to this vector. * @param v addition vector * @param scalar for scaling the addition vector */ T mulAdd (T v, float scalar); /** First scale a supplied vector, then add it to this vector. * @param v addition vector * @param mulVec vector by whose values the addition vector will be scaled */ T mulAdd (T v, T mulVec); /** Sets the components of this vector to 0 * @return This vector for chaining */ T setZero (); }
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.math; /** Encapsulates a general vector. Allows chaining operations by returning a reference to itself in all modification methods. See * {@link Vector2} and {@link Vector3} for specific implementations. * @author Xoppa */ public interface Vector<T extends Vector<T>> { /** @return a copy of this vector */ T cpy (); /** @return The Euclidean length */ float len (); /** This method is faster than {@link Vector#len()} because it avoids calculating a square root. It is useful for comparisons, * but not for getting exact lengths, as the return value is the square of the actual length. * @return The squared Euclidean length */ float len2 (); /** Limits the length of this vector, based on the desired maximum length. * @param limit desired maximum length for this vector * @return this vector for chaining */ T limit (float limit); /** Limits the length of this vector, based on the desired maximum length squared. * <p /> * This method is slightly faster than limit(). * @param limit2 squared desired maximum length for this vector * @return this vector for chaining * @see #len2() */ T limit2 (float limit2); /** Sets the length of this vector. Does nothing if this vector is zero. * @param len desired length for this vector * @return this vector for chaining */ T setLength (float len); /** Sets the length of this vector, based on the square of the desired length. Does nothing if this vector is zero. * <p /> * This method is slightly faster than setLength(). * @param len2 desired square of the length for this vector * @return this vector for chaining * @see #len2() */ T setLength2 (float len2); /** Clamps this vector's length to given min and max values * @param min Min length * @param max Max length * @return This vector for chaining */ T clamp (float min, float max); /** Sets this vector from the given vector * @param v The vector * @return This vector for chaining */ T set (T v); /** Subtracts the given vector from this vector. * @param v The vector * @return This vector for chaining */ T sub (T v); /** Normalizes this vector. Does nothing if it is zero. * @return This vector for chaining */ T nor (); /** Adds the given vector to this vector * @param v The vector * @return This vector for chaining */ T add (T v); /** @param v The other vector * @return The dot product between this and the other vector */ float dot (T v); /** Scales this vector by a scalar * @param scalar The scalar * @return This vector for chaining */ T scl (float scalar); /** Scales this vector by another vector * @return This vector for chaining */ T scl (T v); /** @param v The other vector * @return the distance between this and the other vector */ float dst (T v); /** This method is faster than {@link Vector#dst(Vector)} because it avoids calculating a square root. It is useful for * comparisons, but not for getting accurate distances, as the return value is the square of the actual distance. * @param v The other vector * @return the squared distance between this and the other vector */ float dst2 (T v); /** Linearly interpolates between this vector and the target vector by alpha which is in the range [0,1]. The result is stored * in this vector. * @param target The target vector * @param alpha The interpolation coefficient * @return This vector for chaining. */ T lerp (T target, float alpha); /** Interpolates between this vector and the given target vector by alpha (within range [0,1]) using the given Interpolation * method. the result is stored in this vector. * @param target The target vector * @param alpha The interpolation coefficient * @param interpolator An Interpolation object describing the used interpolation method * @return This vector for chaining. */ T interpolate (T target, float alpha, Interpolation interpolator); /** Sets this vector to the unit vector with a random direction * @return This vector for chaining */ T setToRandomDirection (); /** @return Whether this vector is a unit length vector */ boolean isUnit (); /** @return Whether this vector is a unit length vector within the given margin. */ boolean isUnit (final float margin); /** @return Whether this vector is a zero vector */ boolean isZero (); /** @return Whether the length of this vector is smaller than the given margin */ boolean isZero (final float margin); /** @return true if this vector is in line with the other vector (either in the same or the opposite direction) */ boolean isOnLine (T other, float epsilon); /** @return true if this vector is in line with the other vector (either in the same or the opposite direction) */ boolean isOnLine (T other); /** @return true if this vector is collinear with the other vector ({@link #isOnLine(Vector, float)} && * {@link #hasSameDirection(Vector)}). */ boolean isCollinear (T other, float epsilon); /** @return true if this vector is collinear with the other vector ({@link #isOnLine(Vector)} && * {@link #hasSameDirection(Vector)}). */ boolean isCollinear (T other); /** @return true if this vector is opposite collinear with the other vector ({@link #isOnLine(Vector, float)} && * {@link #hasOppositeDirection(Vector)}). */ boolean isCollinearOpposite (T other, float epsilon); /** @return true if this vector is opposite collinear with the other vector ({@link #isOnLine(Vector)} && * {@link #hasOppositeDirection(Vector)}). */ boolean isCollinearOpposite (T other); /** @return Whether this vector is perpendicular with the other vector. True if the dot product is 0. */ boolean isPerpendicular (T other); /** @return Whether this vector is perpendicular with the other vector. True if the dot product is 0. * @param epsilon a positive small number close to zero */ boolean isPerpendicular (T other, float epsilon); /** @return Whether this vector has similar direction compared to the other vector. True if the normalized dot product is > * 0. */ boolean hasSameDirection (T other); /** @return Whether this vector has opposite direction compared to the other vector. True if the normalized dot product is < * 0. */ boolean hasOppositeDirection (T other); /** Compares this vector with the other vector, using the supplied epsilon for fuzzy equality testing. * @param other * @param epsilon * @return whether the vectors have fuzzy equality. */ boolean epsilonEquals (T other, float epsilon); /** First scale a supplied vector, then add it to this vector. * @param v addition vector * @param scalar for scaling the addition vector */ T mulAdd (T v, float scalar); /** First scale a supplied vector, then add it to this vector. * @param v addition vector * @param mulVec vector by whose values the addition vector will be scaled */ T mulAdd (T v, T mulVec); /** Sets the components of this vector to 0 * @return This vector for chaining */ T setZero (); }
1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./gdx/src/com/badlogic/gdx/math/Vector2.java
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.math; import java.io.Serializable; import com.badlogic.gdx.utils.GdxRuntimeException; import com.badlogic.gdx.utils.NumberUtils; /** Encapsulates a 2D vector. Allows chaining methods by returning a reference to itself * @author [email protected] */ public class Vector2 implements Serializable, Vector<Vector2> { private static final long serialVersionUID = 913902788239530931L; public final static Vector2 X = new Vector2(1, 0); public final static Vector2 Y = new Vector2(0, 1); public final static Vector2 Zero = new Vector2(0, 0); /** the x-component of this vector **/ public float x; /** the y-component of this vector **/ public float y; /** Constructs a new vector at (0,0) */ public Vector2 () { } /** Constructs a vector with the given components * @param x The x-component * @param y The y-component */ public Vector2 (float x, float y) { this.x = x; this.y = y; } /** Constructs a vector from the given vector * @param v The vector */ public Vector2 (Vector2 v) { set(v); } @Override public Vector2 cpy () { return new Vector2(this); } public static float len (float x, float y) { return (float)Math.sqrt(x * x + y * y); } @Override public float len () { return (float)Math.sqrt(x * x + y * y); } public static float len2 (float x, float y) { return x * x + y * y; } @Override public float len2 () { return x * x + y * y; } @Override public Vector2 set (Vector2 v) { x = v.x; y = v.y; return this; } /** Sets the components of this vector * @param x The x-component * @param y The y-component * @return This vector for chaining */ public Vector2 set (float x, float y) { this.x = x; this.y = y; return this; } @Override public Vector2 sub (Vector2 v) { x -= v.x; y -= v.y; return this; } /** Substracts the other vector from this vector. * @param x The x-component of the other vector * @param y The y-component of the other vector * @return This vector for chaining */ public Vector2 sub (float x, float y) { this.x -= x; this.y -= y; return this; } @Override public Vector2 nor () { float len = len(); if (len != 0) { x /= len; y /= len; } return this; } @Override public Vector2 add (Vector2 v) { x += v.x; y += v.y; return this; } /** Adds the given components to this vector * @param x The x-component * @param y The y-component * @return This vector for chaining */ public Vector2 add (float x, float y) { this.x += x; this.y += y; return this; } public static float dot (float x1, float y1, float x2, float y2) { return x1 * x2 + y1 * y2; } @Override public float dot (Vector2 v) { return x * v.x + y * v.y; } public float dot (float ox, float oy) { return x * ox + y * oy; } @Override public Vector2 scl (float scalar) { x *= scalar; y *= scalar; return this; } /** Multiplies this vector by a scalar * @return This vector for chaining */ public Vector2 scl (float x, float y) { this.x *= x; this.y *= y; return this; } @Override public Vector2 scl (Vector2 v) { this.x *= v.x; this.y *= v.y; return this; } @Override public Vector2 mulAdd (Vector2 vec, float scalar) { this.x += vec.x * scalar; this.y += vec.y * scalar; return this; } @Override public Vector2 mulAdd (Vector2 vec, Vector2 mulVec) { this.x += vec.x * mulVec.x; this.y += vec.y * mulVec.y; return this; } public static float dst (float x1, float y1, float x2, float y2) { final float x_d = x2 - x1; final float y_d = y2 - y1; return (float)Math.sqrt(x_d * x_d + y_d * y_d); } @Override public float dst (Vector2 v) { final float x_d = v.x - x; final float y_d = v.y - y; return (float)Math.sqrt(x_d * x_d + y_d * y_d); } /** @param x The x-component of the other vector * @param y The y-component of the other vector * @return the distance between this and the other vector */ public float dst (float x, float y) { final float x_d = x - this.x; final float y_d = y - this.y; return (float)Math.sqrt(x_d * x_d + y_d * y_d); } public static float dst2 (float x1, float y1, float x2, float y2) { final float x_d = x2 - x1; final float y_d = y2 - y1; return x_d * x_d + y_d * y_d; } @Override public float dst2 (Vector2 v) { final float x_d = v.x - x; final float y_d = v.y - y; return x_d * x_d + y_d * y_d; } /** @param x The x-component of the other vector * @param y The y-component of the other vector * @return the squared distance between this and the other vector */ public float dst2 (float x, float y) { final float x_d = x - this.x; final float y_d = y - this.y; return x_d * x_d + y_d * y_d; } @Override public Vector2 limit (float limit) { return limit2(limit * limit); } @Override public Vector2 limit2 (float limit2) { float len2 = len2(); if (len2 > limit2) { return scl((float)Math.sqrt(limit2 / len2)); } return this; } @Override public Vector2 clamp (float min, float max) { final float len2 = len2(); if (len2 == 0f) return this; float max2 = max * max; if (len2 > max2) return scl((float)Math.sqrt(max2 / len2)); float min2 = min * min; if (len2 < min2) return scl((float)Math.sqrt(min2 / len2)); return this; } @Override public Vector2 setLength (float len) { return setLength2(len * len); } @Override public Vector2 setLength2 (float len2) { float oldLen2 = len2(); return (oldLen2 == 0 || oldLen2 == len2) ? this : scl((float)Math.sqrt(len2 / oldLen2)); } /** Converts this {@code Vector2} to a string in the format {@code (x,y)}. * @return a string representation of this object. */ @Override public String toString () { return "(" + x + "," + y + ")"; } /** Sets this {@code Vector2} to the value represented by the specified string according to the format of {@link #toString()}. * @param v the string. * @return this vector for chaining */ public Vector2 fromString (String v) { int s = v.indexOf(',', 1); if (s != -1 && v.charAt(0) == '(' && v.charAt(v.length() - 1) == ')') { try { float x = Float.parseFloat(v.substring(1, s)); float y = Float.parseFloat(v.substring(s + 1, v.length() - 1)); return this.set(x, y); } catch (NumberFormatException ex) { // Throw a GdxRuntimeException } } throw new GdxRuntimeException("Malformed Vector2: " + v); } /** Left-multiplies this vector by the given matrix * @param mat the matrix * @return this vector */ public Vector2 mul (Matrix3 mat) { float x = this.x * mat.val[0] + this.y * mat.val[3] + mat.val[6]; float y = this.x * mat.val[1] + this.y * mat.val[4] + mat.val[7]; this.x = x; this.y = y; return this; } /** Calculates the 2D cross product between this and the given vector. * @param v the other vector * @return the cross product */ public float crs (Vector2 v) { return this.x * v.y - this.y * v.x; } /** Calculates the 2D cross product between this and the given vector. * @param x the x-coordinate of the other vector * @param y the y-coordinate of the other vector * @return the cross product */ public float crs (float x, float y) { return this.x * y - this.y * x; } /** @return the angle in degrees of this vector (point) relative to the x-axis. Angles are towards the positive y-axis * (typically counter-clockwise) and between 0 and 360. * @deprecated use {@link #angleDeg()} instead. */ @Deprecated public float angle () { float angle = (float)Math.atan2(y, x) * MathUtils.radiansToDegrees; if (angle < 0) angle += 360; return angle; } /** @return the angle in degrees of this vector (point) relative to the given vector. Angles are towards the negative y-axis * (typically clockwise) between -180 and +180 * @deprecated use {@link #angleDeg(Vector2)} instead. Be ware of the changes in returned angle to counter-clockwise and the * range. */ @Deprecated public float angle (Vector2 reference) { return (float)Math.atan2(crs(reference), dot(reference)) * MathUtils.radiansToDegrees; } /** @return the angle in degrees of this vector (point) relative to the x-axis. Angles are towards the positive y-axis * (typically counter-clockwise) and in the [0, 360) range. */ public float angleDeg () { float angle = (float)Math.atan2(y, x) * MathUtils.radiansToDegrees; if (angle < 0) angle += 360; return angle; } /** @return the angle in degrees of this vector (point) relative to the given vector. Angles are towards the positive y-axis * (typically counter-clockwise.) in the [0, 360) range */ public float angleDeg (Vector2 reference) { float angle = (float)Math.atan2(reference.crs(this), reference.dot(this)) * MathUtils.radiansToDegrees; if (angle < 0) angle += 360; return angle; } /** @return the angle in radians of this vector (point) relative to the x-axis. Angles are towards the positive y-axis. * (typically counter-clockwise) */ public float angleRad () { return (float)Math.atan2(y, x); } /** @return the angle in radians of this vector (point) relative to the given vector. Angles are towards the positive y-axis. * (typically counter-clockwise.) */ public float angleRad (Vector2 reference) { return (float)Math.atan2(reference.crs(this), reference.dot(this)); } /** Sets the angle of the vector in degrees relative to the x-axis, towards the positive y-axis (typically counter-clockwise). * @param degrees The angle in degrees to set. * @deprecated use {@link #setAngleDeg(float)} instead. */ @Deprecated public Vector2 setAngle (float degrees) { return setAngleRad(degrees * MathUtils.degreesToRadians); } /** Sets the angle of the vector in degrees relative to the x-axis, towards the positive y-axis (typically counter-clockwise). * @param degrees The angle in degrees to set. */ public Vector2 setAngleDeg (float degrees) { return setAngleRad(degrees * MathUtils.degreesToRadians); } /** Sets the angle of the vector in radians relative to the x-axis, towards the positive y-axis (typically counter-clockwise). * @param radians The angle in radians to set. */ public Vector2 setAngleRad (float radians) { this.set(len(), 0f); this.rotateRad(radians); return this; } /** Rotates the Vector2 by the given angle, counter-clockwise assuming the y-axis points up. * @param degrees the angle in degrees * @deprecated use {@link #rotateDeg(float)} instead. */ @Deprecated public Vector2 rotate (float degrees) { return rotateRad(degrees * MathUtils.degreesToRadians); } /** Rotates the Vector2 by the given angle around reference vector, counter-clockwise assuming the y-axis points up. * @param degrees the angle in degrees * @param reference center Vector2 * @deprecated use {@link #rotateAroundDeg(Vector2, float)} instead. */ @Deprecated public Vector2 rotateAround (Vector2 reference, float degrees) { return this.sub(reference).rotateDeg(degrees).add(reference); } /** Rotates the Vector2 by the given angle, counter-clockwise assuming the y-axis points up. * @param degrees the angle in degrees */ public Vector2 rotateDeg (float degrees) { return rotateRad(degrees * MathUtils.degreesToRadians); } /** Rotates the Vector2 by the given angle, counter-clockwise assuming the y-axis points up. * @param radians the angle in radians */ public Vector2 rotateRad (float radians) { float cos = (float)Math.cos(radians); float sin = (float)Math.sin(radians); float newX = this.x * cos - this.y * sin; float newY = this.x * sin + this.y * cos; this.x = newX; this.y = newY; return this; } /** Rotates the Vector2 by the given angle around reference vector, counter-clockwise assuming the y-axis points up. * @param degrees the angle in degrees * @param reference center Vector2 */ public Vector2 rotateAroundDeg (Vector2 reference, float degrees) { return this.sub(reference).rotateDeg(degrees).add(reference); } /** Rotates the Vector2 by the given angle around reference vector, counter-clockwise assuming the y-axis points up. * @param radians the angle in radians * @param reference center Vector2 */ public Vector2 rotateAroundRad (Vector2 reference, float radians) { return this.sub(reference).rotateRad(radians).add(reference); } /** Rotates the Vector2 by 90 degrees in the specified direction, where >= 0 is counter-clockwise and < 0 is clockwise. */ public Vector2 rotate90 (int dir) { float x = this.x; if (dir >= 0) { this.x = -y; y = x; } else { this.x = y; y = -x; } return this; } @Override public Vector2 lerp (Vector2 target, float alpha) { final float invAlpha = 1.0f - alpha; this.x = (x * invAlpha) + (target.x * alpha); this.y = (y * invAlpha) + (target.y * alpha); return this; } @Override public Vector2 interpolate (Vector2 target, float alpha, Interpolation interpolation) { return lerp(target, interpolation.apply(alpha)); } @Override public Vector2 setToRandomDirection () { float theta = MathUtils.random(0f, MathUtils.PI2); return this.set(MathUtils.cos(theta), MathUtils.sin(theta)); } @Override public int hashCode () { final int prime = 31; int result = 1; result = prime * result + NumberUtils.floatToIntBits(x); result = prime * result + NumberUtils.floatToIntBits(y); return result; } @Override public boolean equals (Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Vector2 other = (Vector2)obj; if (NumberUtils.floatToIntBits(x) != NumberUtils.floatToIntBits(other.x)) return false; if (NumberUtils.floatToIntBits(y) != NumberUtils.floatToIntBits(other.y)) return false; return true; } @Override public boolean epsilonEquals (Vector2 other, float epsilon) { if (other == null) return false; if (Math.abs(other.x - x) > epsilon) return false; if (Math.abs(other.y - y) > epsilon) return false; return true; } /** Compares this vector with the other vector, using the supplied epsilon for fuzzy equality testing. * @return whether the vectors are the same. */ public boolean epsilonEquals (float x, float y, float epsilon) { if (Math.abs(x - this.x) > epsilon) return false; if (Math.abs(y - this.y) > epsilon) return false; return true; } /** Compares this vector with the other vector using MathUtils.FLOAT_ROUNDING_ERROR for fuzzy equality testing * @param other other vector to compare * @return true if vector are equal, otherwise false */ public boolean epsilonEquals (final Vector2 other) { return epsilonEquals(other, MathUtils.FLOAT_ROUNDING_ERROR); } /** Compares this vector with the other vector using MathUtils.FLOAT_ROUNDING_ERROR for fuzzy equality testing * @param x x component of the other vector to compare * @param y y component of the other vector to compare * @return true if vector are equal, otherwise false */ public boolean epsilonEquals (float x, float y) { return epsilonEquals(x, y, MathUtils.FLOAT_ROUNDING_ERROR); } @Override public boolean isUnit () { return isUnit(0.000000001f); } @Override public boolean isUnit (final float margin) { return Math.abs(len2() - 1f) < margin; } @Override public boolean isZero () { return x == 0 && y == 0; } @Override public boolean isZero (final float margin) { return len2() < margin; } @Override public boolean isOnLine (Vector2 other) { return MathUtils.isZero(x * other.y - y * other.x); } @Override public boolean isOnLine (Vector2 other, float epsilon) { return MathUtils.isZero(x * other.y - y * other.x, epsilon); } @Override public boolean isCollinear (Vector2 other, float epsilon) { return isOnLine(other, epsilon) && dot(other) > 0f; } @Override public boolean isCollinear (Vector2 other) { return isOnLine(other) && dot(other) > 0f; } @Override public boolean isCollinearOpposite (Vector2 other, float epsilon) { return isOnLine(other, epsilon) && dot(other) < 0f; } @Override public boolean isCollinearOpposite (Vector2 other) { return isOnLine(other) && dot(other) < 0f; } @Override public boolean isPerpendicular (Vector2 vector) { return MathUtils.isZero(dot(vector)); } @Override public boolean isPerpendicular (Vector2 vector, float epsilon) { return MathUtils.isZero(dot(vector), epsilon); } @Override public boolean hasSameDirection (Vector2 vector) { return dot(vector) > 0; } @Override public boolean hasOppositeDirection (Vector2 vector) { return dot(vector) < 0; } @Override public Vector2 setZero () { this.x = 0; this.y = 0; return this; } }
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.math; import java.io.Serializable; import com.badlogic.gdx.utils.GdxRuntimeException; import com.badlogic.gdx.utils.NumberUtils; /** Encapsulates a 2D vector. Allows chaining methods by returning a reference to itself * @author [email protected] */ public class Vector2 implements Serializable, Vector<Vector2> { private static final long serialVersionUID = 913902788239530931L; public final static Vector2 X = new Vector2(1, 0); public final static Vector2 Y = new Vector2(0, 1); public final static Vector2 Zero = new Vector2(0, 0); /** the x-component of this vector **/ public float x; /** the y-component of this vector **/ public float y; /** Constructs a new vector at (0,0) */ public Vector2 () { } /** Constructs a vector with the given components * @param x The x-component * @param y The y-component */ public Vector2 (float x, float y) { this.x = x; this.y = y; } /** Constructs a vector from the given vector * @param v The vector */ public Vector2 (Vector2 v) { set(v); } @Override public Vector2 cpy () { return new Vector2(this); } public static float len (float x, float y) { return (float)Math.sqrt(x * x + y * y); } @Override public float len () { return (float)Math.sqrt(x * x + y * y); } public static float len2 (float x, float y) { return x * x + y * y; } @Override public float len2 () { return x * x + y * y; } @Override public Vector2 set (Vector2 v) { x = v.x; y = v.y; return this; } /** Sets the components of this vector * @param x The x-component * @param y The y-component * @return This vector for chaining */ public Vector2 set (float x, float y) { this.x = x; this.y = y; return this; } @Override public Vector2 sub (Vector2 v) { x -= v.x; y -= v.y; return this; } /** Subtracts the other vector from this vector. * @param x The x-component of the other vector * @param y The y-component of the other vector * @return This vector for chaining */ public Vector2 sub (float x, float y) { this.x -= x; this.y -= y; return this; } @Override public Vector2 nor () { float len = len(); if (len != 0) { x /= len; y /= len; } return this; } @Override public Vector2 add (Vector2 v) { x += v.x; y += v.y; return this; } /** Adds the given components to this vector * @param x The x-component * @param y The y-component * @return This vector for chaining */ public Vector2 add (float x, float y) { this.x += x; this.y += y; return this; } public static float dot (float x1, float y1, float x2, float y2) { return x1 * x2 + y1 * y2; } @Override public float dot (Vector2 v) { return x * v.x + y * v.y; } public float dot (float ox, float oy) { return x * ox + y * oy; } @Override public Vector2 scl (float scalar) { x *= scalar; y *= scalar; return this; } /** Multiplies this vector by a scalar * @return This vector for chaining */ public Vector2 scl (float x, float y) { this.x *= x; this.y *= y; return this; } @Override public Vector2 scl (Vector2 v) { this.x *= v.x; this.y *= v.y; return this; } @Override public Vector2 mulAdd (Vector2 vec, float scalar) { this.x += vec.x * scalar; this.y += vec.y * scalar; return this; } @Override public Vector2 mulAdd (Vector2 vec, Vector2 mulVec) { this.x += vec.x * mulVec.x; this.y += vec.y * mulVec.y; return this; } /** Returns true if this vector and the vector parameter have identical components. * @param vector The other vector * @return Whether this and the other vector are equal with exact precision */ public boolean idt (final Vector2 vector) { return x == vector.x && y == vector.y; } public static float dst (float x1, float y1, float x2, float y2) { final float x_d = x2 - x1; final float y_d = y2 - y1; return (float)Math.sqrt(x_d * x_d + y_d * y_d); } @Override public float dst (Vector2 v) { final float x_d = v.x - x; final float y_d = v.y - y; return (float)Math.sqrt(x_d * x_d + y_d * y_d); } /** @param x The x-component of the other vector * @param y The y-component of the other vector * @return the distance between this and the other vector */ public float dst (float x, float y) { final float x_d = x - this.x; final float y_d = y - this.y; return (float)Math.sqrt(x_d * x_d + y_d * y_d); } public static float dst2 (float x1, float y1, float x2, float y2) { final float x_d = x2 - x1; final float y_d = y2 - y1; return x_d * x_d + y_d * y_d; } @Override public float dst2 (Vector2 v) { final float x_d = v.x - x; final float y_d = v.y - y; return x_d * x_d + y_d * y_d; } /** @param x The x-component of the other vector * @param y The y-component of the other vector * @return the squared distance between this and the other vector */ public float dst2 (float x, float y) { final float x_d = x - this.x; final float y_d = y - this.y; return x_d * x_d + y_d * y_d; } @Override public Vector2 limit (float limit) { return limit2(limit * limit); } @Override public Vector2 limit2 (float limit2) { float len2 = len2(); if (len2 > limit2) { return scl((float)Math.sqrt(limit2 / len2)); } return this; } @Override public Vector2 clamp (float min, float max) { final float len2 = len2(); if (len2 == 0f) return this; float max2 = max * max; if (len2 > max2) return scl((float)Math.sqrt(max2 / len2)); float min2 = min * min; if (len2 < min2) return scl((float)Math.sqrt(min2 / len2)); return this; } @Override public Vector2 setLength (float len) { return setLength2(len * len); } @Override public Vector2 setLength2 (float len2) { float oldLen2 = len2(); return (oldLen2 == 0 || oldLen2 == len2) ? this : scl((float)Math.sqrt(len2 / oldLen2)); } /** Converts this {@code Vector2} to a string in the format {@code (x,y)}. * @return a string representation of this object. */ @Override public String toString () { return "(" + x + "," + y + ")"; } /** Sets this {@code Vector2} to the value represented by the specified string according to the format of {@link #toString()}. * @param v the string. * @return this vector for chaining */ public Vector2 fromString (String v) { int s = v.indexOf(',', 1); if (s != -1 && v.charAt(0) == '(' && v.charAt(v.length() - 1) == ')') { try { float x = Float.parseFloat(v.substring(1, s)); float y = Float.parseFloat(v.substring(s + 1, v.length() - 1)); return this.set(x, y); } catch (NumberFormatException ex) { // Throw a GdxRuntimeException } } throw new GdxRuntimeException("Malformed Vector2: " + v); } /** Left-multiplies this vector by the given matrix * @param mat the matrix * @return this vector */ public Vector2 mul (Matrix3 mat) { float x = this.x * mat.val[0] + this.y * mat.val[3] + mat.val[6]; float y = this.x * mat.val[1] + this.y * mat.val[4] + mat.val[7]; this.x = x; this.y = y; return this; } /** Calculates the 2D cross product between this and the given vector. * @param v the other vector * @return the cross product */ public float crs (Vector2 v) { return this.x * v.y - this.y * v.x; } /** Calculates the 2D cross product between this and the given vector. * @param x the x-coordinate of the other vector * @param y the y-coordinate of the other vector * @return the cross product */ public float crs (float x, float y) { return this.x * y - this.y * x; } /** @return the angle in degrees of this vector (point) relative to the x-axis. Angles are towards the positive y-axis * (typically counter-clockwise) and between 0 and 360. * @deprecated use {@link #angleDeg()} instead. */ @Deprecated public float angle () { float angle = (float)Math.atan2(y, x) * MathUtils.radiansToDegrees; if (angle < 0) angle += 360; return angle; } /** @return the angle in degrees of this vector (point) relative to the given vector. Angles are towards the negative y-axis * (typically clockwise) between -180 and +180 * @deprecated use {@link #angleDeg(Vector2)} instead. Beware of the changes in returned angle to counter-clockwise and the * range. */ @Deprecated public float angle (Vector2 reference) { return (float)Math.atan2(crs(reference), dot(reference)) * MathUtils.radiansToDegrees; } /** @return the angle in degrees of this vector (point) relative to the x-axis. Angles are towards the positive y-axis * (typically counter-clockwise) and in the [0, 360) range. */ public float angleDeg () { float angle = (float)Math.atan2(y, x) * MathUtils.radiansToDegrees; if (angle < 0) angle += 360; return angle; } /** @return the angle in degrees of this vector (point) relative to the given vector. Angles are towards the positive y-axis * (typically counter-clockwise.) in the [0, 360) range */ public float angleDeg (Vector2 reference) { float angle = (float)Math.atan2(reference.crs(this), reference.dot(this)) * MathUtils.radiansToDegrees; if (angle < 0) angle += 360; return angle; } /** @return the angle in radians of this vector (point) relative to the x-axis. Angles are towards the positive y-axis. * (typically counter-clockwise) */ public float angleRad () { return (float)Math.atan2(y, x); } /** @return the angle in radians of this vector (point) relative to the given vector. Angles are towards the positive y-axis. * (typically counter-clockwise.) */ public float angleRad (Vector2 reference) { return (float)Math.atan2(reference.crs(this), reference.dot(this)); } /** Sets the angle of the vector in degrees relative to the x-axis, towards the positive y-axis (typically counter-clockwise). * @param degrees The angle in degrees to set. * @deprecated use {@link #setAngleDeg(float)} instead. */ @Deprecated public Vector2 setAngle (float degrees) { return setAngleRad(degrees * MathUtils.degreesToRadians); } /** Sets the angle of the vector in degrees relative to the x-axis, towards the positive y-axis (typically counter-clockwise). * @param degrees The angle in degrees to set. */ public Vector2 setAngleDeg (float degrees) { return setAngleRad(degrees * MathUtils.degreesToRadians); } /** Sets the angle of the vector in radians relative to the x-axis, towards the positive y-axis (typically counter-clockwise). * @param radians The angle in radians to set. */ public Vector2 setAngleRad (float radians) { this.set(len(), 0f); this.rotateRad(radians); return this; } /** Rotates the Vector2 by the given angle, counter-clockwise assuming the y-axis points up. * @param degrees the angle in degrees * @deprecated use {@link #rotateDeg(float)} instead. */ @Deprecated public Vector2 rotate (float degrees) { return rotateRad(degrees * MathUtils.degreesToRadians); } /** Rotates the Vector2 by the given angle around reference vector, counter-clockwise assuming the y-axis points up. * @param degrees the angle in degrees * @param reference center Vector2 * @deprecated use {@link #rotateAroundDeg(Vector2, float)} instead. */ @Deprecated public Vector2 rotateAround (Vector2 reference, float degrees) { return this.sub(reference).rotateDeg(degrees).add(reference); } /** Rotates the Vector2 by the given angle, counter-clockwise assuming the y-axis points up. * @param degrees the angle in degrees */ public Vector2 rotateDeg (float degrees) { return rotateRad(degrees * MathUtils.degreesToRadians); } /** Rotates the Vector2 by the given angle, counter-clockwise assuming the y-axis points up. * @param radians the angle in radians */ public Vector2 rotateRad (float radians) { float cos = (float)Math.cos(radians); float sin = (float)Math.sin(radians); float newX = this.x * cos - this.y * sin; float newY = this.x * sin + this.y * cos; this.x = newX; this.y = newY; return this; } /** Rotates the Vector2 by the given angle around reference vector, counter-clockwise assuming the y-axis points up. * @param degrees the angle in degrees * @param reference center Vector2 */ public Vector2 rotateAroundDeg (Vector2 reference, float degrees) { return this.sub(reference).rotateDeg(degrees).add(reference); } /** Rotates the Vector2 by the given angle around reference vector, counter-clockwise assuming the y-axis points up. * @param radians the angle in radians * @param reference center Vector2 */ public Vector2 rotateAroundRad (Vector2 reference, float radians) { return this.sub(reference).rotateRad(radians).add(reference); } /** Rotates the Vector2 by 90 degrees in the specified direction, where >= 0 is counter-clockwise and < 0 is clockwise. */ public Vector2 rotate90 (int dir) { float x = this.x; if (dir >= 0) { this.x = -y; y = x; } else { this.x = y; y = -x; } return this; } @Override public Vector2 lerp (Vector2 target, float alpha) { final float invAlpha = 1.0f - alpha; this.x = (x * invAlpha) + (target.x * alpha); this.y = (y * invAlpha) + (target.y * alpha); return this; } @Override public Vector2 interpolate (Vector2 target, float alpha, Interpolation interpolation) { return lerp(target, interpolation.apply(alpha)); } @Override public Vector2 setToRandomDirection () { float theta = MathUtils.random(0f, MathUtils.PI2); return this.set(MathUtils.cos(theta), MathUtils.sin(theta)); } @Override public int hashCode () { final int prime = 31; int result = 1; result = prime * result + NumberUtils.floatToIntBits(x); result = prime * result + NumberUtils.floatToIntBits(y); return result; } @Override public boolean equals (Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Vector2 other = (Vector2)obj; if (NumberUtils.floatToIntBits(x) != NumberUtils.floatToIntBits(other.x)) return false; if (NumberUtils.floatToIntBits(y) != NumberUtils.floatToIntBits(other.y)) return false; return true; } @Override public boolean epsilonEquals (Vector2 other, float epsilon) { if (other == null) return false; if (Math.abs(other.x - x) > epsilon) return false; if (Math.abs(other.y - y) > epsilon) return false; return true; } /** Compares this vector with the other vector, using the supplied epsilon for fuzzy equality testing. * @return whether the vectors are the same. */ public boolean epsilonEquals (float x, float y, float epsilon) { if (Math.abs(x - this.x) > epsilon) return false; if (Math.abs(y - this.y) > epsilon) return false; return true; } /** Compares this vector with the other vector using MathUtils.FLOAT_ROUNDING_ERROR for fuzzy equality testing * @param other other vector to compare * @return true if vector are equal, otherwise false */ public boolean epsilonEquals (final Vector2 other) { return epsilonEquals(other, MathUtils.FLOAT_ROUNDING_ERROR); } /** Compares this vector with the other vector using MathUtils.FLOAT_ROUNDING_ERROR for fuzzy equality testing * @param x x component of the other vector to compare * @param y y component of the other vector to compare * @return true if vector are equal, otherwise false */ public boolean epsilonEquals (float x, float y) { return epsilonEquals(x, y, MathUtils.FLOAT_ROUNDING_ERROR); } @Override public boolean isUnit () { return isUnit(0.000000001f); } @Override public boolean isUnit (final float margin) { return Math.abs(len2() - 1f) < margin; } @Override public boolean isZero () { return x == 0 && y == 0; } @Override public boolean isZero (final float margin) { return len2() < margin; } @Override public boolean isOnLine (Vector2 other) { return MathUtils.isZero(x * other.y - y * other.x); } @Override public boolean isOnLine (Vector2 other, float epsilon) { return MathUtils.isZero(x * other.y - y * other.x, epsilon); } @Override public boolean isCollinear (Vector2 other, float epsilon) { return isOnLine(other, epsilon) && dot(other) > 0f; } @Override public boolean isCollinear (Vector2 other) { return isOnLine(other) && dot(other) > 0f; } @Override public boolean isCollinearOpposite (Vector2 other, float epsilon) { return isOnLine(other, epsilon) && dot(other) < 0f; } @Override public boolean isCollinearOpposite (Vector2 other) { return isOnLine(other) && dot(other) < 0f; } @Override public boolean isPerpendicular (Vector2 vector) { return MathUtils.isZero(dot(vector)); } @Override public boolean isPerpendicular (Vector2 vector, float epsilon) { return MathUtils.isZero(dot(vector), epsilon); } @Override public boolean hasSameDirection (Vector2 vector) { return dot(vector) > 0; } @Override public boolean hasOppositeDirection (Vector2 vector) { return dot(vector) < 0; } @Override public Vector2 setZero () { this.x = 0; this.y = 0; return this; } }
1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./gdx/src/com/badlogic/gdx/math/Vector3.java
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.math; import java.io.Serializable; import com.badlogic.gdx.utils.GdxRuntimeException; import com.badlogic.gdx.utils.NumberUtils; /** Encapsulates a 3D vector. Allows chaining operations by returning a reference to itself in all modification methods. * @author [email protected] */ public class Vector3 implements Serializable, Vector<Vector3> { private static final long serialVersionUID = 3840054589595372522L; /** the x-component of this vector **/ public float x; /** the y-component of this vector **/ public float y; /** the z-component of this vector **/ public float z; public final static Vector3 X = new Vector3(1, 0, 0); public final static Vector3 Y = new Vector3(0, 1, 0); public final static Vector3 Z = new Vector3(0, 0, 1); public final static Vector3 Zero = new Vector3(0, 0, 0); private final static Matrix4 tmpMat = new Matrix4(); /** Constructs a vector at (0,0,0) */ public Vector3 () { } /** Creates a vector with the given components * @param x The x-component * @param y The y-component * @param z The z-component */ public Vector3 (float x, float y, float z) { this.set(x, y, z); } /** Creates a vector from the given vector * @param vector The vector */ public Vector3 (final Vector3 vector) { this.set(vector); } /** Creates a vector from the given array. The array must have at least 3 elements. * * @param values The array */ public Vector3 (final float[] values) { this.set(values[0], values[1], values[2]); } /** Creates a vector from the given vector and z-component * * @param vector The vector * @param z The z-component */ public Vector3 (final Vector2 vector, float z) { this.set(vector.x, vector.y, z); } /** Sets the vector to the given components * * @param x The x-component * @param y The y-component * @param z The z-component * @return this vector for chaining */ public Vector3 set (float x, float y, float z) { this.x = x; this.y = y; this.z = z; return this; } @Override public Vector3 set (final Vector3 vector) { return this.set(vector.x, vector.y, vector.z); } /** Sets the components from the array. The array must have at least 3 elements * * @param values The array * @return this vector for chaining */ public Vector3 set (final float[] values) { return this.set(values[0], values[1], values[2]); } /** Sets the components of the given vector and z-component * * @param vector The vector * @param z The z-component * @return This vector for chaining */ public Vector3 set (final Vector2 vector, float z) { return this.set(vector.x, vector.y, z); } /** Sets the components from the given spherical coordinate * @param azimuthalAngle The angle between x-axis in radians [0, 2pi] * @param polarAngle The angle between z-axis in radians [0, pi] * @return This vector for chaining */ public Vector3 setFromSpherical (float azimuthalAngle, float polarAngle) { float cosPolar = MathUtils.cos(polarAngle); float sinPolar = MathUtils.sin(polarAngle); float cosAzim = MathUtils.cos(azimuthalAngle); float sinAzim = MathUtils.sin(azimuthalAngle); return this.set(cosAzim * sinPolar, sinAzim * sinPolar, cosPolar); } @Override public Vector3 setToRandomDirection () { float u = MathUtils.random(); float v = MathUtils.random(); float theta = MathUtils.PI2 * u; // azimuthal angle float phi = (float)Math.acos(2f * v - 1f); // polar angle return this.setFromSpherical(theta, phi); } @Override public Vector3 cpy () { return new Vector3(this); } @Override public Vector3 add (final Vector3 vector) { return this.add(vector.x, vector.y, vector.z); } /** Adds the given vector to this component * @param x The x-component of the other vector * @param y The y-component of the other vector * @param z The z-component of the other vector * @return This vector for chaining. */ public Vector3 add (float x, float y, float z) { return this.set(this.x + x, this.y + y, this.z + z); } /** Adds the given value to all three components of the vector. * * @param values The value * @return This vector for chaining */ public Vector3 add (float values) { return this.set(this.x + values, this.y + values, this.z + values); } @Override public Vector3 sub (final Vector3 a_vec) { return this.sub(a_vec.x, a_vec.y, a_vec.z); } /** Subtracts the other vector from this vector. * * @param x The x-component of the other vector * @param y The y-component of the other vector * @param z The z-component of the other vector * @return This vector for chaining */ public Vector3 sub (float x, float y, float z) { return this.set(this.x - x, this.y - y, this.z - z); } /** Subtracts the given value from all components of this vector * * @param value The value * @return This vector for chaining */ public Vector3 sub (float value) { return this.set(this.x - value, this.y - value, this.z - value); } @Override public Vector3 scl (float scalar) { return this.set(this.x * scalar, this.y * scalar, this.z * scalar); } @Override public Vector3 scl (final Vector3 other) { return this.set(x * other.x, y * other.y, z * other.z); } /** Scales this vector by the given values * @param vx X value * @param vy Y value * @param vz Z value * @return This vector for chaining */ public Vector3 scl (float vx, float vy, float vz) { return this.set(this.x * vx, this.y * vy, this.z * vz); } @Override public Vector3 mulAdd (Vector3 vec, float scalar) { this.x += vec.x * scalar; this.y += vec.y * scalar; this.z += vec.z * scalar; return this; } @Override public Vector3 mulAdd (Vector3 vec, Vector3 mulVec) { this.x += vec.x * mulVec.x; this.y += vec.y * mulVec.y; this.z += vec.z * mulVec.z; return this; } /** @return The euclidean length */ public static float len (final float x, final float y, final float z) { return (float)Math.sqrt(x * x + y * y + z * z); } @Override public float len () { return (float)Math.sqrt(x * x + y * y + z * z); } /** @return The squared euclidean length */ public static float len2 (final float x, final float y, final float z) { return x * x + y * y + z * z; } @Override public float len2 () { return x * x + y * y + z * z; } /** @param vector The other vector * @return Whether this and the other vector are equal */ public boolean idt (final Vector3 vector) { return x == vector.x && y == vector.y && z == vector.z; } /** @return The euclidean distance between the two specified vectors */ public static float dst (final float x1, final float y1, final float z1, final float x2, final float y2, final float z2) { final float a = x2 - x1; final float b = y2 - y1; final float c = z2 - z1; return (float)Math.sqrt(a * a + b * b + c * c); } @Override public float dst (final Vector3 vector) { final float a = vector.x - x; final float b = vector.y - y; final float c = vector.z - z; return (float)Math.sqrt(a * a + b * b + c * c); } /** @return the distance between this point and the given point */ public float dst (float x, float y, float z) { final float a = x - this.x; final float b = y - this.y; final float c = z - this.z; return (float)Math.sqrt(a * a + b * b + c * c); } /** @return the squared distance between the given points */ public static float dst2 (final float x1, final float y1, final float z1, final float x2, final float y2, final float z2) { final float a = x2 - x1; final float b = y2 - y1; final float c = z2 - z1; return a * a + b * b + c * c; } @Override public float dst2 (Vector3 point) { final float a = point.x - x; final float b = point.y - y; final float c = point.z - z; return a * a + b * b + c * c; } /** Returns the squared distance between this point and the given point * @param x The x-component of the other point * @param y The y-component of the other point * @param z The z-component of the other point * @return The squared distance */ public float dst2 (float x, float y, float z) { final float a = x - this.x; final float b = y - this.y; final float c = z - this.z; return a * a + b * b + c * c; } @Override public Vector3 nor () { final float len2 = this.len2(); if (len2 == 0f || len2 == 1f) return this; return this.scl(1f / (float)Math.sqrt(len2)); } /** @return The dot product between the two vectors */ public static float dot (float x1, float y1, float z1, float x2, float y2, float z2) { return x1 * x2 + y1 * y2 + z1 * z2; } @Override public float dot (final Vector3 vector) { return x * vector.x + y * vector.y + z * vector.z; } /** Returns the dot product between this and the given vector. * @param x The x-component of the other vector * @param y The y-component of the other vector * @param z The z-component of the other vector * @return The dot product */ public float dot (float x, float y, float z) { return this.x * x + this.y * y + this.z * z; } /** Sets this vector to the cross product between it and the other vector. * @param vector The other vector * @return This vector for chaining */ public Vector3 crs (final Vector3 vector) { return this.set(y * vector.z - z * vector.y, z * vector.x - x * vector.z, x * vector.y - y * vector.x); } /** Sets this vector to the cross product between it and the other vector. * @param x The x-component of the other vector * @param y The y-component of the other vector * @param z The z-component of the other vector * @return This vector for chaining */ public Vector3 crs (float x, float y, float z) { return this.set(this.y * z - this.z * y, this.z * x - this.x * z, this.x * y - this.y * x); } /** Left-multiplies the vector by the given 4x3 column major matrix. The matrix should be composed by a 3x3 matrix representing * rotation and scale plus a 1x3 matrix representing the translation. * @param matrix The matrix * @return This vector for chaining */ public Vector3 mul4x3 (float[] matrix) { return set(x * matrix[0] + y * matrix[3] + z * matrix[6] + matrix[9], x * matrix[1] + y * matrix[4] + z * matrix[7] + matrix[10], x * matrix[2] + y * matrix[5] + z * matrix[8] + matrix[11]); } /** Left-multiplies the vector by the given matrix, assuming the fourth (w) component of the vector is 1. * @param matrix The matrix * @return This vector for chaining */ public Vector3 mul (final Matrix4 matrix) { final float l_mat[] = matrix.val; return this.set(x * l_mat[Matrix4.M00] + y * l_mat[Matrix4.M01] + z * l_mat[Matrix4.M02] + l_mat[Matrix4.M03], x * l_mat[Matrix4.M10] + y * l_mat[Matrix4.M11] + z * l_mat[Matrix4.M12] + l_mat[Matrix4.M13], x * l_mat[Matrix4.M20] + y * l_mat[Matrix4.M21] + z * l_mat[Matrix4.M22] + l_mat[Matrix4.M23]); } /** Multiplies the vector by the transpose of the given matrix, assuming the fourth (w) component of the vector is 1. * @param matrix The matrix * @return This vector for chaining */ public Vector3 traMul (final Matrix4 matrix) { final float l_mat[] = matrix.val; return this.set(x * l_mat[Matrix4.M00] + y * l_mat[Matrix4.M10] + z * l_mat[Matrix4.M20] + l_mat[Matrix4.M30], x * l_mat[Matrix4.M01] + y * l_mat[Matrix4.M11] + z * l_mat[Matrix4.M21] + l_mat[Matrix4.M31], x * l_mat[Matrix4.M02] + y * l_mat[Matrix4.M12] + z * l_mat[Matrix4.M22] + l_mat[Matrix4.M32]); } /** Left-multiplies the vector by the given matrix. * @param matrix The matrix * @return This vector for chaining */ public Vector3 mul (Matrix3 matrix) { final float l_mat[] = matrix.val; return set(x * l_mat[Matrix3.M00] + y * l_mat[Matrix3.M01] + z * l_mat[Matrix3.M02], x * l_mat[Matrix3.M10] + y * l_mat[Matrix3.M11] + z * l_mat[Matrix3.M12], x * l_mat[Matrix3.M20] + y * l_mat[Matrix3.M21] + z * l_mat[Matrix3.M22]); } /** Multiplies the vector by the transpose of the given matrix. * @param matrix The matrix * @return This vector for chaining */ public Vector3 traMul (Matrix3 matrix) { final float l_mat[] = matrix.val; return set(x * l_mat[Matrix3.M00] + y * l_mat[Matrix3.M10] + z * l_mat[Matrix3.M20], x * l_mat[Matrix3.M01] + y * l_mat[Matrix3.M11] + z * l_mat[Matrix3.M21], x * l_mat[Matrix3.M02] + y * l_mat[Matrix3.M12] + z * l_mat[Matrix3.M22]); } /** Multiplies the vector by the given {@link Quaternion}. * @return This vector for chaining */ public Vector3 mul (final Quaternion quat) { return quat.transform(this); } /** Multiplies this vector by the given matrix dividing by w, assuming the fourth (w) component of the vector is 1. This is * mostly used to project/unproject vectors via a perspective projection matrix. * * @param matrix The matrix. * @return This vector for chaining */ public Vector3 prj (final Matrix4 matrix) { final float l_mat[] = matrix.val; final float l_w = 1f / (x * l_mat[Matrix4.M30] + y * l_mat[Matrix4.M31] + z * l_mat[Matrix4.M32] + l_mat[Matrix4.M33]); return this.set((x * l_mat[Matrix4.M00] + y * l_mat[Matrix4.M01] + z * l_mat[Matrix4.M02] + l_mat[Matrix4.M03]) * l_w, (x * l_mat[Matrix4.M10] + y * l_mat[Matrix4.M11] + z * l_mat[Matrix4.M12] + l_mat[Matrix4.M13]) * l_w, (x * l_mat[Matrix4.M20] + y * l_mat[Matrix4.M21] + z * l_mat[Matrix4.M22] + l_mat[Matrix4.M23]) * l_w); } /** Multiplies this vector by the first three columns of the matrix, essentially only applying rotation and scaling. * * @param matrix The matrix * @return This vector for chaining */ public Vector3 rot (final Matrix4 matrix) { final float l_mat[] = matrix.val; return this.set(x * l_mat[Matrix4.M00] + y * l_mat[Matrix4.M01] + z * l_mat[Matrix4.M02], x * l_mat[Matrix4.M10] + y * l_mat[Matrix4.M11] + z * l_mat[Matrix4.M12], x * l_mat[Matrix4.M20] + y * l_mat[Matrix4.M21] + z * l_mat[Matrix4.M22]); } /** Multiplies this vector by the transpose of the first three columns of the matrix. Note: only works for translation and * rotation, does not work for scaling. For those, use {@link #rot(Matrix4)} with {@link Matrix4#inv()}. * @param matrix The transformation matrix * @return The vector for chaining */ public Vector3 unrotate (final Matrix4 matrix) { final float l_mat[] = matrix.val; return this.set(x * l_mat[Matrix4.M00] + y * l_mat[Matrix4.M10] + z * l_mat[Matrix4.M20], x * l_mat[Matrix4.M01] + y * l_mat[Matrix4.M11] + z * l_mat[Matrix4.M21], x * l_mat[Matrix4.M02] + y * l_mat[Matrix4.M12] + z * l_mat[Matrix4.M22]); } /** Translates this vector in the direction opposite to the translation of the matrix and the multiplies this vector by the * transpose of the first three columns of the matrix. Note: only works for translation and rotation, does not work for * scaling. For those, use {@link #mul(Matrix4)} with {@link Matrix4#inv()}. * @param matrix The transformation matrix * @return The vector for chaining */ public Vector3 untransform (final Matrix4 matrix) { final float l_mat[] = matrix.val; x -= l_mat[Matrix4.M03]; y -= l_mat[Matrix4.M03]; z -= l_mat[Matrix4.M03]; return this.set(x * l_mat[Matrix4.M00] + y * l_mat[Matrix4.M10] + z * l_mat[Matrix4.M20], x * l_mat[Matrix4.M01] + y * l_mat[Matrix4.M11] + z * l_mat[Matrix4.M21], x * l_mat[Matrix4.M02] + y * l_mat[Matrix4.M12] + z * l_mat[Matrix4.M22]); } /** Rotates this vector by the given angle in degrees around the given axis. * * @param degrees the angle in degrees * @param axisX the x-component of the axis * @param axisY the y-component of the axis * @param axisZ the z-component of the axis * @return This vector for chaining */ public Vector3 rotate (float degrees, float axisX, float axisY, float axisZ) { return this.mul(tmpMat.setToRotation(axisX, axisY, axisZ, degrees)); } /** Rotates this vector by the given angle in radians around the given axis. * * @param radians the angle in radians * @param axisX the x-component of the axis * @param axisY the y-component of the axis * @param axisZ the z-component of the axis * @return This vector for chaining */ public Vector3 rotateRad (float radians, float axisX, float axisY, float axisZ) { return this.mul(tmpMat.setToRotationRad(axisX, axisY, axisZ, radians)); } /** Rotates this vector by the given angle in degrees around the given axis. * * @param axis the axis * @param degrees the angle in degrees * @return This vector for chaining */ public Vector3 rotate (final Vector3 axis, float degrees) { tmpMat.setToRotation(axis, degrees); return this.mul(tmpMat); } /** Rotates this vector by the given angle in radians around the given axis. * * @param axis the axis * @param radians the angle in radians * @return This vector for chaining */ public Vector3 rotateRad (final Vector3 axis, float radians) { tmpMat.setToRotationRad(axis, radians); return this.mul(tmpMat); } @Override public boolean isUnit () { return isUnit(0.000000001f); } @Override public boolean isUnit (final float margin) { return Math.abs(len2() - 1f) < margin; } @Override public boolean isZero () { return x == 0 && y == 0 && z == 0; } @Override public boolean isZero (final float margin) { return len2() < margin; } @Override public boolean isOnLine (Vector3 other, float epsilon) { return len2(y * other.z - z * other.y, z * other.x - x * other.z, x * other.y - y * other.x) <= epsilon; } @Override public boolean isOnLine (Vector3 other) { return len2(y * other.z - z * other.y, z * other.x - x * other.z, x * other.y - y * other.x) <= MathUtils.FLOAT_ROUNDING_ERROR; } @Override public boolean isCollinear (Vector3 other, float epsilon) { return isOnLine(other, epsilon) && hasSameDirection(other); } @Override public boolean isCollinear (Vector3 other) { return isOnLine(other) && hasSameDirection(other); } @Override public boolean isCollinearOpposite (Vector3 other, float epsilon) { return isOnLine(other, epsilon) && hasOppositeDirection(other); } @Override public boolean isCollinearOpposite (Vector3 other) { return isOnLine(other) && hasOppositeDirection(other); } @Override public boolean isPerpendicular (Vector3 vector) { return MathUtils.isZero(dot(vector)); } @Override public boolean isPerpendicular (Vector3 vector, float epsilon) { return MathUtils.isZero(dot(vector), epsilon); } @Override public boolean hasSameDirection (Vector3 vector) { return dot(vector) > 0; } @Override public boolean hasOppositeDirection (Vector3 vector) { return dot(vector) < 0; } @Override public Vector3 lerp (final Vector3 target, float alpha) { x += alpha * (target.x - x); y += alpha * (target.y - y); z += alpha * (target.z - z); return this; } @Override public Vector3 interpolate (Vector3 target, float alpha, Interpolation interpolator) { return lerp(target, interpolator.apply(0f, 1f, alpha)); } /** Spherically interpolates between this vector and the target vector by alpha which is in the range [0,1]. The result is * stored in this vector. * * @param target The target vector * @param alpha The interpolation coefficient * @return This vector for chaining. */ public Vector3 slerp (final Vector3 target, float alpha) { final float dot = dot(target); // If the inputs are too close for comfort, simply linearly interpolate. if (dot > 0.9995 || dot < -0.9995) return lerp(target, alpha); // theta0 = angle between input vectors final float theta0 = (float)Math.acos(dot); // theta = angle between this vector and result final float theta = theta0 * alpha; final float st = (float)Math.sin(theta); final float tx = target.x - x * dot; final float ty = target.y - y * dot; final float tz = target.z - z * dot; final float l2 = tx * tx + ty * ty + tz * tz; final float dl = st * ((l2 < 0.0001f) ? 1f : 1f / (float)Math.sqrt(l2)); return scl((float)Math.cos(theta)).add(tx * dl, ty * dl, tz * dl).nor(); } /** Converts this {@code Vector3} to a string in the format {@code (x,y,z)}. * @return a string representation of this object. */ @Override public String toString () { return "(" + x + "," + y + "," + z + ")"; } /** Sets this {@code Vector3} to the value represented by the specified string according to the format of {@link #toString()}. * @param v the string. * @return this vector for chaining */ public Vector3 fromString (String v) { int s0 = v.indexOf(',', 1); int s1 = v.indexOf(',', s0 + 1); if (s0 != -1 && s1 != -1 && v.charAt(0) == '(' && v.charAt(v.length() - 1) == ')') { try { float x = Float.parseFloat(v.substring(1, s0)); float y = Float.parseFloat(v.substring(s0 + 1, s1)); float z = Float.parseFloat(v.substring(s1 + 1, v.length() - 1)); return this.set(x, y, z); } catch (NumberFormatException ex) { // Throw a GdxRuntimeException } } throw new GdxRuntimeException("Malformed Vector3: " + v); } @Override public Vector3 limit (float limit) { return limit2(limit * limit); } @Override public Vector3 limit2 (float limit2) { float len2 = len2(); if (len2 > limit2) { scl((float)Math.sqrt(limit2 / len2)); } return this; } @Override public Vector3 setLength (float len) { return setLength2(len * len); } @Override public Vector3 setLength2 (float len2) { float oldLen2 = len2(); return (oldLen2 == 0 || oldLen2 == len2) ? this : scl((float)Math.sqrt(len2 / oldLen2)); } @Override public Vector3 clamp (float min, float max) { final float len2 = len2(); if (len2 == 0f) return this; float max2 = max * max; if (len2 > max2) return scl((float)Math.sqrt(max2 / len2)); float min2 = min * min; if (len2 < min2) return scl((float)Math.sqrt(min2 / len2)); return this; } @Override public int hashCode () { final int prime = 31; int result = 1; result = prime * result + NumberUtils.floatToIntBits(x); result = prime * result + NumberUtils.floatToIntBits(y); result = prime * result + NumberUtils.floatToIntBits(z); return result; } @Override public boolean equals (Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Vector3 other = (Vector3)obj; if (NumberUtils.floatToIntBits(x) != NumberUtils.floatToIntBits(other.x)) return false; if (NumberUtils.floatToIntBits(y) != NumberUtils.floatToIntBits(other.y)) return false; if (NumberUtils.floatToIntBits(z) != NumberUtils.floatToIntBits(other.z)) return false; return true; } @Override public boolean epsilonEquals (final Vector3 other, float epsilon) { if (other == null) return false; if (Math.abs(other.x - x) > epsilon) return false; if (Math.abs(other.y - y) > epsilon) return false; if (Math.abs(other.z - z) > epsilon) return false; return true; } /** Compares this vector with the other vector, using the supplied epsilon for fuzzy equality testing. * @return whether the vectors are the same. */ public boolean epsilonEquals (float x, float y, float z, float epsilon) { if (Math.abs(x - this.x) > epsilon) return false; if (Math.abs(y - this.y) > epsilon) return false; if (Math.abs(z - this.z) > epsilon) return false; return true; } /** Compares this vector with the other vector using MathUtils.FLOAT_ROUNDING_ERROR for fuzzy equality testing * * @param other other vector to compare * @return true if vector are equal, otherwise false */ public boolean epsilonEquals (final Vector3 other) { return epsilonEquals(other, MathUtils.FLOAT_ROUNDING_ERROR); } /** Compares this vector with the other vector using MathUtils.FLOAT_ROUNDING_ERROR for fuzzy equality testing * * @param x x component of the other vector to compare * @param y y component of the other vector to compare * @param z z component of the other vector to compare * @return true if vector are equal, otherwise false */ public boolean epsilonEquals (float x, float y, float z) { return epsilonEquals(x, y, z, MathUtils.FLOAT_ROUNDING_ERROR); } @Override public Vector3 setZero () { this.x = 0; this.y = 0; this.z = 0; return this; } }
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.math; import java.io.Serializable; import com.badlogic.gdx.utils.GdxRuntimeException; import com.badlogic.gdx.utils.NumberUtils; /** Encapsulates a 3D vector. Allows chaining operations by returning a reference to itself in all modification methods. * @author [email protected] */ public class Vector3 implements Serializable, Vector<Vector3> { private static final long serialVersionUID = 3840054589595372522L; /** the x-component of this vector **/ public float x; /** the y-component of this vector **/ public float y; /** the z-component of this vector **/ public float z; public final static Vector3 X = new Vector3(1, 0, 0); public final static Vector3 Y = new Vector3(0, 1, 0); public final static Vector3 Z = new Vector3(0, 0, 1); public final static Vector3 Zero = new Vector3(0, 0, 0); private final static Matrix4 tmpMat = new Matrix4(); /** Constructs a vector at (0,0,0) */ public Vector3 () { } /** Creates a vector with the given components * @param x The x-component * @param y The y-component * @param z The z-component */ public Vector3 (float x, float y, float z) { this.set(x, y, z); } /** Creates a vector from the given vector * @param vector The vector */ public Vector3 (final Vector3 vector) { this.set(vector); } /** Creates a vector from the given array. The array must have at least 3 elements. * * @param values The array */ public Vector3 (final float[] values) { this.set(values[0], values[1], values[2]); } /** Creates a vector from the given vector and z-component * * @param vector The vector * @param z The z-component */ public Vector3 (final Vector2 vector, float z) { this.set(vector.x, vector.y, z); } /** Sets the vector to the given components * * @param x The x-component * @param y The y-component * @param z The z-component * @return this vector for chaining */ public Vector3 set (float x, float y, float z) { this.x = x; this.y = y; this.z = z; return this; } @Override public Vector3 set (final Vector3 vector) { return this.set(vector.x, vector.y, vector.z); } /** Sets the components from the array. The array must have at least 3 elements * * @param values The array * @return this vector for chaining */ public Vector3 set (final float[] values) { return this.set(values[0], values[1], values[2]); } /** Sets the components of the given vector and z-component * * @param vector The vector * @param z The z-component * @return This vector for chaining */ public Vector3 set (final Vector2 vector, float z) { return this.set(vector.x, vector.y, z); } /** Sets the components from the given spherical coordinate * @param azimuthalAngle The angle between x-axis in radians [0, 2pi] * @param polarAngle The angle between z-axis in radians [0, pi] * @return This vector for chaining */ public Vector3 setFromSpherical (float azimuthalAngle, float polarAngle) { float cosPolar = MathUtils.cos(polarAngle); float sinPolar = MathUtils.sin(polarAngle); float cosAzim = MathUtils.cos(azimuthalAngle); float sinAzim = MathUtils.sin(azimuthalAngle); return this.set(cosAzim * sinPolar, sinAzim * sinPolar, cosPolar); } @Override public Vector3 setToRandomDirection () { float u = MathUtils.random(); float v = MathUtils.random(); float theta = MathUtils.PI2 * u; // azimuthal angle float phi = (float)Math.acos(2f * v - 1f); // polar angle return this.setFromSpherical(theta, phi); } @Override public Vector3 cpy () { return new Vector3(this); } @Override public Vector3 add (final Vector3 vector) { return this.add(vector.x, vector.y, vector.z); } /** Adds the given vector to this component * @param x The x-component of the other vector * @param y The y-component of the other vector * @param z The z-component of the other vector * @return This vector for chaining. */ public Vector3 add (float x, float y, float z) { return this.set(this.x + x, this.y + y, this.z + z); } /** Adds the given value to all three components of the vector. * * @param values The value * @return This vector for chaining */ public Vector3 add (float values) { return this.set(this.x + values, this.y + values, this.z + values); } @Override public Vector3 sub (final Vector3 a_vec) { return this.sub(a_vec.x, a_vec.y, a_vec.z); } /** Subtracts the other vector from this vector. * * @param x The x-component of the other vector * @param y The y-component of the other vector * @param z The z-component of the other vector * @return This vector for chaining */ public Vector3 sub (float x, float y, float z) { return this.set(this.x - x, this.y - y, this.z - z); } /** Subtracts the given value from all components of this vector * * @param value The value * @return This vector for chaining */ public Vector3 sub (float value) { return this.set(this.x - value, this.y - value, this.z - value); } @Override public Vector3 scl (float scalar) { return this.set(this.x * scalar, this.y * scalar, this.z * scalar); } @Override public Vector3 scl (final Vector3 other) { return this.set(x * other.x, y * other.y, z * other.z); } /** Scales this vector by the given values * @param vx X value * @param vy Y value * @param vz Z value * @return This vector for chaining */ public Vector3 scl (float vx, float vy, float vz) { return this.set(this.x * vx, this.y * vy, this.z * vz); } @Override public Vector3 mulAdd (Vector3 vec, float scalar) { this.x += vec.x * scalar; this.y += vec.y * scalar; this.z += vec.z * scalar; return this; } @Override public Vector3 mulAdd (Vector3 vec, Vector3 mulVec) { this.x += vec.x * mulVec.x; this.y += vec.y * mulVec.y; this.z += vec.z * mulVec.z; return this; } /** @return The Euclidean length */ public static float len (final float x, final float y, final float z) { return (float)Math.sqrt(x * x + y * y + z * z); } @Override public float len () { return (float)Math.sqrt(x * x + y * y + z * z); } /** @return The squared Euclidean length */ public static float len2 (final float x, final float y, final float z) { return x * x + y * y + z * z; } @Override public float len2 () { return x * x + y * y + z * z; } /** Returns true if this vector and the vector parameter have identical components. * @param vector The other vector * @return Whether this and the other vector are equal with exact precision */ public boolean idt (final Vector3 vector) { return x == vector.x && y == vector.y && z == vector.z; } /** @return The Euclidean distance between the two specified vectors */ public static float dst (final float x1, final float y1, final float z1, final float x2, final float y2, final float z2) { final float a = x2 - x1; final float b = y2 - y1; final float c = z2 - z1; return (float)Math.sqrt(a * a + b * b + c * c); } @Override public float dst (final Vector3 vector) { final float a = vector.x - x; final float b = vector.y - y; final float c = vector.z - z; return (float)Math.sqrt(a * a + b * b + c * c); } /** @return the distance between this point and the given point */ public float dst (float x, float y, float z) { final float a = x - this.x; final float b = y - this.y; final float c = z - this.z; return (float)Math.sqrt(a * a + b * b + c * c); } /** @return the squared distance between the given points */ public static float dst2 (final float x1, final float y1, final float z1, final float x2, final float y2, final float z2) { final float a = x2 - x1; final float b = y2 - y1; final float c = z2 - z1; return a * a + b * b + c * c; } @Override public float dst2 (Vector3 point) { final float a = point.x - x; final float b = point.y - y; final float c = point.z - z; return a * a + b * b + c * c; } /** Returns the squared distance between this point and the given point * @param x The x-component of the other point * @param y The y-component of the other point * @param z The z-component of the other point * @return The squared distance */ public float dst2 (float x, float y, float z) { final float a = x - this.x; final float b = y - this.y; final float c = z - this.z; return a * a + b * b + c * c; } @Override public Vector3 nor () { final float len2 = this.len2(); if (len2 == 0f || len2 == 1f) return this; return this.scl(1f / (float)Math.sqrt(len2)); } /** @return The dot product between the two vectors */ public static float dot (float x1, float y1, float z1, float x2, float y2, float z2) { return x1 * x2 + y1 * y2 + z1 * z2; } @Override public float dot (final Vector3 vector) { return x * vector.x + y * vector.y + z * vector.z; } /** Returns the dot product between this and the given vector. * @param x The x-component of the other vector * @param y The y-component of the other vector * @param z The z-component of the other vector * @return The dot product */ public float dot (float x, float y, float z) { return this.x * x + this.y * y + this.z * z; } /** Sets this vector to the cross product between it and the other vector. * @param vector The other vector * @return This vector for chaining */ public Vector3 crs (final Vector3 vector) { return this.set(y * vector.z - z * vector.y, z * vector.x - x * vector.z, x * vector.y - y * vector.x); } /** Sets this vector to the cross product between it and the other vector. * @param x The x-component of the other vector * @param y The y-component of the other vector * @param z The z-component of the other vector * @return This vector for chaining */ public Vector3 crs (float x, float y, float z) { return this.set(this.y * z - this.z * y, this.z * x - this.x * z, this.x * y - this.y * x); } /** Left-multiplies the vector by the given 4x3 column major matrix. The matrix should be composed by a 3x3 matrix representing * rotation and scale plus a 1x3 matrix representing the translation. * @param matrix The matrix * @return This vector for chaining */ public Vector3 mul4x3 (float[] matrix) { return set(x * matrix[0] + y * matrix[3] + z * matrix[6] + matrix[9], x * matrix[1] + y * matrix[4] + z * matrix[7] + matrix[10], x * matrix[2] + y * matrix[5] + z * matrix[8] + matrix[11]); } /** Left-multiplies the vector by the given matrix, assuming the fourth (w) component of the vector is 1. * @param matrix The matrix * @return This vector for chaining */ public Vector3 mul (final Matrix4 matrix) { final float[] l_mat = matrix.val; return this.set(x * l_mat[Matrix4.M00] + y * l_mat[Matrix4.M01] + z * l_mat[Matrix4.M02] + l_mat[Matrix4.M03], x * l_mat[Matrix4.M10] + y * l_mat[Matrix4.M11] + z * l_mat[Matrix4.M12] + l_mat[Matrix4.M13], x * l_mat[Matrix4.M20] + y * l_mat[Matrix4.M21] + z * l_mat[Matrix4.M22] + l_mat[Matrix4.M23]); } /** Multiplies the vector by the transpose of the given matrix, assuming the fourth (w) component of the vector is 1. * @param matrix The matrix * @return This vector for chaining */ public Vector3 traMul (final Matrix4 matrix) { final float[] l_mat = matrix.val; return this.set(x * l_mat[Matrix4.M00] + y * l_mat[Matrix4.M10] + z * l_mat[Matrix4.M20] + l_mat[Matrix4.M30], x * l_mat[Matrix4.M01] + y * l_mat[Matrix4.M11] + z * l_mat[Matrix4.M21] + l_mat[Matrix4.M31], x * l_mat[Matrix4.M02] + y * l_mat[Matrix4.M12] + z * l_mat[Matrix4.M22] + l_mat[Matrix4.M32]); } /** Left-multiplies the vector by the given matrix. * @param matrix The matrix * @return This vector for chaining */ public Vector3 mul (Matrix3 matrix) { final float[] l_mat = matrix.val; return set(x * l_mat[Matrix3.M00] + y * l_mat[Matrix3.M01] + z * l_mat[Matrix3.M02], x * l_mat[Matrix3.M10] + y * l_mat[Matrix3.M11] + z * l_mat[Matrix3.M12], x * l_mat[Matrix3.M20] + y * l_mat[Matrix3.M21] + z * l_mat[Matrix3.M22]); } /** Multiplies the vector by the transpose of the given matrix. * @param matrix The matrix * @return This vector for chaining */ public Vector3 traMul (Matrix3 matrix) { final float[] l_mat = matrix.val; return set(x * l_mat[Matrix3.M00] + y * l_mat[Matrix3.M10] + z * l_mat[Matrix3.M20], x * l_mat[Matrix3.M01] + y * l_mat[Matrix3.M11] + z * l_mat[Matrix3.M21], x * l_mat[Matrix3.M02] + y * l_mat[Matrix3.M12] + z * l_mat[Matrix3.M22]); } /** Multiplies the vector by the given {@link Quaternion}. * @return This vector for chaining */ public Vector3 mul (final Quaternion quat) { return quat.transform(this); } /** Multiplies this vector by the given matrix dividing by w, assuming the fourth (w) component of the vector is 1. This is * mostly used to project/unproject vectors via a perspective projection matrix. * * @param matrix The matrix. * @return This vector for chaining */ public Vector3 prj (final Matrix4 matrix) { final float[] l_mat = matrix.val; final float l_w = 1f / (x * l_mat[Matrix4.M30] + y * l_mat[Matrix4.M31] + z * l_mat[Matrix4.M32] + l_mat[Matrix4.M33]); return this.set((x * l_mat[Matrix4.M00] + y * l_mat[Matrix4.M01] + z * l_mat[Matrix4.M02] + l_mat[Matrix4.M03]) * l_w, (x * l_mat[Matrix4.M10] + y * l_mat[Matrix4.M11] + z * l_mat[Matrix4.M12] + l_mat[Matrix4.M13]) * l_w, (x * l_mat[Matrix4.M20] + y * l_mat[Matrix4.M21] + z * l_mat[Matrix4.M22] + l_mat[Matrix4.M23]) * l_w); } /** Multiplies this vector by the first three columns of the matrix, essentially only applying rotation and scaling. * * @param matrix The matrix * @return This vector for chaining */ public Vector3 rot (final Matrix4 matrix) { final float[] l_mat = matrix.val; return this.set(x * l_mat[Matrix4.M00] + y * l_mat[Matrix4.M01] + z * l_mat[Matrix4.M02], x * l_mat[Matrix4.M10] + y * l_mat[Matrix4.M11] + z * l_mat[Matrix4.M12], x * l_mat[Matrix4.M20] + y * l_mat[Matrix4.M21] + z * l_mat[Matrix4.M22]); } /** Multiplies this vector by the transpose of the first three columns of the matrix. Note: only works for translation and * rotation, does not work for scaling. For those, use {@link #rot(Matrix4)} with {@link Matrix4#inv()}. * @param matrix The transformation matrix * @return The vector for chaining */ public Vector3 unrotate (final Matrix4 matrix) { final float[] l_mat = matrix.val; return this.set(x * l_mat[Matrix4.M00] + y * l_mat[Matrix4.M10] + z * l_mat[Matrix4.M20], x * l_mat[Matrix4.M01] + y * l_mat[Matrix4.M11] + z * l_mat[Matrix4.M21], x * l_mat[Matrix4.M02] + y * l_mat[Matrix4.M12] + z * l_mat[Matrix4.M22]); } /** Translates this vector in the direction opposite to the translation of the matrix and the multiplies this vector by the * transpose of the first three columns of the matrix. Note: only works for translation and rotation, does not work for * scaling. For those, use {@link #mul(Matrix4)} with {@link Matrix4#inv()}. * @param matrix The transformation matrix * @return The vector for chaining */ public Vector3 untransform (final Matrix4 matrix) { final float[] l_mat = matrix.val; x -= l_mat[Matrix4.M03]; y -= l_mat[Matrix4.M03]; z -= l_mat[Matrix4.M03]; return this.set(x * l_mat[Matrix4.M00] + y * l_mat[Matrix4.M10] + z * l_mat[Matrix4.M20], x * l_mat[Matrix4.M01] + y * l_mat[Matrix4.M11] + z * l_mat[Matrix4.M21], x * l_mat[Matrix4.M02] + y * l_mat[Matrix4.M12] + z * l_mat[Matrix4.M22]); } /** Rotates this vector by the given angle in degrees around the given axis. * * @param degrees the angle in degrees * @param axisX the x-component of the axis * @param axisY the y-component of the axis * @param axisZ the z-component of the axis * @return This vector for chaining */ public Vector3 rotate (float degrees, float axisX, float axisY, float axisZ) { return this.mul(tmpMat.setToRotation(axisX, axisY, axisZ, degrees)); } /** Rotates this vector by the given angle in radians around the given axis. * * @param radians the angle in radians * @param axisX the x-component of the axis * @param axisY the y-component of the axis * @param axisZ the z-component of the axis * @return This vector for chaining */ public Vector3 rotateRad (float radians, float axisX, float axisY, float axisZ) { return this.mul(tmpMat.setToRotationRad(axisX, axisY, axisZ, radians)); } /** Rotates this vector by the given angle in degrees around the given axis. * * @param axis the axis * @param degrees the angle in degrees * @return This vector for chaining */ public Vector3 rotate (final Vector3 axis, float degrees) { tmpMat.setToRotation(axis, degrees); return this.mul(tmpMat); } /** Rotates this vector by the given angle in radians around the given axis. * * @param axis the axis * @param radians the angle in radians * @return This vector for chaining */ public Vector3 rotateRad (final Vector3 axis, float radians) { tmpMat.setToRotationRad(axis, radians); return this.mul(tmpMat); } @Override public boolean isUnit () { return isUnit(0.000000001f); } @Override public boolean isUnit (final float margin) { return Math.abs(len2() - 1f) < margin; } @Override public boolean isZero () { return x == 0 && y == 0 && z == 0; } @Override public boolean isZero (final float margin) { return len2() < margin; } @Override public boolean isOnLine (Vector3 other, float epsilon) { return len2(y * other.z - z * other.y, z * other.x - x * other.z, x * other.y - y * other.x) <= epsilon; } @Override public boolean isOnLine (Vector3 other) { return len2(y * other.z - z * other.y, z * other.x - x * other.z, x * other.y - y * other.x) <= MathUtils.FLOAT_ROUNDING_ERROR; } @Override public boolean isCollinear (Vector3 other, float epsilon) { return isOnLine(other, epsilon) && hasSameDirection(other); } @Override public boolean isCollinear (Vector3 other) { return isOnLine(other) && hasSameDirection(other); } @Override public boolean isCollinearOpposite (Vector3 other, float epsilon) { return isOnLine(other, epsilon) && hasOppositeDirection(other); } @Override public boolean isCollinearOpposite (Vector3 other) { return isOnLine(other) && hasOppositeDirection(other); } @Override public boolean isPerpendicular (Vector3 vector) { return MathUtils.isZero(dot(vector)); } @Override public boolean isPerpendicular (Vector3 vector, float epsilon) { return MathUtils.isZero(dot(vector), epsilon); } @Override public boolean hasSameDirection (Vector3 vector) { return dot(vector) > 0; } @Override public boolean hasOppositeDirection (Vector3 vector) { return dot(vector) < 0; } @Override public Vector3 lerp (final Vector3 target, float alpha) { x += alpha * (target.x - x); y += alpha * (target.y - y); z += alpha * (target.z - z); return this; } @Override public Vector3 interpolate (Vector3 target, float alpha, Interpolation interpolator) { return lerp(target, interpolator.apply(0f, 1f, alpha)); } /** Spherically interpolates between this vector and the target vector by alpha which is in the range [0,1]. The result is * stored in this vector. * * @param target The target vector * @param alpha The interpolation coefficient * @return This vector for chaining. */ public Vector3 slerp (final Vector3 target, float alpha) { final float dot = dot(target); // If the inputs are too close for comfort, simply linearly interpolate. if (dot > 0.9995 || dot < -0.9995) return lerp(target, alpha); // theta0 = angle between input vectors final float theta0 = (float)Math.acos(dot); // theta = angle between this vector and result final float theta = theta0 * alpha; final float st = (float)Math.sin(theta); final float tx = target.x - x * dot; final float ty = target.y - y * dot; final float tz = target.z - z * dot; final float l2 = tx * tx + ty * ty + tz * tz; final float dl = st * ((l2 < 0.0001f) ? 1f : 1f / (float)Math.sqrt(l2)); return scl((float)Math.cos(theta)).add(tx * dl, ty * dl, tz * dl).nor(); } /** Converts this {@code Vector3} to a string in the format {@code (x,y,z)}. * @return a string representation of this object. */ @Override public String toString () { return "(" + x + "," + y + "," + z + ")"; } /** Sets this {@code Vector3} to the value represented by the specified string according to the format of {@link #toString()}. * @param v the string. * @return this vector for chaining */ public Vector3 fromString (String v) { int s0 = v.indexOf(',', 1); int s1 = v.indexOf(',', s0 + 1); if (s0 != -1 && s1 != -1 && v.charAt(0) == '(' && v.charAt(v.length() - 1) == ')') { try { float x = Float.parseFloat(v.substring(1, s0)); float y = Float.parseFloat(v.substring(s0 + 1, s1)); float z = Float.parseFloat(v.substring(s1 + 1, v.length() - 1)); return this.set(x, y, z); } catch (NumberFormatException ex) { // Throw a GdxRuntimeException } } throw new GdxRuntimeException("Malformed Vector3: " + v); } @Override public Vector3 limit (float limit) { return limit2(limit * limit); } @Override public Vector3 limit2 (float limit2) { float len2 = len2(); if (len2 > limit2) { scl((float)Math.sqrt(limit2 / len2)); } return this; } @Override public Vector3 setLength (float len) { return setLength2(len * len); } @Override public Vector3 setLength2 (float len2) { float oldLen2 = len2(); return (oldLen2 == 0 || oldLen2 == len2) ? this : scl((float)Math.sqrt(len2 / oldLen2)); } @Override public Vector3 clamp (float min, float max) { final float len2 = len2(); if (len2 == 0f) return this; float max2 = max * max; if (len2 > max2) return scl((float)Math.sqrt(max2 / len2)); float min2 = min * min; if (len2 < min2) return scl((float)Math.sqrt(min2 / len2)); return this; } @Override public int hashCode () { final int prime = 31; int result = 1; result = prime * result + NumberUtils.floatToIntBits(x); result = prime * result + NumberUtils.floatToIntBits(y); result = prime * result + NumberUtils.floatToIntBits(z); return result; } @Override public boolean equals (Object obj) { if (this == obj) return true; if (obj == null) return false; if (getClass() != obj.getClass()) return false; Vector3 other = (Vector3)obj; if (NumberUtils.floatToIntBits(x) != NumberUtils.floatToIntBits(other.x)) return false; if (NumberUtils.floatToIntBits(y) != NumberUtils.floatToIntBits(other.y)) return false; if (NumberUtils.floatToIntBits(z) != NumberUtils.floatToIntBits(other.z)) return false; return true; } @Override public boolean epsilonEquals (final Vector3 other, float epsilon) { if (other == null) return false; if (Math.abs(other.x - x) > epsilon) return false; if (Math.abs(other.y - y) > epsilon) return false; if (Math.abs(other.z - z) > epsilon) return false; return true; } /** Compares this vector with the other vector, using the supplied epsilon for fuzzy equality testing. * @return whether the vectors are the same. */ public boolean epsilonEquals (float x, float y, float z, float epsilon) { if (Math.abs(x - this.x) > epsilon) return false; if (Math.abs(y - this.y) > epsilon) return false; if (Math.abs(z - this.z) > epsilon) return false; return true; } /** Compares this vector with the other vector using MathUtils.FLOAT_ROUNDING_ERROR for fuzzy equality testing * * @param other other vector to compare * @return true if vector are equal, otherwise false */ public boolean epsilonEquals (final Vector3 other) { return epsilonEquals(other, MathUtils.FLOAT_ROUNDING_ERROR); } /** Compares this vector with the other vector using MathUtils.FLOAT_ROUNDING_ERROR for fuzzy equality testing * * @param x x component of the other vector to compare * @param y y component of the other vector to compare * @param z z component of the other vector to compare * @return true if vector are equal, otherwise false */ public boolean epsilonEquals (float x, float y, float z) { return epsilonEquals(x, y, z, MathUtils.FLOAT_ROUNDING_ERROR); } @Override public Vector3 setZero () { this.x = 0; this.y = 0; this.z = 0; return this; } }
1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./tests/gdx-tests/src/com/badlogic/gdx/tests/bullet/ImportTest.java
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.tests.bullet; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.assets.loaders.ModelLoader; import com.badlogic.gdx.graphics.g3d.Model; import com.badlogic.gdx.graphics.g3d.ModelInstance; import com.badlogic.gdx.graphics.g3d.loader.G3dModelLoader; import com.badlogic.gdx.math.Matrix4; import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.physics.bullet.collision.btCollisionShape; import com.badlogic.gdx.physics.bullet.dynamics.btDynamicsWorld; import com.badlogic.gdx.physics.bullet.dynamics.btRigidBody; import com.badlogic.gdx.physics.bullet.extras.btBulletWorldImporter; import com.badlogic.gdx.utils.JsonReader; public class ImportTest extends BaseBulletTest { btBulletWorldImporter importer; Model model; public class MyImporter extends btBulletWorldImporter { public MyImporter (btDynamicsWorld world) { super(world); } @Override public btRigidBody createRigidBody (boolean isDynamic, float mass, Matrix4 startTransform, btCollisionShape shape, String bodyName) { Vector3 localInertia = new Vector3(); if (mass > 0f) shape.calculateLocalInertia(mass, localInertia); btRigidBody result = new btRigidBody(mass, null, shape, localInertia); String nodeName = bodyName.split("_", 2)[0] + "_model"; ModelInstance instance = new ModelInstance(model, nodeName, true, true); instance.transform.set(startTransform); BulletEntity entity = new BulletEntity(instance, result); ImportTest.this.world.add(entity); return result; } } @Override public void create () { super.create(); ModelLoader g3djLoader = new G3dModelLoader(new JsonReader()); model = g3djLoader.loadModel(Gdx.files.internal("data/g3d/btscene1.g3dj")); disposables.add(model); importer = new MyImporter((btDynamicsWorld)world.collisionWorld); importer.loadFile(Gdx.files.internal("data/g3d/btscene1.bullet")); camera.position.set(10f, 15f, 20f); camera.up.set(0, 1, 0); camera.lookAt(-10, 8, 0); camera.update(); } @Override public boolean tap (float x, float y, int count, int button) { shoot(x, y); return true; } @Override public void dispose () { super.dispose(); importer.deleteAllData(); importer.dispose(); importer = null; } }
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.tests.bullet; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.assets.loaders.ModelLoader; import com.badlogic.gdx.graphics.g3d.Model; import com.badlogic.gdx.graphics.g3d.ModelInstance; import com.badlogic.gdx.graphics.g3d.loader.G3dModelLoader; import com.badlogic.gdx.math.Matrix4; import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.physics.bullet.collision.btCollisionShape; import com.badlogic.gdx.physics.bullet.dynamics.btDynamicsWorld; import com.badlogic.gdx.physics.bullet.dynamics.btRigidBody; import com.badlogic.gdx.physics.bullet.extras.btBulletWorldImporter; import com.badlogic.gdx.utils.JsonReader; public class ImportTest extends BaseBulletTest { btBulletWorldImporter importer; Model model; public class MyImporter extends btBulletWorldImporter { public MyImporter (btDynamicsWorld world) { super(world); } @Override public btRigidBody createRigidBody (boolean isDynamic, float mass, Matrix4 startTransform, btCollisionShape shape, String bodyName) { Vector3 localInertia = new Vector3(); if (mass > 0f) shape.calculateLocalInertia(mass, localInertia); btRigidBody result = new btRigidBody(mass, null, shape, localInertia); String nodeName = bodyName.split("_", 2)[0] + "_model"; ModelInstance instance = new ModelInstance(model, nodeName, true, true); instance.transform.set(startTransform); BulletEntity entity = new BulletEntity(instance, result); ImportTest.this.world.add(entity); return result; } } @Override public void create () { super.create(); ModelLoader g3djLoader = new G3dModelLoader(new JsonReader()); model = g3djLoader.loadModel(Gdx.files.internal("data/g3d/btscene1.g3dj")); disposables.add(model); importer = new MyImporter((btDynamicsWorld)world.collisionWorld); importer.loadFile(Gdx.files.internal("data/g3d/btscene1.bullet")); camera.position.set(10f, 15f, 20f); camera.up.set(0, 1, 0); camera.lookAt(-10, 8, 0); camera.update(); } @Override public boolean tap (float x, float y, int count, int button) { shoot(x, y); return true; } @Override public void dispose () { super.dispose(); importer.deleteAllData(); importer.dispose(); importer = null; } }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./extensions/gdx-bullet/jni/swig-src/collision/com/badlogic/gdx/physics/bullet/collision/btTriangleInfoMap.java
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.collision; import com.badlogic.gdx.physics.bullet.linearmath.*; public class btTriangleInfoMap extends btHashMapInternalShortBtHashIntBtTriangleInfo { private long swigCPtr; protected btTriangleInfoMap (final String className, long cPtr, boolean cMemoryOwn) { super(className, CollisionJNI.btTriangleInfoMap_SWIGUpcast(cPtr), cMemoryOwn); swigCPtr = cPtr; } /** Construct a new btTriangleInfoMap, normally you should not need this constructor it's intended for low-level usage. */ public btTriangleInfoMap (long cPtr, boolean cMemoryOwn) { this("btTriangleInfoMap", cPtr, cMemoryOwn); construct(); } @Override protected void reset (long cPtr, boolean cMemoryOwn) { if (!destroyed) destroy(); super.reset(CollisionJNI.btTriangleInfoMap_SWIGUpcast(swigCPtr = cPtr), cMemoryOwn); } public static long getCPtr (btTriangleInfoMap obj) { return (obj == null) ? 0 : obj.swigCPtr; } @Override protected void finalize () throws Throwable { if (!destroyed) destroy(); super.finalize(); } @Override protected synchronized void delete () { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; CollisionJNI.delete_btTriangleInfoMap(swigCPtr); } swigCPtr = 0; } super.delete(); } public void setConvexEpsilon (float value) { CollisionJNI.btTriangleInfoMap_convexEpsilon_set(swigCPtr, this, value); } public float getConvexEpsilon () { return CollisionJNI.btTriangleInfoMap_convexEpsilon_get(swigCPtr, this); } public void setPlanarEpsilon (float value) { CollisionJNI.btTriangleInfoMap_planarEpsilon_set(swigCPtr, this, value); } public float getPlanarEpsilon () { return CollisionJNI.btTriangleInfoMap_planarEpsilon_get(swigCPtr, this); } public void setEqualVertexThreshold (float value) { CollisionJNI.btTriangleInfoMap_equalVertexThreshold_set(swigCPtr, this, value); } public float getEqualVertexThreshold () { return CollisionJNI.btTriangleInfoMap_equalVertexThreshold_get(swigCPtr, this); } public void setEdgeDistanceThreshold (float value) { CollisionJNI.btTriangleInfoMap_edgeDistanceThreshold_set(swigCPtr, this, value); } public float getEdgeDistanceThreshold () { return CollisionJNI.btTriangleInfoMap_edgeDistanceThreshold_get(swigCPtr, this); } public void setMaxEdgeAngleThreshold (float value) { CollisionJNI.btTriangleInfoMap_maxEdgeAngleThreshold_set(swigCPtr, this, value); } public float getMaxEdgeAngleThreshold () { return CollisionJNI.btTriangleInfoMap_maxEdgeAngleThreshold_get(swigCPtr, this); } public void setZeroAreaThreshold (float value) { CollisionJNI.btTriangleInfoMap_zeroAreaThreshold_set(swigCPtr, this, value); } public float getZeroAreaThreshold () { return CollisionJNI.btTriangleInfoMap_zeroAreaThreshold_get(swigCPtr, this); } public btTriangleInfoMap () { this(CollisionJNI.new_btTriangleInfoMap(), true); } public int calculateSerializeBufferSize () { return CollisionJNI.btTriangleInfoMap_calculateSerializeBufferSize(swigCPtr, this); } public String serialize (long dataBuffer, btSerializer serializer) { return CollisionJNI.btTriangleInfoMap_serialize(swigCPtr, this, dataBuffer, btSerializer.getCPtr(serializer), serializer); } public void deSerialize (btTriangleInfoMapData data) { CollisionJNI.btTriangleInfoMap_deSerialize(swigCPtr, this, btTriangleInfoMapData.getCPtr(data), data); } }
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.collision; import com.badlogic.gdx.physics.bullet.linearmath.*; public class btTriangleInfoMap extends btHashMapInternalShortBtHashIntBtTriangleInfo { private long swigCPtr; protected btTriangleInfoMap (final String className, long cPtr, boolean cMemoryOwn) { super(className, CollisionJNI.btTriangleInfoMap_SWIGUpcast(cPtr), cMemoryOwn); swigCPtr = cPtr; } /** Construct a new btTriangleInfoMap, normally you should not need this constructor it's intended for low-level usage. */ public btTriangleInfoMap (long cPtr, boolean cMemoryOwn) { this("btTriangleInfoMap", cPtr, cMemoryOwn); construct(); } @Override protected void reset (long cPtr, boolean cMemoryOwn) { if (!destroyed) destroy(); super.reset(CollisionJNI.btTriangleInfoMap_SWIGUpcast(swigCPtr = cPtr), cMemoryOwn); } public static long getCPtr (btTriangleInfoMap obj) { return (obj == null) ? 0 : obj.swigCPtr; } @Override protected void finalize () throws Throwable { if (!destroyed) destroy(); super.finalize(); } @Override protected synchronized void delete () { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; CollisionJNI.delete_btTriangleInfoMap(swigCPtr); } swigCPtr = 0; } super.delete(); } public void setConvexEpsilon (float value) { CollisionJNI.btTriangleInfoMap_convexEpsilon_set(swigCPtr, this, value); } public float getConvexEpsilon () { return CollisionJNI.btTriangleInfoMap_convexEpsilon_get(swigCPtr, this); } public void setPlanarEpsilon (float value) { CollisionJNI.btTriangleInfoMap_planarEpsilon_set(swigCPtr, this, value); } public float getPlanarEpsilon () { return CollisionJNI.btTriangleInfoMap_planarEpsilon_get(swigCPtr, this); } public void setEqualVertexThreshold (float value) { CollisionJNI.btTriangleInfoMap_equalVertexThreshold_set(swigCPtr, this, value); } public float getEqualVertexThreshold () { return CollisionJNI.btTriangleInfoMap_equalVertexThreshold_get(swigCPtr, this); } public void setEdgeDistanceThreshold (float value) { CollisionJNI.btTriangleInfoMap_edgeDistanceThreshold_set(swigCPtr, this, value); } public float getEdgeDistanceThreshold () { return CollisionJNI.btTriangleInfoMap_edgeDistanceThreshold_get(swigCPtr, this); } public void setMaxEdgeAngleThreshold (float value) { CollisionJNI.btTriangleInfoMap_maxEdgeAngleThreshold_set(swigCPtr, this, value); } public float getMaxEdgeAngleThreshold () { return CollisionJNI.btTriangleInfoMap_maxEdgeAngleThreshold_get(swigCPtr, this); } public void setZeroAreaThreshold (float value) { CollisionJNI.btTriangleInfoMap_zeroAreaThreshold_set(swigCPtr, this, value); } public float getZeroAreaThreshold () { return CollisionJNI.btTriangleInfoMap_zeroAreaThreshold_get(swigCPtr, this); } public btTriangleInfoMap () { this(CollisionJNI.new_btTriangleInfoMap(), true); } public int calculateSerializeBufferSize () { return CollisionJNI.btTriangleInfoMap_calculateSerializeBufferSize(swigCPtr, this); } public String serialize (long dataBuffer, btSerializer serializer) { return CollisionJNI.btTriangleInfoMap_serialize(swigCPtr, this, dataBuffer, btSerializer.getCPtr(serializer), serializer); } public void deSerialize (btTriangleInfoMapData data) { CollisionJNI.btTriangleInfoMap_deSerialize(swigCPtr, this, btTriangleInfoMapData.getCPtr(data), data); } }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./backends/gdx-backend-lwjgl/src/com/badlogic/gdx/backends/lwjgl/LwjglFrame.java
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.backends.lwjgl; import java.io.PrintWriter; import java.io.StringWriter; import javax.swing.JFrame; import org.lwjgl.opengl.Display; import com.badlogic.gdx.ApplicationListener; import java.awt.Dimension; import java.awt.EventQueue; import java.awt.GraphicsConfiguration; import java.awt.Point; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.geom.AffineTransform; /** Wraps an {@link LwjglCanvas} in a resizable {@link JFrame}. */ public class LwjglFrame extends JFrame { LwjglCanvas lwjglCanvas; private Thread shutdownHook; public LwjglFrame (ApplicationListener listener, String title, int width, int height) { super(title); LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); config.title = title; config.width = width; config.height = height; construct(listener, config); } public LwjglFrame (ApplicationListener listener, LwjglApplicationConfiguration config) { super(config.title); construct(listener, config); } /** @param graphicsConfig May be null. */ public LwjglFrame (ApplicationListener listener, LwjglApplicationConfiguration config, GraphicsConfiguration graphicsConfig) { super(config.title, graphicsConfig); construct(listener, config); } private void construct (ApplicationListener listener, LwjglApplicationConfiguration config) { lwjglCanvas = new LwjglCanvas(listener, config) { protected void stopped () { LwjglFrame.this.dispose(); } protected void setTitle (String title) { LwjglFrame.this.setTitle(title); } protected void setDisplayMode (int width, int height) { Dimension size = new Dimension(Math.round(width / scaleX), Math.round(height / scaleY)); LwjglFrame.this.getContentPane().setPreferredSize(size); LwjglFrame.this.getContentPane().invalidate(); LwjglFrame.this.pack(); LwjglFrame.this.setLocationRelativeTo(null); updateSize(width, height); } protected void resize (int width, int height) { updateSize(width, height); } protected void create () { LwjglFrame.this.creating(); super.create(); } protected void start () { LwjglFrame.this.start(); } protected void disposed () { LwjglFrame.this.disposed(); } protected void exception (Throwable t) { LwjglFrame.this.exception(t); } protected void postedException (Throwable ex, Throwable caller) { LwjglFrame.this.postedException(ex, caller); } protected int getFrameRate () { int frameRate = LwjglFrame.this.getFrameRate(); return frameRate == 0 ? super.getFrameRate() : frameRate; } public LwjglInput createInput (LwjglApplicationConfiguration config) { return LwjglFrame.this.createInput(config); } }; setHaltOnShutdown(true); setDefaultCloseOperation(EXIT_ON_CLOSE); AffineTransform transform = getGraphicsConfiguration().getDefaultTransform(); float scaleX = (float)transform.getScaleX(), scaleY = (float)transform.getScaleY(); Dimension size = new Dimension(Math.round(config.width / scaleX), Math.round(config.height / scaleY)); getContentPane().setPreferredSize(size); initialize(); pack(); Point location = getLocation(); if (location.x == 0 && location.y == 0) setLocationRelativeTo(null); lwjglCanvas.getCanvas().setSize(size); addWindowFocusListener(new WindowAdapter() { public void windowLostFocus (WindowEvent event) { // Display.reshape sizes and positions the OpenGL window to match the canvas. // Normally Display.reshape is called from Display.update when the size changes, but LwjglCanvas doesn't call // Display.update when rendering is not needed because it also swaps buffers and would flicker. // After losing focus rendering may not be needed so Display.reshape must be called, else the OpenGL window may be // left in the wrong place. // Display.setLocation calls Display.reshape, despite javadocs saying it's a no-op when a canvas is set. if (Display.isCreated()) { Display.setLocation(0, 0); lwjglCanvas.graphics.requestRendering(); } } }); // Finish with invokeLater so any LwjglFrame super constructor has a chance to initialize. EventQueue.invokeLater(new Runnable() { public void run () { addCanvas(); setVisible(true); try { lwjglCanvas.getCanvas().requestFocus(); } catch (Throwable ignored) { // Fails on Linux sometimes, seems shared lib isn't loaded for LinuxDisplay#callErrorHandler. } } }); } protected void creating () { } public void reshape (int x, int y, int width, int height) { super.reshape(x, y, width, height); revalidate(); } /** When true, <code>Runtime.getRuntime().halt(0);</code> is used when the JVM shuts down. This prevents Swing shutdown hooks * from causing a deadlock and keeping the JVM alive indefinitely. Default is true. */ public void setHaltOnShutdown (boolean halt) { try { try { if (halt) { if (shutdownHook != null) return; shutdownHook = new Thread() { public void run () { Runtime.getRuntime().halt(0); } }; Runtime.getRuntime().addShutdownHook(shutdownHook); } else if (shutdownHook != null) { Runtime.getRuntime().removeShutdownHook(shutdownHook); shutdownHook = null; } } catch (Throwable ignored) { // Can happen if already shutting down. } } catch (IllegalStateException ex) { shutdownHook = null; } } protected int getFrameRate () { return 0; } public LwjglInput createInput (LwjglApplicationConfiguration config) { return new DefaultLwjglInput(); } protected void exception (Throwable ex) { ex.printStackTrace(); lwjglCanvas.stop(); } protected void postedException (Throwable ex, Throwable caller) { if (caller == null) throw new RuntimeException(ex); StringWriter buffer = new StringWriter(1024); caller.printStackTrace(new PrintWriter(buffer)); throw new RuntimeException("Posted: " + buffer, ex); } /** Called before the JFrame is made displayable. */ protected void initialize () { } /** Adds the canvas to the content pane. This triggers addNotify and starts the canvas' game loop. */ protected void addCanvas () { getContentPane().add(lwjglCanvas.getCanvas()); } /** Called after {@link ApplicationListener} create and resize, but before the game loop iteration. */ protected void start () { } /** Called when the canvas size changes. */ public void updateSize (int width, int height) { } /** Called after dispose is complete. */ protected void disposed () { } public LwjglCanvas getLwjglCanvas () { return lwjglCanvas; } }
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.backends.lwjgl; import java.io.PrintWriter; import java.io.StringWriter; import javax.swing.JFrame; import org.lwjgl.opengl.Display; import com.badlogic.gdx.ApplicationListener; import java.awt.Dimension; import java.awt.EventQueue; import java.awt.GraphicsConfiguration; import java.awt.Point; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.awt.geom.AffineTransform; /** Wraps an {@link LwjglCanvas} in a resizable {@link JFrame}. */ public class LwjglFrame extends JFrame { LwjglCanvas lwjglCanvas; private Thread shutdownHook; public LwjglFrame (ApplicationListener listener, String title, int width, int height) { super(title); LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); config.title = title; config.width = width; config.height = height; construct(listener, config); } public LwjglFrame (ApplicationListener listener, LwjglApplicationConfiguration config) { super(config.title); construct(listener, config); } /** @param graphicsConfig May be null. */ public LwjglFrame (ApplicationListener listener, LwjglApplicationConfiguration config, GraphicsConfiguration graphicsConfig) { super(config.title, graphicsConfig); construct(listener, config); } private void construct (ApplicationListener listener, LwjglApplicationConfiguration config) { lwjglCanvas = new LwjglCanvas(listener, config) { protected void stopped () { LwjglFrame.this.dispose(); } protected void setTitle (String title) { LwjglFrame.this.setTitle(title); } protected void setDisplayMode (int width, int height) { Dimension size = new Dimension(Math.round(width / scaleX), Math.round(height / scaleY)); LwjglFrame.this.getContentPane().setPreferredSize(size); LwjglFrame.this.getContentPane().invalidate(); LwjglFrame.this.pack(); LwjglFrame.this.setLocationRelativeTo(null); updateSize(width, height); } protected void resize (int width, int height) { updateSize(width, height); } protected void create () { LwjglFrame.this.creating(); super.create(); } protected void start () { LwjglFrame.this.start(); } protected void disposed () { LwjglFrame.this.disposed(); } protected void exception (Throwable t) { LwjglFrame.this.exception(t); } protected void postedException (Throwable ex, Throwable caller) { LwjglFrame.this.postedException(ex, caller); } protected int getFrameRate () { int frameRate = LwjglFrame.this.getFrameRate(); return frameRate == 0 ? super.getFrameRate() : frameRate; } public LwjglInput createInput (LwjglApplicationConfiguration config) { return LwjglFrame.this.createInput(config); } }; setHaltOnShutdown(true); setDefaultCloseOperation(EXIT_ON_CLOSE); AffineTransform transform = getGraphicsConfiguration().getDefaultTransform(); float scaleX = (float)transform.getScaleX(), scaleY = (float)transform.getScaleY(); Dimension size = new Dimension(Math.round(config.width / scaleX), Math.round(config.height / scaleY)); getContentPane().setPreferredSize(size); initialize(); pack(); Point location = getLocation(); if (location.x == 0 && location.y == 0) setLocationRelativeTo(null); lwjglCanvas.getCanvas().setSize(size); addWindowFocusListener(new WindowAdapter() { public void windowLostFocus (WindowEvent event) { // Display.reshape sizes and positions the OpenGL window to match the canvas. // Normally Display.reshape is called from Display.update when the size changes, but LwjglCanvas doesn't call // Display.update when rendering is not needed because it also swaps buffers and would flicker. // After losing focus rendering may not be needed so Display.reshape must be called, else the OpenGL window may be // left in the wrong place. // Display.setLocation calls Display.reshape, despite javadocs saying it's a no-op when a canvas is set. if (Display.isCreated()) { Display.setLocation(0, 0); lwjglCanvas.graphics.requestRendering(); } } }); // Finish with invokeLater so any LwjglFrame super constructor has a chance to initialize. EventQueue.invokeLater(new Runnable() { public void run () { addCanvas(); setVisible(true); try { lwjglCanvas.getCanvas().requestFocus(); } catch (Throwable ignored) { // Fails on Linux sometimes, seems shared lib isn't loaded for LinuxDisplay#callErrorHandler. } } }); } protected void creating () { } public void reshape (int x, int y, int width, int height) { super.reshape(x, y, width, height); revalidate(); } /** When true, <code>Runtime.getRuntime().halt(0);</code> is used when the JVM shuts down. This prevents Swing shutdown hooks * from causing a deadlock and keeping the JVM alive indefinitely. Default is true. */ public void setHaltOnShutdown (boolean halt) { try { try { if (halt) { if (shutdownHook != null) return; shutdownHook = new Thread() { public void run () { Runtime.getRuntime().halt(0); } }; Runtime.getRuntime().addShutdownHook(shutdownHook); } else if (shutdownHook != null) { Runtime.getRuntime().removeShutdownHook(shutdownHook); shutdownHook = null; } } catch (Throwable ignored) { // Can happen if already shutting down. } } catch (IllegalStateException ex) { shutdownHook = null; } } protected int getFrameRate () { return 0; } public LwjglInput createInput (LwjglApplicationConfiguration config) { return new DefaultLwjglInput(); } protected void exception (Throwable ex) { ex.printStackTrace(); lwjglCanvas.stop(); } protected void postedException (Throwable ex, Throwable caller) { if (caller == null) throw new RuntimeException(ex); StringWriter buffer = new StringWriter(1024); caller.printStackTrace(new PrintWriter(buffer)); throw new RuntimeException("Posted: " + buffer, ex); } /** Called before the JFrame is made displayable. */ protected void initialize () { } /** Adds the canvas to the content pane. This triggers addNotify and starts the canvas' game loop. */ protected void addCanvas () { getContentPane().add(lwjglCanvas.getCanvas()); } /** Called after {@link ApplicationListener} create and resize, but before the game loop iteration. */ protected void start () { } /** Called when the canvas size changes. */ public void updateSize (int width, int height) { } /** Called after dispose is complete. */ protected void disposed () { } public LwjglCanvas getLwjglCanvas () { return lwjglCanvas; } }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./extensions/gdx-box2d/gdx-box2d-gwt/src/com/badlogic/gdx/physics/box2d/gwt/emu/org/jbox2d/dynamics/Profile.java
/******************************************************************************* * Copyright (c) 2013, Daniel Murphy * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. ******************************************************************************/ package org.jbox2d.dynamics; import java.util.List; import org.jbox2d.common.MathUtils; public class Profile { private static final int LONG_AVG_NUMS = 20; private static final float LONG_FRACTION = 1f / LONG_AVG_NUMS; private static final int SHORT_AVG_NUMS = 5; private static final float SHORT_FRACTION = 1f / SHORT_AVG_NUMS; public static class ProfileEntry { float longAvg; float shortAvg; float min; float max; float accum; public ProfileEntry () { min = Float.MAX_VALUE; max = -Float.MAX_VALUE; } public void record (float value) { longAvg = longAvg * (1 - LONG_FRACTION) + value * LONG_FRACTION; shortAvg = shortAvg * (1 - SHORT_FRACTION) + value * SHORT_FRACTION; min = MathUtils.min(value, min); max = MathUtils.max(value, max); } public void startAccum () { accum = 0; } public void accum (float value) { accum += value; } public void endAccum () { record(accum); } @Override public String toString () { return shortAvg + " (" + longAvg + ") [" + min + "," + max + "]"; } } public final ProfileEntry step = new ProfileEntry(); public final ProfileEntry stepInit = new ProfileEntry(); public final ProfileEntry collide = new ProfileEntry(); public final ProfileEntry solveParticleSystem = new ProfileEntry(); public final ProfileEntry solve = new ProfileEntry(); public final ProfileEntry solveInit = new ProfileEntry(); public final ProfileEntry solveVelocity = new ProfileEntry(); public final ProfileEntry solvePosition = new ProfileEntry(); public final ProfileEntry broadphase = new ProfileEntry(); public final ProfileEntry solveTOI = new ProfileEntry(); public void toDebugStrings (List<String> strings) { strings.add("Profile:"); strings.add(" step: " + step); strings.add(" init: " + stepInit); strings.add(" collide: " + collide); strings.add(" particles: " + solveParticleSystem); strings.add(" solve: " + solve); strings.add(" solveInit: " + solveInit); strings.add(" solveVelocity: " + solveVelocity); strings.add(" solvePosition: " + solvePosition); strings.add(" broadphase: " + broadphase); strings.add(" solveTOI: " + solveTOI); } }
/******************************************************************************* * Copyright (c) 2013, Daniel Murphy * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. ******************************************************************************/ package org.jbox2d.dynamics; import java.util.List; import org.jbox2d.common.MathUtils; public class Profile { private static final int LONG_AVG_NUMS = 20; private static final float LONG_FRACTION = 1f / LONG_AVG_NUMS; private static final int SHORT_AVG_NUMS = 5; private static final float SHORT_FRACTION = 1f / SHORT_AVG_NUMS; public static class ProfileEntry { float longAvg; float shortAvg; float min; float max; float accum; public ProfileEntry () { min = Float.MAX_VALUE; max = -Float.MAX_VALUE; } public void record (float value) { longAvg = longAvg * (1 - LONG_FRACTION) + value * LONG_FRACTION; shortAvg = shortAvg * (1 - SHORT_FRACTION) + value * SHORT_FRACTION; min = MathUtils.min(value, min); max = MathUtils.max(value, max); } public void startAccum () { accum = 0; } public void accum (float value) { accum += value; } public void endAccum () { record(accum); } @Override public String toString () { return shortAvg + " (" + longAvg + ") [" + min + "," + max + "]"; } } public final ProfileEntry step = new ProfileEntry(); public final ProfileEntry stepInit = new ProfileEntry(); public final ProfileEntry collide = new ProfileEntry(); public final ProfileEntry solveParticleSystem = new ProfileEntry(); public final ProfileEntry solve = new ProfileEntry(); public final ProfileEntry solveInit = new ProfileEntry(); public final ProfileEntry solveVelocity = new ProfileEntry(); public final ProfileEntry solvePosition = new ProfileEntry(); public final ProfileEntry broadphase = new ProfileEntry(); public final ProfileEntry solveTOI = new ProfileEntry(); public void toDebugStrings (List<String> strings) { strings.add("Profile:"); strings.add(" step: " + step); strings.add(" init: " + stepInit); strings.add(" collide: " + collide); strings.add(" particles: " + solveParticleSystem); strings.add(" solve: " + solve); strings.add(" solveInit: " + solveInit); strings.add(" solveVelocity: " + solveVelocity); strings.add(" solvePosition: " + solvePosition); strings.add(" broadphase: " + broadphase); strings.add(" solveTOI: " + solveTOI); } }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./tests/gdx-tests/src/com/badlogic/gdx/tests/bullet/FrustumCullingTest.java
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.tests.bullet; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.PerspectiveCamera; import com.badlogic.gdx.graphics.VertexAttributes.Usage; import com.badlogic.gdx.graphics.g3d.Material; import com.badlogic.gdx.graphics.g3d.Model; import com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute; import com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder; import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder; import com.badlogic.gdx.math.Matrix4; import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.physics.bullet.collision.btBroadphasePairArray; import com.badlogic.gdx.physics.bullet.collision.btCollisionDispatcher; import com.badlogic.gdx.physics.bullet.collision.btCollisionObject; import com.badlogic.gdx.physics.bullet.collision.btCollisionShape; import com.badlogic.gdx.physics.bullet.collision.btCollisionWorld; import com.badlogic.gdx.physics.bullet.collision.btCompoundShape; import com.badlogic.gdx.physics.bullet.collision.btConvexHullShape; import com.badlogic.gdx.physics.bullet.collision.btDbvtBroadphase; import com.badlogic.gdx.physics.bullet.collision.btDefaultCollisionConfiguration; import com.badlogic.gdx.physics.bullet.collision.btPairCachingGhostObject; import com.badlogic.gdx.physics.bullet.collision.btPersistentManifoldArray; import com.badlogic.gdx.utils.Array; /** @author Xoppa */ public class FrustumCullingTest extends BaseBulletTest { /** Only show entities inside the frustum */ final static int CULL_FRUSTUM = 1; /** Transform the render cam with the frustum */ final static int FRUSTUM_CAM = 2; final static boolean USE_BULLET_FRUSTUM_CULLING = true; int state = 0; // 0 = No culling, look from above final static int BOXCOUNT = 200; final static float BOX_X_MIN = -25; final static float BOX_Y_MIN = -25; final static float BOX_Z_MIN = -25; final static float BOX_X_MAX = 25; final static float BOX_Y_MAX = 25; final static float BOX_Z_MAX = 25; final static float SPEED_X = 360f / 7f; final static float SPEED_Y = 360f / 19f; final static float SPEED_Z = 360f / 13f; final static Vector3 tmpV = new Vector3(); final static Matrix4 tmpM = new Matrix4(); final static int ptrs[] = new int[512]; final static Array<btCollisionObject> visibleObjects = new Array<btCollisionObject>(); public static btPairCachingGhostObject createFrustumObject (final Vector3... points) { final btPairCachingGhostObject result = new TestPairCachingGhostObject(); final boolean USE_COMPOUND = true; // Using a compound shape is not necessary, but it's good practice to create shapes around the center. if (USE_COMPOUND) { final Vector3 centerNear = new Vector3(points[2]).sub(points[0]).scl(0.5f).add(points[0]); final Vector3 centerFar = new Vector3(points[6]).sub(points[4]).scl(0.5f).add(points[4]); final Vector3 center = new Vector3(centerFar).sub(centerNear).scl(0.5f).add(centerNear); final btConvexHullShape hullShape = new btConvexHullShape(); for (int i = 0; i < points.length; i++) hullShape.addPoint(tmpV.set(points[i]).sub(center)); final btCompoundShape shape = new btCompoundShape(); shape.addChildShape(tmpM.setToTranslation(center), hullShape); result.setCollisionShape(shape); } else { final btConvexHullShape shape = new btConvexHullShape(); for (int i = 0; i < points.length; i++) shape.addPoint(points[i]); result.setCollisionShape(shape); } result.setCollisionFlags(btCollisionObject.CollisionFlags.CF_NO_CONTACT_RESPONSE); return result; } public static Array<BulletEntity> getEntitiesCollidingWithObject (final BulletWorld world, final btCollisionObject object, final Array<BulletEntity> out, final btPersistentManifoldArray tmpArr) { // Fetch the array of contacts btBroadphasePairArray arr = world.broadphase.getOverlappingPairCache().getOverlappingPairArray(); // Get the user values (which are indices in the entities array) of all objects colliding with the object final int n = arr.getCollisionObjectsValue(ptrs, object); // Fill the array of entities out.clear(); for (int i = 0; i < n; i++) out.add(world.entities.get(ptrs[i])); return out; } public static Model createFrustumModel (final Vector3... p) { ModelBuilder builder = new ModelBuilder(); builder.begin(); MeshPartBuilder mpb = builder.part("", GL20.GL_LINES, Usage.Position | Usage.Normal, new Material(new ColorAttribute(ColorAttribute.Diffuse, Color.WHITE))); mpb.vertex(p[0].x, p[0].y, p[0].z, 0, 0, 1, p[1].x, p[1].y, p[1].z, 0, 0, 1, p[2].x, p[2].y, p[2].z, 0, 0, 1, p[3].x, p[3].y, p[3].z, 0, 0, 1, // near p[4].x, p[4].y, p[4].z, 0, 0, -1, p[5].x, p[5].y, p[5].z, 0, 0, -1, p[6].x, p[6].y, p[6].z, 0, 0, -1, p[7].x, p[7].y, p[7].z, 0, 0, -1); mpb.index((short)0, (short)1, (short)1, (short)2, (short)2, (short)3, (short)3, (short)0); mpb.index((short)4, (short)5, (short)5, (short)6, (short)6, (short)7, (short)7, (short)4); mpb.index((short)0, (short)4, (short)1, (short)5, (short)2, (short)6, (short)3, (short)7); return builder.end(); } private float angleX, angleY, angleZ; private btPairCachingGhostObject frustumObject; private BulletEntity frustumEntity; private final Array<BulletEntity> visibleEntities = new Array<BulletEntity>(); private btPersistentManifoldArray tempManifoldArr; private PerspectiveCamera frustumCam; private PerspectiveCamera overviewCam; @Override public void create () { super.create(); instructions = "Tap to toggle view\nLong press to toggle debug mode\nSwipe for next test\nCtrl+drag to rotate\nScroll to zoom"; tempManifoldArr = new btPersistentManifoldArray(); world.addConstructor("collisionBox", new BulletConstructor(world.getConstructor("box").model)); // Create the entities final float dX = BOX_X_MAX - BOX_X_MIN; final float dY = BOX_Y_MAX - BOX_Y_MIN; final float dZ = BOX_Z_MAX - BOX_Z_MIN; for (int i = 0; i < BOXCOUNT; i++) world.add("collisionBox", BOX_X_MIN + dX * (float)Math.random(), BOX_Y_MIN + dY * (float)Math.random(), BOX_Z_MIN + dZ * (float)Math.random()).setColor(Color.GRAY); frustumCam = new PerspectiveCamera(camera.fieldOfView, camera.viewportWidth, camera.viewportHeight); frustumCam.far = Vector3.len(BOX_X_MAX, BOX_Y_MAX, BOX_Z_MAX); frustumCam.update(); overviewCam = camera; overviewCam.position.set(BOX_X_MAX, BOX_Y_MAX, BOX_Z_MAX); overviewCam.lookAt(Vector3.Zero); overviewCam.far = 150f; overviewCam.update(); final Model frustumModel = createFrustumModel(frustumCam.frustum.planePoints); disposables.add(frustumModel); frustumObject = createFrustumObject(frustumCam.frustum.planePoints); world.add(frustumEntity = new BulletEntity(frustumModel, frustumObject, 0, 0, 0)); frustumEntity.setColor(Color.BLUE); } @Override public BulletWorld createWorld () { // No need to use dynamics for this test btDbvtBroadphase broadphase = new btDbvtBroadphase(); btDefaultCollisionConfiguration collisionConfig = new btDefaultCollisionConfiguration(); btCollisionDispatcher dispatcher = new btCollisionDispatcher(collisionConfig); btCollisionWorld collisionWorld = new btCollisionWorld(dispatcher, broadphase, collisionConfig); return new BulletWorld(collisionConfig, dispatcher, broadphase, null, collisionWorld); } @Override public void update () { super.update(); // Not using dynamics, so update the collision world manually if (USE_BULLET_FRUSTUM_CULLING) { if (world.performanceCounter != null) world.performanceCounter.start(); world.collisionWorld.performDiscreteCollisionDetection(); if (world.performanceCounter != null) world.performanceCounter.stop(); } } @Override public void render () { final float dt = Gdx.graphics.getDeltaTime(); frustumEntity.transform.idt(); frustumEntity.transform.rotate(Vector3.X, angleX = (angleX + dt * SPEED_X) % 360); frustumEntity.transform.rotate(Vector3.Y, angleY = (angleY + dt * SPEED_Y) % 360); frustumEntity.transform.rotate(Vector3.Z, angleZ = (angleZ + dt * SPEED_Z) % 360); // Transform the ghost object frustumEntity.body.setWorldTransform(frustumEntity.transform); // Transform the frustum cam frustumCam.direction.set(0, 0, -1); frustumCam.up.set(0, 1, 0); frustumCam.position.set(0, 0, 0); frustumCam.rotate(frustumEntity.transform); frustumCam.update(); super.render(); performance.append(" visible: ").append(visibleEntities.size); } @Override protected void renderWorld () { if (world.performanceCounter != null) world.performanceCounter.start(); if (USE_BULLET_FRUSTUM_CULLING) getEntitiesCollidingWithObject(world, frustumObject, visibleEntities, tempManifoldArr); else { visibleEntities.clear(); for (int i = 0; i < world.entities.size; i++) { final BulletEntity e = world.entities.get(i); if (e == frustumEntity) continue; e.modelInstance.transform.getTranslation(tmpV); if (frustumCam.frustum.sphereInFrustum(tmpV, 1)) visibleEntities.add(e); } } if (world.performanceCounter != null) world.performanceCounter.stop(); for (int i = 0; i < visibleEntities.size; i++) visibleEntities.get(i).setColor(Color.RED); modelBatch.begin(camera); if ((state & CULL_FRUSTUM) == CULL_FRUSTUM) { world.render(modelBatch, environment, visibleEntities); world.render(modelBatch, environment, frustumEntity); } else world.render(modelBatch, environment); modelBatch.end(); for (int i = 0; i < visibleEntities.size; i++) visibleEntities.get(i).setColor(Color.GRAY); } @Override protected void beginRender (boolean lighting) { super.beginRender(false); } @Override public void dispose () { frustumObject = null; super.dispose(); if (tempManifoldArr != null) tempManifoldArr.dispose(); tempManifoldArr = null; } @Override public boolean tap (float x, float y, int count, int button) { state = (state + 1) % 3; if ((state & FRUSTUM_CAM) == FRUSTUM_CAM) camera = frustumCam; else camera = overviewCam; return true; } // Simple helper class to keep a reference to the collision shape public static class TestPairCachingGhostObject extends btPairCachingGhostObject { public btCollisionShape shape; @Override public void setCollisionShape (btCollisionShape collisionShape) { shape = collisionShape; super.setCollisionShape(collisionShape); } @Override public void dispose () { super.dispose(); if (shape != null) shape.dispose(); shape = null; } } }
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.tests.bullet; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.PerspectiveCamera; import com.badlogic.gdx.graphics.VertexAttributes.Usage; import com.badlogic.gdx.graphics.g3d.Material; import com.badlogic.gdx.graphics.g3d.Model; import com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute; import com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder; import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder; import com.badlogic.gdx.math.Matrix4; import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.physics.bullet.collision.btBroadphasePairArray; import com.badlogic.gdx.physics.bullet.collision.btCollisionDispatcher; import com.badlogic.gdx.physics.bullet.collision.btCollisionObject; import com.badlogic.gdx.physics.bullet.collision.btCollisionShape; import com.badlogic.gdx.physics.bullet.collision.btCollisionWorld; import com.badlogic.gdx.physics.bullet.collision.btCompoundShape; import com.badlogic.gdx.physics.bullet.collision.btConvexHullShape; import com.badlogic.gdx.physics.bullet.collision.btDbvtBroadphase; import com.badlogic.gdx.physics.bullet.collision.btDefaultCollisionConfiguration; import com.badlogic.gdx.physics.bullet.collision.btPairCachingGhostObject; import com.badlogic.gdx.physics.bullet.collision.btPersistentManifoldArray; import com.badlogic.gdx.utils.Array; /** @author Xoppa */ public class FrustumCullingTest extends BaseBulletTest { /** Only show entities inside the frustum */ final static int CULL_FRUSTUM = 1; /** Transform the render cam with the frustum */ final static int FRUSTUM_CAM = 2; final static boolean USE_BULLET_FRUSTUM_CULLING = true; int state = 0; // 0 = No culling, look from above final static int BOXCOUNT = 200; final static float BOX_X_MIN = -25; final static float BOX_Y_MIN = -25; final static float BOX_Z_MIN = -25; final static float BOX_X_MAX = 25; final static float BOX_Y_MAX = 25; final static float BOX_Z_MAX = 25; final static float SPEED_X = 360f / 7f; final static float SPEED_Y = 360f / 19f; final static float SPEED_Z = 360f / 13f; final static Vector3 tmpV = new Vector3(); final static Matrix4 tmpM = new Matrix4(); final static int ptrs[] = new int[512]; final static Array<btCollisionObject> visibleObjects = new Array<btCollisionObject>(); public static btPairCachingGhostObject createFrustumObject (final Vector3... points) { final btPairCachingGhostObject result = new TestPairCachingGhostObject(); final boolean USE_COMPOUND = true; // Using a compound shape is not necessary, but it's good practice to create shapes around the center. if (USE_COMPOUND) { final Vector3 centerNear = new Vector3(points[2]).sub(points[0]).scl(0.5f).add(points[0]); final Vector3 centerFar = new Vector3(points[6]).sub(points[4]).scl(0.5f).add(points[4]); final Vector3 center = new Vector3(centerFar).sub(centerNear).scl(0.5f).add(centerNear); final btConvexHullShape hullShape = new btConvexHullShape(); for (int i = 0; i < points.length; i++) hullShape.addPoint(tmpV.set(points[i]).sub(center)); final btCompoundShape shape = new btCompoundShape(); shape.addChildShape(tmpM.setToTranslation(center), hullShape); result.setCollisionShape(shape); } else { final btConvexHullShape shape = new btConvexHullShape(); for (int i = 0; i < points.length; i++) shape.addPoint(points[i]); result.setCollisionShape(shape); } result.setCollisionFlags(btCollisionObject.CollisionFlags.CF_NO_CONTACT_RESPONSE); return result; } public static Array<BulletEntity> getEntitiesCollidingWithObject (final BulletWorld world, final btCollisionObject object, final Array<BulletEntity> out, final btPersistentManifoldArray tmpArr) { // Fetch the array of contacts btBroadphasePairArray arr = world.broadphase.getOverlappingPairCache().getOverlappingPairArray(); // Get the user values (which are indices in the entities array) of all objects colliding with the object final int n = arr.getCollisionObjectsValue(ptrs, object); // Fill the array of entities out.clear(); for (int i = 0; i < n; i++) out.add(world.entities.get(ptrs[i])); return out; } public static Model createFrustumModel (final Vector3... p) { ModelBuilder builder = new ModelBuilder(); builder.begin(); MeshPartBuilder mpb = builder.part("", GL20.GL_LINES, Usage.Position | Usage.Normal, new Material(new ColorAttribute(ColorAttribute.Diffuse, Color.WHITE))); mpb.vertex(p[0].x, p[0].y, p[0].z, 0, 0, 1, p[1].x, p[1].y, p[1].z, 0, 0, 1, p[2].x, p[2].y, p[2].z, 0, 0, 1, p[3].x, p[3].y, p[3].z, 0, 0, 1, // near p[4].x, p[4].y, p[4].z, 0, 0, -1, p[5].x, p[5].y, p[5].z, 0, 0, -1, p[6].x, p[6].y, p[6].z, 0, 0, -1, p[7].x, p[7].y, p[7].z, 0, 0, -1); mpb.index((short)0, (short)1, (short)1, (short)2, (short)2, (short)3, (short)3, (short)0); mpb.index((short)4, (short)5, (short)5, (short)6, (short)6, (short)7, (short)7, (short)4); mpb.index((short)0, (short)4, (short)1, (short)5, (short)2, (short)6, (short)3, (short)7); return builder.end(); } private float angleX, angleY, angleZ; private btPairCachingGhostObject frustumObject; private BulletEntity frustumEntity; private final Array<BulletEntity> visibleEntities = new Array<BulletEntity>(); private btPersistentManifoldArray tempManifoldArr; private PerspectiveCamera frustumCam; private PerspectiveCamera overviewCam; @Override public void create () { super.create(); instructions = "Tap to toggle view\nLong press to toggle debug mode\nSwipe for next test\nCtrl+drag to rotate\nScroll to zoom"; tempManifoldArr = new btPersistentManifoldArray(); world.addConstructor("collisionBox", new BulletConstructor(world.getConstructor("box").model)); // Create the entities final float dX = BOX_X_MAX - BOX_X_MIN; final float dY = BOX_Y_MAX - BOX_Y_MIN; final float dZ = BOX_Z_MAX - BOX_Z_MIN; for (int i = 0; i < BOXCOUNT; i++) world.add("collisionBox", BOX_X_MIN + dX * (float)Math.random(), BOX_Y_MIN + dY * (float)Math.random(), BOX_Z_MIN + dZ * (float)Math.random()).setColor(Color.GRAY); frustumCam = new PerspectiveCamera(camera.fieldOfView, camera.viewportWidth, camera.viewportHeight); frustumCam.far = Vector3.len(BOX_X_MAX, BOX_Y_MAX, BOX_Z_MAX); frustumCam.update(); overviewCam = camera; overviewCam.position.set(BOX_X_MAX, BOX_Y_MAX, BOX_Z_MAX); overviewCam.lookAt(Vector3.Zero); overviewCam.far = 150f; overviewCam.update(); final Model frustumModel = createFrustumModel(frustumCam.frustum.planePoints); disposables.add(frustumModel); frustumObject = createFrustumObject(frustumCam.frustum.planePoints); world.add(frustumEntity = new BulletEntity(frustumModel, frustumObject, 0, 0, 0)); frustumEntity.setColor(Color.BLUE); } @Override public BulletWorld createWorld () { // No need to use dynamics for this test btDbvtBroadphase broadphase = new btDbvtBroadphase(); btDefaultCollisionConfiguration collisionConfig = new btDefaultCollisionConfiguration(); btCollisionDispatcher dispatcher = new btCollisionDispatcher(collisionConfig); btCollisionWorld collisionWorld = new btCollisionWorld(dispatcher, broadphase, collisionConfig); return new BulletWorld(collisionConfig, dispatcher, broadphase, null, collisionWorld); } @Override public void update () { super.update(); // Not using dynamics, so update the collision world manually if (USE_BULLET_FRUSTUM_CULLING) { if (world.performanceCounter != null) world.performanceCounter.start(); world.collisionWorld.performDiscreteCollisionDetection(); if (world.performanceCounter != null) world.performanceCounter.stop(); } } @Override public void render () { final float dt = Gdx.graphics.getDeltaTime(); frustumEntity.transform.idt(); frustumEntity.transform.rotate(Vector3.X, angleX = (angleX + dt * SPEED_X) % 360); frustumEntity.transform.rotate(Vector3.Y, angleY = (angleY + dt * SPEED_Y) % 360); frustumEntity.transform.rotate(Vector3.Z, angleZ = (angleZ + dt * SPEED_Z) % 360); // Transform the ghost object frustumEntity.body.setWorldTransform(frustumEntity.transform); // Transform the frustum cam frustumCam.direction.set(0, 0, -1); frustumCam.up.set(0, 1, 0); frustumCam.position.set(0, 0, 0); frustumCam.rotate(frustumEntity.transform); frustumCam.update(); super.render(); performance.append(" visible: ").append(visibleEntities.size); } @Override protected void renderWorld () { if (world.performanceCounter != null) world.performanceCounter.start(); if (USE_BULLET_FRUSTUM_CULLING) getEntitiesCollidingWithObject(world, frustumObject, visibleEntities, tempManifoldArr); else { visibleEntities.clear(); for (int i = 0; i < world.entities.size; i++) { final BulletEntity e = world.entities.get(i); if (e == frustumEntity) continue; e.modelInstance.transform.getTranslation(tmpV); if (frustumCam.frustum.sphereInFrustum(tmpV, 1)) visibleEntities.add(e); } } if (world.performanceCounter != null) world.performanceCounter.stop(); for (int i = 0; i < visibleEntities.size; i++) visibleEntities.get(i).setColor(Color.RED); modelBatch.begin(camera); if ((state & CULL_FRUSTUM) == CULL_FRUSTUM) { world.render(modelBatch, environment, visibleEntities); world.render(modelBatch, environment, frustumEntity); } else world.render(modelBatch, environment); modelBatch.end(); for (int i = 0; i < visibleEntities.size; i++) visibleEntities.get(i).setColor(Color.GRAY); } @Override protected void beginRender (boolean lighting) { super.beginRender(false); } @Override public void dispose () { frustumObject = null; super.dispose(); if (tempManifoldArr != null) tempManifoldArr.dispose(); tempManifoldArr = null; } @Override public boolean tap (float x, float y, int count, int button) { state = (state + 1) % 3; if ((state & FRUSTUM_CAM) == FRUSTUM_CAM) camera = frustumCam; else camera = overviewCam; return true; } // Simple helper class to keep a reference to the collision shape public static class TestPairCachingGhostObject extends btPairCachingGhostObject { public btCollisionShape shape; @Override public void setCollisionShape (btCollisionShape collisionShape) { shape = collisionShape; super.setCollisionShape(collisionShape); } @Override public void dispose () { super.dispose(); if (shape != null) shape.dispose(); shape = null; } } }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./extensions/gdx-box2d/gdx-box2d-gwt/src/com/badlogic/gdx/physics/box2d/gwt/emu/org/jbox2d/collision/broadphase/DefaultBroadPhaseBuffer.java
/******************************************************************************* * Copyright (c) 2013, Daniel Murphy * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. ******************************************************************************/ package org.jbox2d.collision.broadphase; import java.util.Arrays; import org.jbox2d.callbacks.DebugDraw; import org.jbox2d.callbacks.PairCallback; import org.jbox2d.callbacks.TreeCallback; import org.jbox2d.callbacks.TreeRayCastCallback; import org.jbox2d.collision.AABB; import org.jbox2d.collision.RayCastInput; import org.jbox2d.common.Vec2; /** The broad-phase is used for computing pairs and performing volume queries and ray casts. This broad-phase does not persist * pairs. Instead, this reports potentially new pairs. It is up to the client to consume the new pairs and to track subsequent * overlap. * * @author Daniel Murphy */ public class DefaultBroadPhaseBuffer implements TreeCallback, BroadPhase { private final BroadPhaseStrategy m_tree; private int m_proxyCount; private int[] m_moveBuffer; private int m_moveCapacity; private int m_moveCount; private Pair[] m_pairBuffer; private int m_pairCapacity; private int m_pairCount; private int m_queryProxyId; public DefaultBroadPhaseBuffer (BroadPhaseStrategy strategy) { m_proxyCount = 0; m_pairCapacity = 16; m_pairCount = 0; m_pairBuffer = new Pair[m_pairCapacity]; for (int i = 0; i < m_pairCapacity; i++) { m_pairBuffer[i] = new Pair(); } m_moveCapacity = 16; m_moveCount = 0; m_moveBuffer = new int[m_moveCapacity]; m_tree = strategy; m_queryProxyId = NULL_PROXY; } @Override public final int createProxy (final AABB aabb, Object userData) { int proxyId = m_tree.createProxy(aabb, userData); ++m_proxyCount; bufferMove(proxyId); return proxyId; } @Override public final void destroyProxy (int proxyId) { unbufferMove(proxyId); --m_proxyCount; m_tree.destroyProxy(proxyId); } @Override public final void moveProxy (int proxyId, final AABB aabb, final Vec2 displacement) { boolean buffer = m_tree.moveProxy(proxyId, aabb, displacement); if (buffer) { bufferMove(proxyId); } } @Override public void touchProxy (int proxyId) { bufferMove(proxyId); } @Override public Object getUserData (int proxyId) { return m_tree.getUserData(proxyId); } @Override public AABB getFatAABB (int proxyId) { return m_tree.getFatAABB(proxyId); } @Override public boolean testOverlap (int proxyIdA, int proxyIdB) { // return AABB.testOverlap(proxyA.aabb, proxyB.aabb); // return m_tree.overlap(proxyIdA, proxyIdB); final AABB a = m_tree.getFatAABB(proxyIdA); final AABB b = m_tree.getFatAABB(proxyIdB); if (b.lowerBound.x - a.upperBound.x > 0.0f || b.lowerBound.y - a.upperBound.y > 0.0f) { return false; } if (a.lowerBound.x - b.upperBound.x > 0.0f || a.lowerBound.y - b.upperBound.y > 0.0f) { return false; } return true; } @Override public final int getProxyCount () { return m_proxyCount; } @Override public void drawTree (DebugDraw argDraw) { m_tree.drawTree(argDraw); } @Override public final void updatePairs (PairCallback callback) { // Reset pair buffer m_pairCount = 0; // Perform tree queries for all moving proxies. for (int i = 0; i < m_moveCount; ++i) { m_queryProxyId = m_moveBuffer[i]; if (m_queryProxyId == NULL_PROXY) { continue; } // We have to query the tree with the fat AABB so that // we don't fail to create a pair that may touch later. final AABB fatAABB = m_tree.getFatAABB(m_queryProxyId); // Query tree, create pairs and add them pair buffer. // log.debug("quering aabb: "+m_queryProxy.aabb); m_tree.query(this, fatAABB); } // log.debug("Number of pairs found: "+m_pairCount); // Reset move buffer m_moveCount = 0; // Sort the pair buffer to expose duplicates. Arrays.sort(m_pairBuffer, 0, m_pairCount); // Send the pairs back to the client. int i = 0; while (i < m_pairCount) { Pair primaryPair = m_pairBuffer[i]; Object userDataA = m_tree.getUserData(primaryPair.proxyIdA); Object userDataB = m_tree.getUserData(primaryPair.proxyIdB); // log.debug("returning pair: "+userDataA+", "+userDataB); callback.addPair(userDataA, userDataB); ++i; // Skip any duplicate pairs. while (i < m_pairCount) { Pair pair = m_pairBuffer[i]; if (pair.proxyIdA != primaryPair.proxyIdA || pair.proxyIdB != primaryPair.proxyIdB) { break; } ++i; } } } @Override public final void query (final TreeCallback callback, final AABB aabb) { m_tree.query(callback, aabb); } @Override public final void raycast (final TreeRayCastCallback callback, final RayCastInput input) { m_tree.raycast(callback, input); } @Override public final int getTreeHeight () { return m_tree.getHeight(); } @Override public int getTreeBalance () { return m_tree.getMaxBalance(); } @Override public float getTreeQuality () { return m_tree.getAreaRatio(); } protected final void bufferMove (int proxyId) { if (m_moveCount == m_moveCapacity) { int[] old = m_moveBuffer; m_moveCapacity *= 2; m_moveBuffer = new int[m_moveCapacity]; System.arraycopy(old, 0, m_moveBuffer, 0, old.length); } m_moveBuffer[m_moveCount] = proxyId; ++m_moveCount; } protected final void unbufferMove (int proxyId) { for (int i = 0; i < m_moveCount; i++) { if (m_moveBuffer[i] == proxyId) { m_moveBuffer[i] = NULL_PROXY; } } } /** This is called from DynamicTree::query when we are gathering pairs. */ public final boolean treeCallback (int proxyId) { // A proxy cannot form a pair with itself. if (proxyId == m_queryProxyId) { return true; } // Grow the pair buffer as needed. if (m_pairCount == m_pairCapacity) { Pair[] oldBuffer = m_pairBuffer; m_pairCapacity *= 2; m_pairBuffer = new Pair[m_pairCapacity]; System.arraycopy(oldBuffer, 0, m_pairBuffer, 0, oldBuffer.length); for (int i = oldBuffer.length; i < m_pairCapacity; i++) { m_pairBuffer[i] = new Pair(); } } if (proxyId < m_queryProxyId) { m_pairBuffer[m_pairCount].proxyIdA = proxyId; m_pairBuffer[m_pairCount].proxyIdB = m_queryProxyId; } else { m_pairBuffer[m_pairCount].proxyIdA = m_queryProxyId; m_pairBuffer[m_pairCount].proxyIdB = proxyId; } ++m_pairCount; return true; } }
/******************************************************************************* * Copyright (c) 2013, Daniel Murphy * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. ******************************************************************************/ package org.jbox2d.collision.broadphase; import java.util.Arrays; import org.jbox2d.callbacks.DebugDraw; import org.jbox2d.callbacks.PairCallback; import org.jbox2d.callbacks.TreeCallback; import org.jbox2d.callbacks.TreeRayCastCallback; import org.jbox2d.collision.AABB; import org.jbox2d.collision.RayCastInput; import org.jbox2d.common.Vec2; /** The broad-phase is used for computing pairs and performing volume queries and ray casts. This broad-phase does not persist * pairs. Instead, this reports potentially new pairs. It is up to the client to consume the new pairs and to track subsequent * overlap. * * @author Daniel Murphy */ public class DefaultBroadPhaseBuffer implements TreeCallback, BroadPhase { private final BroadPhaseStrategy m_tree; private int m_proxyCount; private int[] m_moveBuffer; private int m_moveCapacity; private int m_moveCount; private Pair[] m_pairBuffer; private int m_pairCapacity; private int m_pairCount; private int m_queryProxyId; public DefaultBroadPhaseBuffer (BroadPhaseStrategy strategy) { m_proxyCount = 0; m_pairCapacity = 16; m_pairCount = 0; m_pairBuffer = new Pair[m_pairCapacity]; for (int i = 0; i < m_pairCapacity; i++) { m_pairBuffer[i] = new Pair(); } m_moveCapacity = 16; m_moveCount = 0; m_moveBuffer = new int[m_moveCapacity]; m_tree = strategy; m_queryProxyId = NULL_PROXY; } @Override public final int createProxy (final AABB aabb, Object userData) { int proxyId = m_tree.createProxy(aabb, userData); ++m_proxyCount; bufferMove(proxyId); return proxyId; } @Override public final void destroyProxy (int proxyId) { unbufferMove(proxyId); --m_proxyCount; m_tree.destroyProxy(proxyId); } @Override public final void moveProxy (int proxyId, final AABB aabb, final Vec2 displacement) { boolean buffer = m_tree.moveProxy(proxyId, aabb, displacement); if (buffer) { bufferMove(proxyId); } } @Override public void touchProxy (int proxyId) { bufferMove(proxyId); } @Override public Object getUserData (int proxyId) { return m_tree.getUserData(proxyId); } @Override public AABB getFatAABB (int proxyId) { return m_tree.getFatAABB(proxyId); } @Override public boolean testOverlap (int proxyIdA, int proxyIdB) { // return AABB.testOverlap(proxyA.aabb, proxyB.aabb); // return m_tree.overlap(proxyIdA, proxyIdB); final AABB a = m_tree.getFatAABB(proxyIdA); final AABB b = m_tree.getFatAABB(proxyIdB); if (b.lowerBound.x - a.upperBound.x > 0.0f || b.lowerBound.y - a.upperBound.y > 0.0f) { return false; } if (a.lowerBound.x - b.upperBound.x > 0.0f || a.lowerBound.y - b.upperBound.y > 0.0f) { return false; } return true; } @Override public final int getProxyCount () { return m_proxyCount; } @Override public void drawTree (DebugDraw argDraw) { m_tree.drawTree(argDraw); } @Override public final void updatePairs (PairCallback callback) { // Reset pair buffer m_pairCount = 0; // Perform tree queries for all moving proxies. for (int i = 0; i < m_moveCount; ++i) { m_queryProxyId = m_moveBuffer[i]; if (m_queryProxyId == NULL_PROXY) { continue; } // We have to query the tree with the fat AABB so that // we don't fail to create a pair that may touch later. final AABB fatAABB = m_tree.getFatAABB(m_queryProxyId); // Query tree, create pairs and add them pair buffer. // log.debug("quering aabb: "+m_queryProxy.aabb); m_tree.query(this, fatAABB); } // log.debug("Number of pairs found: "+m_pairCount); // Reset move buffer m_moveCount = 0; // Sort the pair buffer to expose duplicates. Arrays.sort(m_pairBuffer, 0, m_pairCount); // Send the pairs back to the client. int i = 0; while (i < m_pairCount) { Pair primaryPair = m_pairBuffer[i]; Object userDataA = m_tree.getUserData(primaryPair.proxyIdA); Object userDataB = m_tree.getUserData(primaryPair.proxyIdB); // log.debug("returning pair: "+userDataA+", "+userDataB); callback.addPair(userDataA, userDataB); ++i; // Skip any duplicate pairs. while (i < m_pairCount) { Pair pair = m_pairBuffer[i]; if (pair.proxyIdA != primaryPair.proxyIdA || pair.proxyIdB != primaryPair.proxyIdB) { break; } ++i; } } } @Override public final void query (final TreeCallback callback, final AABB aabb) { m_tree.query(callback, aabb); } @Override public final void raycast (final TreeRayCastCallback callback, final RayCastInput input) { m_tree.raycast(callback, input); } @Override public final int getTreeHeight () { return m_tree.getHeight(); } @Override public int getTreeBalance () { return m_tree.getMaxBalance(); } @Override public float getTreeQuality () { return m_tree.getAreaRatio(); } protected final void bufferMove (int proxyId) { if (m_moveCount == m_moveCapacity) { int[] old = m_moveBuffer; m_moveCapacity *= 2; m_moveBuffer = new int[m_moveCapacity]; System.arraycopy(old, 0, m_moveBuffer, 0, old.length); } m_moveBuffer[m_moveCount] = proxyId; ++m_moveCount; } protected final void unbufferMove (int proxyId) { for (int i = 0; i < m_moveCount; i++) { if (m_moveBuffer[i] == proxyId) { m_moveBuffer[i] = NULL_PROXY; } } } /** This is called from DynamicTree::query when we are gathering pairs. */ public final boolean treeCallback (int proxyId) { // A proxy cannot form a pair with itself. if (proxyId == m_queryProxyId) { return true; } // Grow the pair buffer as needed. if (m_pairCount == m_pairCapacity) { Pair[] oldBuffer = m_pairBuffer; m_pairCapacity *= 2; m_pairBuffer = new Pair[m_pairCapacity]; System.arraycopy(oldBuffer, 0, m_pairBuffer, 0, oldBuffer.length); for (int i = oldBuffer.length; i < m_pairCapacity; i++) { m_pairBuffer[i] = new Pair(); } } if (proxyId < m_queryProxyId) { m_pairBuffer[m_pairCount].proxyIdA = proxyId; m_pairBuffer[m_pairCount].proxyIdB = m_queryProxyId; } else { m_pairBuffer[m_pairCount].proxyIdA = m_queryProxyId; m_pairBuffer[m_pairCount].proxyIdB = proxyId; } ++m_pairCount; return true; } }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./backends/gdx-backends-gwt/src/com/badlogic/gdx/backends/gwt/emu/java/io/DataOutputStream.java
/* * Copyright 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package java.io; import com.google.gwt.corp.compatibility.Numbers; public class DataOutputStream extends OutputStream implements DataOutput { OutputStream os; public DataOutputStream (OutputStream os) { this.os = os; } @Override public void write (int b) throws IOException { os.write(b); } public void writeBoolean (boolean v) throws IOException { os.write(v ? 1 : 0); } public void writeByte (int v) throws IOException { os.write(v); } public void writeBytes (String s) throws IOException { int len = s.length(); for (int i = 0; i < len; i++) { os.write(s.charAt(i) & 0xff); } } public void writeChar (int v) throws IOException { os.write(v >> 8); os.write(v); } public void writeChars (String s) throws IOException { throw new RuntimeException("writeChars NYI"); } public void writeDouble (double v) throws IOException { writeLong(Double.doubleToLongBits(v)); } public void writeFloat (float v) throws IOException { writeInt(Numbers.floatToIntBits(v)); } public void writeInt (int v) throws IOException { os.write(v >> 24); os.write(v >> 16); os.write(v >> 8); os.write(v); } public void writeLong (long v) throws IOException { writeInt((int)(v >> 32L)); writeInt((int)v); } public void writeShort (int v) throws IOException { os.write(v >> 8); os.write(v); } public void writeUTF (String s) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (c > 0 && c < 80) { baos.write(c); } else if (c < '\u0800') { baos.write(0xc0 | (0x1f & (c >> 6))); baos.write(0x80 | (0x3f & c)); } else { baos.write(0xe0 | (0x0f & (c >> 12))); baos.write(0x80 | (0x3f & (c >> 6))); baos.write(0x80 | (0x3f & c)); } } writeShort(baos.count); os.write(baos.buf, 0, baos.count); } }
/* * Copyright 2010 Google Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package java.io; import com.google.gwt.corp.compatibility.Numbers; public class DataOutputStream extends OutputStream implements DataOutput { OutputStream os; public DataOutputStream (OutputStream os) { this.os = os; } @Override public void write (int b) throws IOException { os.write(b); } public void writeBoolean (boolean v) throws IOException { os.write(v ? 1 : 0); } public void writeByte (int v) throws IOException { os.write(v); } public void writeBytes (String s) throws IOException { int len = s.length(); for (int i = 0; i < len; i++) { os.write(s.charAt(i) & 0xff); } } public void writeChar (int v) throws IOException { os.write(v >> 8); os.write(v); } public void writeChars (String s) throws IOException { throw new RuntimeException("writeChars NYI"); } public void writeDouble (double v) throws IOException { writeLong(Double.doubleToLongBits(v)); } public void writeFloat (float v) throws IOException { writeInt(Numbers.floatToIntBits(v)); } public void writeInt (int v) throws IOException { os.write(v >> 24); os.write(v >> 16); os.write(v >> 8); os.write(v); } public void writeLong (long v) throws IOException { writeInt((int)(v >> 32L)); writeInt((int)v); } public void writeShort (int v) throws IOException { os.write(v >> 8); os.write(v); } public void writeUTF (String s) throws IOException { ByteArrayOutputStream baos = new ByteArrayOutputStream(); for (int i = 0; i < s.length(); i++) { char c = s.charAt(i); if (c > 0 && c < 80) { baos.write(c); } else if (c < '\u0800') { baos.write(0xc0 | (0x1f & (c >> 6))); baos.write(0x80 | (0x3f & c)); } else { baos.write(0xe0 | (0x0f & (c >> 12))); baos.write(0x80 | (0x3f & (c >> 6))); baos.write(0x80 | (0x3f & c)); } } writeShort(baos.count); os.write(baos.buf, 0, baos.count); } }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./tests/gdx-tests/src/com/badlogic/gdx/tests/PngTest.java
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.tests; import java.io.IOException; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.Pixmap; import com.badlogic.gdx.graphics.PixmapIO.PNG; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.tests.utils.GdxTest; public class PngTest extends GdxTest { SpriteBatch batch; Texture badlogic, screenshot; public void create () { batch = new SpriteBatch(); badlogic = new Texture(Gdx.files.internal("data/badlogic.jpg")); } public void render () { Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); batch.begin(); if (screenshot == null) { int width = Gdx.graphics.getWidth(), height = Gdx.graphics.getHeight(); for (int i = 0; i < 100; i++) batch.draw(badlogic, MathUtils.random(width), MathUtils.random(height)); batch.flush(); FileHandle file = FileHandle.tempFile("screenshot-"); System.out.println(file.file().getAbsolutePath()); Pixmap pixmap = Pixmap.createFromFrameBuffer(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); try { PNG writer = new PNG((int)(pixmap.getWidth() * pixmap.getHeight() * 1.5f)); // writer.setCompression(Deflater.NO_COMPRESSION); writer.write(file, pixmap); writer.write(file, pixmap); // Write twice to make sure the object is reusable. writer.dispose(); } catch (IOException ex) { throw new RuntimeException(ex); } screenshot = new Texture(file); } batch.draw(screenshot, 0, 0); batch.end(); } }
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.tests; import java.io.IOException; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.Pixmap; import com.badlogic.gdx.graphics.PixmapIO.PNG; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.tests.utils.GdxTest; public class PngTest extends GdxTest { SpriteBatch batch; Texture badlogic, screenshot; public void create () { batch = new SpriteBatch(); badlogic = new Texture(Gdx.files.internal("data/badlogic.jpg")); } public void render () { Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); batch.begin(); if (screenshot == null) { int width = Gdx.graphics.getWidth(), height = Gdx.graphics.getHeight(); for (int i = 0; i < 100; i++) batch.draw(badlogic, MathUtils.random(width), MathUtils.random(height)); batch.flush(); FileHandle file = FileHandle.tempFile("screenshot-"); System.out.println(file.file().getAbsolutePath()); Pixmap pixmap = Pixmap.createFromFrameBuffer(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); try { PNG writer = new PNG((int)(pixmap.getWidth() * pixmap.getHeight() * 1.5f)); // writer.setCompression(Deflater.NO_COMPRESSION); writer.write(file, pixmap); writer.write(file, pixmap); // Write twice to make sure the object is reusable. writer.dispose(); } catch (IOException ex) { throw new RuntimeException(ex); } screenshot = new Texture(file); } batch.draw(screenshot, 0, 0); batch.end(); } }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./extensions/gdx-bullet/jni/swig-src/collision/com/badlogic/gdx/physics/bullet/collision/btBroadphaseAabbCallback.java
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.collision; import com.badlogic.gdx.physics.bullet.BulletBase; import com.badlogic.gdx.physics.bullet.linearmath.*; public class btBroadphaseAabbCallback extends BulletBase { private long swigCPtr; protected btBroadphaseAabbCallback (final String className, long cPtr, boolean cMemoryOwn) { super(className, cPtr, cMemoryOwn); swigCPtr = cPtr; } /** Construct a new btBroadphaseAabbCallback, normally you should not need this constructor it's intended for low-level * usage. */ public btBroadphaseAabbCallback (long cPtr, boolean cMemoryOwn) { this("btBroadphaseAabbCallback", cPtr, cMemoryOwn); construct(); } @Override protected void reset (long cPtr, boolean cMemoryOwn) { if (!destroyed) destroy(); super.reset(swigCPtr = cPtr, cMemoryOwn); } public static long getCPtr (btBroadphaseAabbCallback obj) { return (obj == null) ? 0 : obj.swigCPtr; } @Override protected void finalize () throws Throwable { if (!destroyed) destroy(); super.finalize(); } @Override protected synchronized void delete () { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; CollisionJNI.delete_btBroadphaseAabbCallback(swigCPtr); } swigCPtr = 0; } super.delete(); } protected void swigDirectorDisconnect () { swigCMemOwn = false; delete(); } public void swigReleaseOwnership () { swigCMemOwn = false; CollisionJNI.btBroadphaseAabbCallback_change_ownership(this, swigCPtr, false); } public void swigTakeOwnership () { swigCMemOwn = true; CollisionJNI.btBroadphaseAabbCallback_change_ownership(this, swigCPtr, true); } public boolean process (btBroadphaseProxy proxy) { return CollisionJNI.btBroadphaseAabbCallback_process(swigCPtr, this, btBroadphaseProxy.getCPtr(proxy), proxy); } public btBroadphaseAabbCallback () { this(CollisionJNI.new_btBroadphaseAabbCallback(), true); CollisionJNI.btBroadphaseAabbCallback_director_connect(this, swigCPtr, swigCMemOwn, true); } }
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.collision; import com.badlogic.gdx.physics.bullet.BulletBase; import com.badlogic.gdx.physics.bullet.linearmath.*; public class btBroadphaseAabbCallback extends BulletBase { private long swigCPtr; protected btBroadphaseAabbCallback (final String className, long cPtr, boolean cMemoryOwn) { super(className, cPtr, cMemoryOwn); swigCPtr = cPtr; } /** Construct a new btBroadphaseAabbCallback, normally you should not need this constructor it's intended for low-level * usage. */ public btBroadphaseAabbCallback (long cPtr, boolean cMemoryOwn) { this("btBroadphaseAabbCallback", cPtr, cMemoryOwn); construct(); } @Override protected void reset (long cPtr, boolean cMemoryOwn) { if (!destroyed) destroy(); super.reset(swigCPtr = cPtr, cMemoryOwn); } public static long getCPtr (btBroadphaseAabbCallback obj) { return (obj == null) ? 0 : obj.swigCPtr; } @Override protected void finalize () throws Throwable { if (!destroyed) destroy(); super.finalize(); } @Override protected synchronized void delete () { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; CollisionJNI.delete_btBroadphaseAabbCallback(swigCPtr); } swigCPtr = 0; } super.delete(); } protected void swigDirectorDisconnect () { swigCMemOwn = false; delete(); } public void swigReleaseOwnership () { swigCMemOwn = false; CollisionJNI.btBroadphaseAabbCallback_change_ownership(this, swigCPtr, false); } public void swigTakeOwnership () { swigCMemOwn = true; CollisionJNI.btBroadphaseAabbCallback_change_ownership(this, swigCPtr, true); } public boolean process (btBroadphaseProxy proxy) { return CollisionJNI.btBroadphaseAabbCallback_process(swigCPtr, this, btBroadphaseProxy.getCPtr(proxy), proxy); } public btBroadphaseAabbCallback () { this(CollisionJNI.new_btBroadphaseAabbCallback(), true); CollisionJNI.btBroadphaseAabbCallback_director_connect(this, swigCPtr, swigCMemOwn, true); } }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./backends/gdx-backends-gwt/src/com/badlogic/gdx/backends/gwt/emu/com/badlogic/gdx/utils/reflect/Field.java
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.utils.reflect; import com.badlogic.gwtref.client.Type; /** Provides information about, and access to, a single field of a class or interface. * @author nexsoftware */ public final class Field { private final com.badlogic.gwtref.client.Field field; Field (com.badlogic.gwtref.client.Field field) { this.field = field; } /** Returns the name of the field. */ public String getName () { return field.getName(); } /** Returns a Class object that identifies the declared type for the field. */ public Class getType () { return field.getType().getClassOfType(); } /** Returns the Class object representing the class or interface that declares the field. */ public Class getDeclaringClass () { return field.getEnclosingType().getClassOfType(); } public boolean isAccessible () { return field.isPublic(); } public void setAccessible (boolean accessible) { // NOOP in GWT } /** Return true if the field does not include any of the {@code private}, {@code protected}, or {@code public} modifiers. */ public boolean isDefaultAccess () { return !isPrivate() && !isProtected() && !isPublic(); } /** Return true if the field includes the {@code final} modifier. */ public boolean isFinal () { return field.isFinal(); } /** Return true if the field includes the {@code private} modifier. */ public boolean isPrivate () { return field.isPrivate(); } /** Return true if the field includes the {@code protected} modifier. */ public boolean isProtected () { return field.isProtected(); } /** Return true if the field includes the {@code public} modifier. */ public boolean isPublic () { return field.isPublic(); } /** Return true if the field includes the {@code static} modifier. */ public boolean isStatic () { return field.isStatic(); } /** Return true if the field includes the {@code transient} modifier. */ public boolean isTransient () { return field.isTransient(); } /** Return true if the field includes the {@code volatile} modifier. */ public boolean isVolatile () { return field.isVolatile(); } /** Return true if the field is a synthetic field. */ public boolean isSynthetic () { return field.isSynthetic(); } /** If the type of the field is parameterized, returns the Class object representing the parameter type at the specified index, * null otherwise. */ public Class getElementType (int index) { Type elementType = field.getElementType(index); return elementType != null ? elementType.getClassOfType() : null; } /** Returns true if the field includes an annotation of the provided class type. */ public boolean isAnnotationPresent (Class<? extends java.lang.annotation.Annotation> annotationType) { java.lang.annotation.Annotation[] annotations = field.getDeclaredAnnotations(); for (java.lang.annotation.Annotation annotation : annotations) { if (annotation.annotationType().equals(annotationType)) { return true; } } return false; } /** Returns an array of {@link Annotation} objects reflecting all annotations declared by this field, or an empty array if * there are none. Does not include inherited annotations. */ public Annotation[] getDeclaredAnnotations () { java.lang.annotation.Annotation[] annotations = field.getDeclaredAnnotations(); Annotation[] result = new Annotation[annotations.length]; for (int i = 0; i < annotations.length; i++) { result[i] = new Annotation(annotations[i]); } return result; } /** Returns an {@link Annotation} object reflecting the annotation provided, or null of this field doesn't have such an * annotation. This is a convenience function if the caller knows already which annotation type he's looking for. */ public Annotation getDeclaredAnnotation (Class<? extends java.lang.annotation.Annotation> annotationType) { java.lang.annotation.Annotation[] annotations = field.getDeclaredAnnotations(); for (java.lang.annotation.Annotation annotation : annotations) { if (annotation.annotationType().equals(annotationType)) { return new Annotation(annotation); } } return null; } /** Returns the value of the field on the supplied object. */ public Object get (Object obj) throws ReflectionException { try { return field.get(obj); } catch (IllegalArgumentException e) { throw new ReflectionException("Could not get " + getDeclaringClass() + "#" + getName() + ": " + e.getMessage(), e); } catch (IllegalAccessException e) { throw new ReflectionException("Illegal access to field " + getName() + ": " + e.getMessage(), e); } } /** Sets the value of the field on the supplied object. */ public void set (Object obj, Object value) throws ReflectionException { try { field.set(obj, value); } catch (IllegalArgumentException e) { throw new ReflectionException("Could not set " + getDeclaringClass() + "#" + getName() + ": " + e.getMessage(), e); } catch (IllegalAccessException e) { throw new ReflectionException("Illegal access to field " + getName() + ": " + e.getMessage(), e); } } }
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.utils.reflect; import com.badlogic.gwtref.client.Type; /** Provides information about, and access to, a single field of a class or interface. * @author nexsoftware */ public final class Field { private final com.badlogic.gwtref.client.Field field; Field (com.badlogic.gwtref.client.Field field) { this.field = field; } /** Returns the name of the field. */ public String getName () { return field.getName(); } /** Returns a Class object that identifies the declared type for the field. */ public Class getType () { return field.getType().getClassOfType(); } /** Returns the Class object representing the class or interface that declares the field. */ public Class getDeclaringClass () { return field.getEnclosingType().getClassOfType(); } public boolean isAccessible () { return field.isPublic(); } public void setAccessible (boolean accessible) { // NOOP in GWT } /** Return true if the field does not include any of the {@code private}, {@code protected}, or {@code public} modifiers. */ public boolean isDefaultAccess () { return !isPrivate() && !isProtected() && !isPublic(); } /** Return true if the field includes the {@code final} modifier. */ public boolean isFinal () { return field.isFinal(); } /** Return true if the field includes the {@code private} modifier. */ public boolean isPrivate () { return field.isPrivate(); } /** Return true if the field includes the {@code protected} modifier. */ public boolean isProtected () { return field.isProtected(); } /** Return true if the field includes the {@code public} modifier. */ public boolean isPublic () { return field.isPublic(); } /** Return true if the field includes the {@code static} modifier. */ public boolean isStatic () { return field.isStatic(); } /** Return true if the field includes the {@code transient} modifier. */ public boolean isTransient () { return field.isTransient(); } /** Return true if the field includes the {@code volatile} modifier. */ public boolean isVolatile () { return field.isVolatile(); } /** Return true if the field is a synthetic field. */ public boolean isSynthetic () { return field.isSynthetic(); } /** If the type of the field is parameterized, returns the Class object representing the parameter type at the specified index, * null otherwise. */ public Class getElementType (int index) { Type elementType = field.getElementType(index); return elementType != null ? elementType.getClassOfType() : null; } /** Returns true if the field includes an annotation of the provided class type. */ public boolean isAnnotationPresent (Class<? extends java.lang.annotation.Annotation> annotationType) { java.lang.annotation.Annotation[] annotations = field.getDeclaredAnnotations(); for (java.lang.annotation.Annotation annotation : annotations) { if (annotation.annotationType().equals(annotationType)) { return true; } } return false; } /** Returns an array of {@link Annotation} objects reflecting all annotations declared by this field, or an empty array if * there are none. Does not include inherited annotations. */ public Annotation[] getDeclaredAnnotations () { java.lang.annotation.Annotation[] annotations = field.getDeclaredAnnotations(); Annotation[] result = new Annotation[annotations.length]; for (int i = 0; i < annotations.length; i++) { result[i] = new Annotation(annotations[i]); } return result; } /** Returns an {@link Annotation} object reflecting the annotation provided, or null of this field doesn't have such an * annotation. This is a convenience function if the caller knows already which annotation type he's looking for. */ public Annotation getDeclaredAnnotation (Class<? extends java.lang.annotation.Annotation> annotationType) { java.lang.annotation.Annotation[] annotations = field.getDeclaredAnnotations(); for (java.lang.annotation.Annotation annotation : annotations) { if (annotation.annotationType().equals(annotationType)) { return new Annotation(annotation); } } return null; } /** Returns the value of the field on the supplied object. */ public Object get (Object obj) throws ReflectionException { try { return field.get(obj); } catch (IllegalArgumentException e) { throw new ReflectionException("Could not get " + getDeclaringClass() + "#" + getName() + ": " + e.getMessage(), e); } catch (IllegalAccessException e) { throw new ReflectionException("Illegal access to field " + getName() + ": " + e.getMessage(), e); } } /** Sets the value of the field on the supplied object. */ public void set (Object obj, Object value) throws ReflectionException { try { field.set(obj, value); } catch (IllegalArgumentException e) { throw new ReflectionException("Could not set " + getDeclaringClass() + "#" + getName() + ": " + e.getMessage(), e); } catch (IllegalAccessException e) { throw new ReflectionException("Illegal access to field " + getName() + ": " + e.getMessage(), e); } } }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./extensions/gdx-bullet/jni/swig-src/dynamics/com/badlogic/gdx/physics/bullet/dynamics/SWIGTYPE_p_p_btTypedConstraint.java
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.dynamics; public class SWIGTYPE_p_p_btTypedConstraint { private transient long swigCPtr; protected SWIGTYPE_p_p_btTypedConstraint (long cPtr, @SuppressWarnings("unused") boolean futureUse) { swigCPtr = cPtr; } protected SWIGTYPE_p_p_btTypedConstraint () { swigCPtr = 0; } protected static long getCPtr (SWIGTYPE_p_p_btTypedConstraint obj) { return (obj == null) ? 0 : obj.swigCPtr; } }
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.dynamics; public class SWIGTYPE_p_p_btTypedConstraint { private transient long swigCPtr; protected SWIGTYPE_p_p_btTypedConstraint (long cPtr, @SuppressWarnings("unused") boolean futureUse) { swigCPtr = cPtr; } protected SWIGTYPE_p_p_btTypedConstraint () { swigCPtr = 0; } protected static long getCPtr (SWIGTYPE_p_p_btTypedConstraint obj) { return (obj == null) ? 0 : obj.swigCPtr; } }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./backends/gdx-backend-lwjgl/src/com/badlogic/gdx/backends/lwjgl/LwjglApplicationLogger.java
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.backends.lwjgl; import com.badlogic.gdx.ApplicationLogger; /** Default implementation of {@link ApplicationLogger} for Lwjgl */ public class LwjglApplicationLogger implements ApplicationLogger { @Override public void log (String tag, String message) { System.out.println("[" + tag + "] " + message); } @Override public void log (String tag, String message, Throwable exception) { System.out.println("[" + tag + "] " + message); exception.printStackTrace(System.out); } @Override public void error (String tag, String message) { System.err.println("[" + tag + "] " + message); } @Override public void error (String tag, String message, Throwable exception) { System.err.println("[" + tag + "] " + message); exception.printStackTrace(System.err); } @Override public void debug (String tag, String message) { System.out.println("[" + tag + "] " + message); } @Override public void debug (String tag, String message, Throwable exception) { System.out.println("[" + tag + "] " + message); exception.printStackTrace(System.out); } }
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.backends.lwjgl; import com.badlogic.gdx.ApplicationLogger; /** Default implementation of {@link ApplicationLogger} for Lwjgl */ public class LwjglApplicationLogger implements ApplicationLogger { @Override public void log (String tag, String message) { System.out.println("[" + tag + "] " + message); } @Override public void log (String tag, String message, Throwable exception) { System.out.println("[" + tag + "] " + message); exception.printStackTrace(System.out); } @Override public void error (String tag, String message) { System.err.println("[" + tag + "] " + message); } @Override public void error (String tag, String message, Throwable exception) { System.err.println("[" + tag + "] " + message); exception.printStackTrace(System.err); } @Override public void debug (String tag, String message) { System.out.println("[" + tag + "] " + message); } @Override public void debug (String tag, String message, Throwable exception) { System.out.println("[" + tag + "] " + message); exception.printStackTrace(System.out); } }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./extensions/gdx-bullet/jni/swig-src/dynamics/com/badlogic/gdx/physics/bullet/dynamics/btContactSolverInfoData.java
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.dynamics; import com.badlogic.gdx.physics.bullet.BulletBase; import com.badlogic.gdx.physics.bullet.linearmath.*; import com.badlogic.gdx.physics.bullet.collision.*; public class btContactSolverInfoData extends BulletBase { private long swigCPtr; protected btContactSolverInfoData (final String className, long cPtr, boolean cMemoryOwn) { super(className, cPtr, cMemoryOwn); swigCPtr = cPtr; } /** Construct a new btContactSolverInfoData, normally you should not need this constructor it's intended for low-level * usage. */ public btContactSolverInfoData (long cPtr, boolean cMemoryOwn) { this("btContactSolverInfoData", cPtr, cMemoryOwn); construct(); } @Override protected void reset (long cPtr, boolean cMemoryOwn) { if (!destroyed) destroy(); super.reset(swigCPtr = cPtr, cMemoryOwn); } public static long getCPtr (btContactSolverInfoData obj) { return (obj == null) ? 0 : obj.swigCPtr; } @Override protected void finalize () throws Throwable { if (!destroyed) destroy(); super.finalize(); } @Override protected synchronized void delete () { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; DynamicsJNI.delete_btContactSolverInfoData(swigCPtr); } swigCPtr = 0; } super.delete(); } public void setTau (float value) { DynamicsJNI.btContactSolverInfoData_tau_set(swigCPtr, this, value); } public float getTau () { return DynamicsJNI.btContactSolverInfoData_tau_get(swigCPtr, this); } public void setDamping (float value) { DynamicsJNI.btContactSolverInfoData_damping_set(swigCPtr, this, value); } public float getDamping () { return DynamicsJNI.btContactSolverInfoData_damping_get(swigCPtr, this); } public void setFriction (float value) { DynamicsJNI.btContactSolverInfoData_friction_set(swigCPtr, this, value); } public float getFriction () { return DynamicsJNI.btContactSolverInfoData_friction_get(swigCPtr, this); } public void setTimeStep (float value) { DynamicsJNI.btContactSolverInfoData_timeStep_set(swigCPtr, this, value); } public float getTimeStep () { return DynamicsJNI.btContactSolverInfoData_timeStep_get(swigCPtr, this); } public void setRestitution (float value) { DynamicsJNI.btContactSolverInfoData_restitution_set(swigCPtr, this, value); } public float getRestitution () { return DynamicsJNI.btContactSolverInfoData_restitution_get(swigCPtr, this); } public void setNumIterations (int value) { DynamicsJNI.btContactSolverInfoData_numIterations_set(swigCPtr, this, value); } public int getNumIterations () { return DynamicsJNI.btContactSolverInfoData_numIterations_get(swigCPtr, this); } public void setMaxErrorReduction (float value) { DynamicsJNI.btContactSolverInfoData_maxErrorReduction_set(swigCPtr, this, value); } public float getMaxErrorReduction () { return DynamicsJNI.btContactSolverInfoData_maxErrorReduction_get(swigCPtr, this); } public void setSor (float value) { DynamicsJNI.btContactSolverInfoData_sor_set(swigCPtr, this, value); } public float getSor () { return DynamicsJNI.btContactSolverInfoData_sor_get(swigCPtr, this); } public void setErp (float value) { DynamicsJNI.btContactSolverInfoData_erp_set(swigCPtr, this, value); } public float getErp () { return DynamicsJNI.btContactSolverInfoData_erp_get(swigCPtr, this); } public void setErp2 (float value) { DynamicsJNI.btContactSolverInfoData_erp2_set(swigCPtr, this, value); } public float getErp2 () { return DynamicsJNI.btContactSolverInfoData_erp2_get(swigCPtr, this); } public void setGlobalCfm (float value) { DynamicsJNI.btContactSolverInfoData_globalCfm_set(swigCPtr, this, value); } public float getGlobalCfm () { return DynamicsJNI.btContactSolverInfoData_globalCfm_get(swigCPtr, this); } public void setFrictionERP (float value) { DynamicsJNI.btContactSolverInfoData_frictionERP_set(swigCPtr, this, value); } public float getFrictionERP () { return DynamicsJNI.btContactSolverInfoData_frictionERP_get(swigCPtr, this); } public void setFrictionCFM (float value) { DynamicsJNI.btContactSolverInfoData_frictionCFM_set(swigCPtr, this, value); } public float getFrictionCFM () { return DynamicsJNI.btContactSolverInfoData_frictionCFM_get(swigCPtr, this); } public void setSplitImpulse (int value) { DynamicsJNI.btContactSolverInfoData_splitImpulse_set(swigCPtr, this, value); } public int getSplitImpulse () { return DynamicsJNI.btContactSolverInfoData_splitImpulse_get(swigCPtr, this); } public void setSplitImpulsePenetrationThreshold (float value) { DynamicsJNI.btContactSolverInfoData_splitImpulsePenetrationThreshold_set(swigCPtr, this, value); } public float getSplitImpulsePenetrationThreshold () { return DynamicsJNI.btContactSolverInfoData_splitImpulsePenetrationThreshold_get(swigCPtr, this); } public void setSplitImpulseTurnErp (float value) { DynamicsJNI.btContactSolverInfoData_splitImpulseTurnErp_set(swigCPtr, this, value); } public float getSplitImpulseTurnErp () { return DynamicsJNI.btContactSolverInfoData_splitImpulseTurnErp_get(swigCPtr, this); } public void setLinearSlop (float value) { DynamicsJNI.btContactSolverInfoData_linearSlop_set(swigCPtr, this, value); } public float getLinearSlop () { return DynamicsJNI.btContactSolverInfoData_linearSlop_get(swigCPtr, this); } public void setWarmstartingFactor (float value) { DynamicsJNI.btContactSolverInfoData_warmstartingFactor_set(swigCPtr, this, value); } public float getWarmstartingFactor () { return DynamicsJNI.btContactSolverInfoData_warmstartingFactor_get(swigCPtr, this); } public void setSolverMode (int value) { DynamicsJNI.btContactSolverInfoData_solverMode_set(swigCPtr, this, value); } public int getSolverMode () { return DynamicsJNI.btContactSolverInfoData_solverMode_get(swigCPtr, this); } public void setRestingContactRestitutionThreshold (int value) { DynamicsJNI.btContactSolverInfoData_restingContactRestitutionThreshold_set(swigCPtr, this, value); } public int getRestingContactRestitutionThreshold () { return DynamicsJNI.btContactSolverInfoData_restingContactRestitutionThreshold_get(swigCPtr, this); } public void setMinimumSolverBatchSize (int value) { DynamicsJNI.btContactSolverInfoData_minimumSolverBatchSize_set(swigCPtr, this, value); } public int getMinimumSolverBatchSize () { return DynamicsJNI.btContactSolverInfoData_minimumSolverBatchSize_get(swigCPtr, this); } public void setMaxGyroscopicForce (float value) { DynamicsJNI.btContactSolverInfoData_maxGyroscopicForce_set(swigCPtr, this, value); } public float getMaxGyroscopicForce () { return DynamicsJNI.btContactSolverInfoData_maxGyroscopicForce_get(swigCPtr, this); } public void setSingleAxisRollingFrictionThreshold (float value) { DynamicsJNI.btContactSolverInfoData_singleAxisRollingFrictionThreshold_set(swigCPtr, this, value); } public float getSingleAxisRollingFrictionThreshold () { return DynamicsJNI.btContactSolverInfoData_singleAxisRollingFrictionThreshold_get(swigCPtr, this); } public void setLeastSquaresResidualThreshold (float value) { DynamicsJNI.btContactSolverInfoData_leastSquaresResidualThreshold_set(swigCPtr, this, value); } public float getLeastSquaresResidualThreshold () { return DynamicsJNI.btContactSolverInfoData_leastSquaresResidualThreshold_get(swigCPtr, this); } public void setRestitutionVelocityThreshold (float value) { DynamicsJNI.btContactSolverInfoData_restitutionVelocityThreshold_set(swigCPtr, this, value); } public float getRestitutionVelocityThreshold () { return DynamicsJNI.btContactSolverInfoData_restitutionVelocityThreshold_get(swigCPtr, this); } public btContactSolverInfoData () { this(DynamicsJNI.new_btContactSolverInfoData(), true); } }
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.dynamics; import com.badlogic.gdx.physics.bullet.BulletBase; import com.badlogic.gdx.physics.bullet.linearmath.*; import com.badlogic.gdx.physics.bullet.collision.*; public class btContactSolverInfoData extends BulletBase { private long swigCPtr; protected btContactSolverInfoData (final String className, long cPtr, boolean cMemoryOwn) { super(className, cPtr, cMemoryOwn); swigCPtr = cPtr; } /** Construct a new btContactSolverInfoData, normally you should not need this constructor it's intended for low-level * usage. */ public btContactSolverInfoData (long cPtr, boolean cMemoryOwn) { this("btContactSolverInfoData", cPtr, cMemoryOwn); construct(); } @Override protected void reset (long cPtr, boolean cMemoryOwn) { if (!destroyed) destroy(); super.reset(swigCPtr = cPtr, cMemoryOwn); } public static long getCPtr (btContactSolverInfoData obj) { return (obj == null) ? 0 : obj.swigCPtr; } @Override protected void finalize () throws Throwable { if (!destroyed) destroy(); super.finalize(); } @Override protected synchronized void delete () { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; DynamicsJNI.delete_btContactSolverInfoData(swigCPtr); } swigCPtr = 0; } super.delete(); } public void setTau (float value) { DynamicsJNI.btContactSolverInfoData_tau_set(swigCPtr, this, value); } public float getTau () { return DynamicsJNI.btContactSolverInfoData_tau_get(swigCPtr, this); } public void setDamping (float value) { DynamicsJNI.btContactSolverInfoData_damping_set(swigCPtr, this, value); } public float getDamping () { return DynamicsJNI.btContactSolverInfoData_damping_get(swigCPtr, this); } public void setFriction (float value) { DynamicsJNI.btContactSolverInfoData_friction_set(swigCPtr, this, value); } public float getFriction () { return DynamicsJNI.btContactSolverInfoData_friction_get(swigCPtr, this); } public void setTimeStep (float value) { DynamicsJNI.btContactSolverInfoData_timeStep_set(swigCPtr, this, value); } public float getTimeStep () { return DynamicsJNI.btContactSolverInfoData_timeStep_get(swigCPtr, this); } public void setRestitution (float value) { DynamicsJNI.btContactSolverInfoData_restitution_set(swigCPtr, this, value); } public float getRestitution () { return DynamicsJNI.btContactSolverInfoData_restitution_get(swigCPtr, this); } public void setNumIterations (int value) { DynamicsJNI.btContactSolverInfoData_numIterations_set(swigCPtr, this, value); } public int getNumIterations () { return DynamicsJNI.btContactSolverInfoData_numIterations_get(swigCPtr, this); } public void setMaxErrorReduction (float value) { DynamicsJNI.btContactSolverInfoData_maxErrorReduction_set(swigCPtr, this, value); } public float getMaxErrorReduction () { return DynamicsJNI.btContactSolverInfoData_maxErrorReduction_get(swigCPtr, this); } public void setSor (float value) { DynamicsJNI.btContactSolverInfoData_sor_set(swigCPtr, this, value); } public float getSor () { return DynamicsJNI.btContactSolverInfoData_sor_get(swigCPtr, this); } public void setErp (float value) { DynamicsJNI.btContactSolverInfoData_erp_set(swigCPtr, this, value); } public float getErp () { return DynamicsJNI.btContactSolverInfoData_erp_get(swigCPtr, this); } public void setErp2 (float value) { DynamicsJNI.btContactSolverInfoData_erp2_set(swigCPtr, this, value); } public float getErp2 () { return DynamicsJNI.btContactSolverInfoData_erp2_get(swigCPtr, this); } public void setGlobalCfm (float value) { DynamicsJNI.btContactSolverInfoData_globalCfm_set(swigCPtr, this, value); } public float getGlobalCfm () { return DynamicsJNI.btContactSolverInfoData_globalCfm_get(swigCPtr, this); } public void setFrictionERP (float value) { DynamicsJNI.btContactSolverInfoData_frictionERP_set(swigCPtr, this, value); } public float getFrictionERP () { return DynamicsJNI.btContactSolverInfoData_frictionERP_get(swigCPtr, this); } public void setFrictionCFM (float value) { DynamicsJNI.btContactSolverInfoData_frictionCFM_set(swigCPtr, this, value); } public float getFrictionCFM () { return DynamicsJNI.btContactSolverInfoData_frictionCFM_get(swigCPtr, this); } public void setSplitImpulse (int value) { DynamicsJNI.btContactSolverInfoData_splitImpulse_set(swigCPtr, this, value); } public int getSplitImpulse () { return DynamicsJNI.btContactSolverInfoData_splitImpulse_get(swigCPtr, this); } public void setSplitImpulsePenetrationThreshold (float value) { DynamicsJNI.btContactSolverInfoData_splitImpulsePenetrationThreshold_set(swigCPtr, this, value); } public float getSplitImpulsePenetrationThreshold () { return DynamicsJNI.btContactSolverInfoData_splitImpulsePenetrationThreshold_get(swigCPtr, this); } public void setSplitImpulseTurnErp (float value) { DynamicsJNI.btContactSolverInfoData_splitImpulseTurnErp_set(swigCPtr, this, value); } public float getSplitImpulseTurnErp () { return DynamicsJNI.btContactSolverInfoData_splitImpulseTurnErp_get(swigCPtr, this); } public void setLinearSlop (float value) { DynamicsJNI.btContactSolverInfoData_linearSlop_set(swigCPtr, this, value); } public float getLinearSlop () { return DynamicsJNI.btContactSolverInfoData_linearSlop_get(swigCPtr, this); } public void setWarmstartingFactor (float value) { DynamicsJNI.btContactSolverInfoData_warmstartingFactor_set(swigCPtr, this, value); } public float getWarmstartingFactor () { return DynamicsJNI.btContactSolverInfoData_warmstartingFactor_get(swigCPtr, this); } public void setSolverMode (int value) { DynamicsJNI.btContactSolverInfoData_solverMode_set(swigCPtr, this, value); } public int getSolverMode () { return DynamicsJNI.btContactSolverInfoData_solverMode_get(swigCPtr, this); } public void setRestingContactRestitutionThreshold (int value) { DynamicsJNI.btContactSolverInfoData_restingContactRestitutionThreshold_set(swigCPtr, this, value); } public int getRestingContactRestitutionThreshold () { return DynamicsJNI.btContactSolverInfoData_restingContactRestitutionThreshold_get(swigCPtr, this); } public void setMinimumSolverBatchSize (int value) { DynamicsJNI.btContactSolverInfoData_minimumSolverBatchSize_set(swigCPtr, this, value); } public int getMinimumSolverBatchSize () { return DynamicsJNI.btContactSolverInfoData_minimumSolverBatchSize_get(swigCPtr, this); } public void setMaxGyroscopicForce (float value) { DynamicsJNI.btContactSolverInfoData_maxGyroscopicForce_set(swigCPtr, this, value); } public float getMaxGyroscopicForce () { return DynamicsJNI.btContactSolverInfoData_maxGyroscopicForce_get(swigCPtr, this); } public void setSingleAxisRollingFrictionThreshold (float value) { DynamicsJNI.btContactSolverInfoData_singleAxisRollingFrictionThreshold_set(swigCPtr, this, value); } public float getSingleAxisRollingFrictionThreshold () { return DynamicsJNI.btContactSolverInfoData_singleAxisRollingFrictionThreshold_get(swigCPtr, this); } public void setLeastSquaresResidualThreshold (float value) { DynamicsJNI.btContactSolverInfoData_leastSquaresResidualThreshold_set(swigCPtr, this, value); } public float getLeastSquaresResidualThreshold () { return DynamicsJNI.btContactSolverInfoData_leastSquaresResidualThreshold_get(swigCPtr, this); } public void setRestitutionVelocityThreshold (float value) { DynamicsJNI.btContactSolverInfoData_restitutionVelocityThreshold_set(swigCPtr, this, value); } public float getRestitutionVelocityThreshold () { return DynamicsJNI.btContactSolverInfoData_restitutionVelocityThreshold_get(swigCPtr, this); } public btContactSolverInfoData () { this(DynamicsJNI.new_btContactSolverInfoData(), true); } }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./backends/gdx-backends-gwt/src/com/badlogic/gdx/backends/gwt/emu/java/nio/DoubleBuffer.java
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package java.nio; /** A buffer of doubles. * <p> * A double buffer can be created in either one of the following ways: * </p> * <ul> * <li>{@link #allocate(int) Allocate} a new double array and create a buffer based on it;</li> * <li>{@link #wrap(double[]) Wrap} an existing double array to create a new buffer;</li> * <li>Use {@link java.nio.ByteBuffer#asDoubleBuffer() ByteBuffer.asDoubleBuffer} to create a double buffer based on a byte * buffer.</li> * </ul> * * @since Android 1.0 */ public abstract class DoubleBuffer extends Buffer implements Comparable<DoubleBuffer> { /** Creates a double buffer based on a newly allocated double array. * * @param capacity the capacity of the new buffer. * @return the created double buffer. * @throws IllegalArgumentException if {@code capacity} is less than zero. * @since Android 1.0 */ public static DoubleBuffer allocate (int capacity) { if (capacity < 0) { throw new IllegalArgumentException(); } return BufferFactory.newDoubleBuffer(capacity); } /** Creates a new double buffer by wrapping the given double array. * <p> * Calling this method has the same effect as {@code wrap(array, 0, array.length)}. * </p> * * @param array the double array which the new buffer will be based on. * @return the created double buffer. * @since Android 1.0 */ public static DoubleBuffer wrap (double[] array) { return wrap(array, 0, array.length); } /** Creates a new double buffer by wrapping the given double array. * <p> * The new buffer's position will be {@code start}, limit will be {@code start + len}, capacity will be the length of the * array. * </p> * * @param array the double array which the new buffer will be based on. * @param start the start index, must not be negative and not greater than {@code array.length}. * @param len the length, must not be negative and not greater than {@code array.length - start}. * @return the created double buffer. * @exception IndexOutOfBoundsException if either {@code start} or {@code len} is invalid. * @since Android 1.0 */ public static DoubleBuffer wrap (double[] array, int start, int len) { int length = array.length; if (start < 0 || len < 0 || (long)start + (long)len > length) { throw new IndexOutOfBoundsException(); } DoubleBuffer buf = BufferFactory.newDoubleBuffer(array); buf.position = start; buf.limit = start + len; return buf; } /** Constructs a {@code DoubleBuffer} with given capacity. * * @param capacity the capacity of the buffer. */ DoubleBuffer (int capacity) { super(capacity); } /** Returns the double array which this buffer is based on, if there is one. * * @return the double array which this buffer is based on. * @exception ReadOnlyBufferException if this buffer is based on an array but it is read-only. * @exception UnsupportedOperationException if this buffer is not based on an array. * @since Android 1.0 */ public final double[] array () { return protectedArray(); } /** Returns the offset of the double array which this buffer is based on, if there is one. * <p> * The offset is the index of the array corresponding to the zero position of the buffer. * </p> * * @return the offset of the double array which this buffer is based on. * @exception ReadOnlyBufferException if this buffer is based on an array, but it is read-only. * @exception UnsupportedOperationException if this buffer is not based on an array. * @since Android 1.0 */ public final int arrayOffset () { return protectedArrayOffset(); } /** Returns a read-only buffer that shares its content with this buffer. * <p> * The returned buffer is guaranteed to be a new instance, even if this buffer is read-only itself. The new buffer's position, * limit, capacity and mark are the same as this buffer's. * </p> * <p> * The new buffer shares its content with this buffer, which means that this buffer's change of content will be visible to the * new buffer. The two buffer's position, limit and mark are independent. * </p> * * @return a read-only version of this buffer. * @since Android 1.0 */ public abstract DoubleBuffer asReadOnlyBuffer (); /** Compacts this double buffer. * <p> * The remaining doubles will be moved to the head of the buffer, staring from position zero. Then the position is set to * {@code remaining()}; the limit is set to capacity; the mark is cleared. * </p> * * @return this buffer. * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. * @since Android 1.0 */ public abstract DoubleBuffer compact (); /** Compare the remaining doubles of this buffer to another double buffer's remaining doubles. * * @param otherBuffer another double buffer. * @return a negative value if this is less than {@code other}; 0 if this equals to {@code other}; a positive value if this is * greater than {@code other}. * @exception ClassCastException if {@code other} is not a double buffer. * @since Android 1.0 */ public int compareTo (DoubleBuffer otherBuffer) { int compareRemaining = (remaining() < otherBuffer.remaining()) ? remaining() : otherBuffer.remaining(); int thisPos = position; int otherPos = otherBuffer.position; // BEGIN android-changed double thisDouble, otherDouble; while (compareRemaining > 0) { thisDouble = get(thisPos); otherDouble = otherBuffer.get(otherPos); // checks for double and NaN inequality if ((thisDouble != otherDouble) && ((thisDouble == thisDouble) || (otherDouble == otherDouble))) { return thisDouble < otherDouble ? -1 : 1; } thisPos++; otherPos++; compareRemaining--; } // END android-changed return remaining() - otherBuffer.remaining(); } /** Returns a duplicated buffer that shares its content with this buffer. * <p> * The duplicated buffer's position, limit, capacity and mark are the same as this buffer's. The duplicated buffer's read-only * property and byte order are the same as this buffer's, too. * </p> * <p> * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the * other. The two buffer's position, limit and mark are independent. * </p> * * @return a duplicated buffer that shares its content with this buffer. * @since Android 1.0 */ public abstract DoubleBuffer duplicate (); /** Checks whether this double buffer is equal to another object. * <p> * If {@code other} is not a double buffer then {@code false} is returned. Two double buffers are equal if and only if their * remaining doubles are exactly the same. Position, limit, capacity and mark are not considered. * </p> * * @param other the object to compare with this double buffer. * @return {@code true} if this double buffer is equal to {@code other}, {@code false} otherwise. * @since Android 1.0 */ public boolean equals (Object other) { if (!(other instanceof DoubleBuffer)) { return false; } DoubleBuffer otherBuffer = (DoubleBuffer)other; if (remaining() != otherBuffer.remaining()) { return false; } int myPosition = position; int otherPosition = otherBuffer.position; boolean equalSoFar = true; while (equalSoFar && (myPosition < limit)) { equalSoFar = get(myPosition++) == otherBuffer.get(otherPosition++); } return equalSoFar; } /** Returns the double at the current position and increases the position by 1. * * @return the double at the current position. * @exception BufferUnderflowException if the position is equal or greater than limit. * @since Android 1.0 */ public abstract double get (); /** Reads doubles from the current position into the specified double array and increases the position by the number of doubles * read. * <p> * Calling this method has the same effect as {@code get(dest, 0, dest.length)}. * </p> * * @param dest the destination double array. * @return this buffer. * @exception BufferUnderflowException if {@code dest.length} is greater than {@code remaining()}. * @since Android 1.0 */ public DoubleBuffer get (double[] dest) { return get(dest, 0, dest.length); } /** Reads doubles from the current position into the specified double array, starting from the specified offset, and increases * the position by the number of doubles read. * * @param dest the target double array. * @param off the offset of the double array, must not be negative and not greater than {@code dest.length}. * @param len the number of doubles to read, must be no less than zero and not greater than {@code dest.length - off}. * @return this buffer. * @exception IndexOutOfBoundsException if either {@code off} or {@code len} is invalid. * @exception BufferUnderflowException if {@code len} is greater than {@code remaining()}. * @since Android 1.0 */ public DoubleBuffer get (double[] dest, int off, int len) { int length = dest.length; if (off < 0 || len < 0 || (long)off + (long)len > length) { throw new IndexOutOfBoundsException(); } if (len > remaining()) { throw new BufferUnderflowException(); } for (int i = off; i < off + len; i++) { dest[i] = get(); } return this; } /** Returns a double at the specified index; the position is not changed. * * @param index the index, must not be negative and less than limit. * @return a double at the specified index. * @exception IndexOutOfBoundsException if index is invalid. * @since Android 1.0 */ public abstract double get (int index); /** Indicates whether this buffer is based on a double array and is read/write. * * @return {@code true} if this buffer is based on a double array and provides read/write access, {@code false} otherwise. * @since Android 1.0 */ public final boolean hasArray () { return protectedHasArray(); } // /** // * Calculates this buffer's hash code from the remaining chars. The // * position, limit, capacity and mark don't affect the hash code. // * // * @return the hash code calculated from the remaining chars. // * @since Android 1.0 // */ // public int hashCode() { // int myPosition = position; // int hash = 0; // long l; // while (myPosition < limit) { // l = Double.doubleToLongBits(get(myPosition++)); // hash = hash + ((int) l) ^ ((int) (l >> 32)); // } // return hash; // } /** Indicates whether this buffer is direct. A direct buffer will try its best to take advantage of native memory APIs and it * may not stay in the Java heap, so it is not affected by garbage collection. * <p> * A double buffer is direct if it is based on a byte buffer and the byte buffer is direct. * </p> * * @return {@code true} if this buffer is direct, {@code false} otherwise. * @since Android 1.0 */ public abstract boolean isDirect (); /** Returns the byte order used by this buffer when converting doubles from/to bytes. * <p> * If this buffer is not based on a byte buffer, then this always returns the platform's native byte order. * </p> * * @return the byte order used by this buffer when converting doubles from/to bytes. * @since Android 1.0 */ public abstract ByteOrder order (); /** Child class implements this method to realize {@code array()}. * * @see #array() */ abstract double[] protectedArray (); /** Child class implements this method to realize {@code arrayOffset()}. * * @see #arrayOffset() */ abstract int protectedArrayOffset (); /** Child class implements this method to realize {@code hasArray()}. * * @see #hasArray() */ abstract boolean protectedHasArray (); /** Writes the given double to the current position and increases the position by 1. * * @param d the double to write. * @return this buffer. * @exception BufferOverflowException if position is equal or greater than limit. * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. * @since Android 1.0 */ public abstract DoubleBuffer put (double d); /** Writes doubles from the given double array to the current position and increases the position by the number of doubles * written. * <p> * Calling this method has the same effect as {@code put(src, 0, src.length)}. * </p> * * @param src the source double array. * @return this buffer. * @exception BufferOverflowException if {@code remaining()} is less than {@code src.length}. * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. * @since Android 1.0 */ public final DoubleBuffer put (double[] src) { return put(src, 0, src.length); } /** Writes doubles from the given double array, starting from the specified offset, to the current position and increases the * position by the number of doubles written. * * @param src the source double array. * @param off the offset of double array, must not be negative and not greater than {@code src.length}. * @param len the number of doubles to write, must be no less than zero and not greater than {@code src.length - off}. * @return this buffer. * @exception BufferOverflowException if {@code remaining()} is less than {@code len}. * @exception IndexOutOfBoundsException if either {@code off} or {@code len} is invalid. * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. * @since Android 1.0 */ public DoubleBuffer put (double[] src, int off, int len) { int length = src.length; if (off < 0 || len < 0 || (long)off + (long)len > length) { throw new IndexOutOfBoundsException(); } if (len > remaining()) { throw new BufferOverflowException(); } for (int i = off; i < off + len; i++) { put(src[i]); } return this; } /** Writes all the remaining doubles of the {@code src} double buffer to this buffer's current position, and increases both * buffers' position by the number of doubles copied. * * @param src the source double buffer. * @return this buffer. * @exception BufferOverflowException if {@code src.remaining()} is greater than this buffer's {@code remaining()}. * @exception IllegalArgumentException if {@code src} is this buffer. * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. * @since Android 1.0 */ public DoubleBuffer put (DoubleBuffer src) { if (src == this) { throw new IllegalArgumentException(); } if (src.remaining() > remaining()) { throw new BufferOverflowException(); } double[] doubles = new double[src.remaining()]; src.get(doubles); put(doubles); return this; } /** Write a double to the specified index of this buffer and the position is not changed. * * @param index the index, must not be negative and less than the limit. * @param d the double to write. * @return this buffer. * @exception IndexOutOfBoundsException if index is invalid. * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. * @since Android 1.0 */ public abstract DoubleBuffer put (int index, double d); /** Returns a sliced buffer that shares its content with this buffer. * <p> * The sliced buffer's capacity will be this buffer's {@code remaining()}, and its zero position will correspond to this * buffer's current position. The new buffer's position will be 0, limit will be its capacity, and its mark is cleared. The new * buffer's read-only property and byte order are the same as this buffer's. * </p> * <p> * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the * other. The two buffer's position, limit and mark are independent. * </p> * * @return a sliced buffer that shares its content with this buffer. * @since Android 1.0 */ public abstract DoubleBuffer slice (); /** Returns a string representing the state of this double buffer. * * @return A string representing the state of this double buffer. * @since Android 1.0 */ public String toString () { StringBuilder sb = new StringBuilder(); sb.append(getClass().getName()); sb.append(", status: capacity="); //$NON-NLS-1$ sb.append(capacity()); sb.append(" position="); //$NON-NLS-1$ sb.append(position()); sb.append(" limit="); //$NON-NLS-1$ sb.append(limit()); return sb.toString(); } }
/* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with * this work for additional information regarding copyright ownership. * The ASF licenses this file to You under the Apache License, Version 2.0 * (the "License"); you may not use this file except in compliance with * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package java.nio; /** A buffer of doubles. * <p> * A double buffer can be created in either one of the following ways: * </p> * <ul> * <li>{@link #allocate(int) Allocate} a new double array and create a buffer based on it;</li> * <li>{@link #wrap(double[]) Wrap} an existing double array to create a new buffer;</li> * <li>Use {@link java.nio.ByteBuffer#asDoubleBuffer() ByteBuffer.asDoubleBuffer} to create a double buffer based on a byte * buffer.</li> * </ul> * * @since Android 1.0 */ public abstract class DoubleBuffer extends Buffer implements Comparable<DoubleBuffer> { /** Creates a double buffer based on a newly allocated double array. * * @param capacity the capacity of the new buffer. * @return the created double buffer. * @throws IllegalArgumentException if {@code capacity} is less than zero. * @since Android 1.0 */ public static DoubleBuffer allocate (int capacity) { if (capacity < 0) { throw new IllegalArgumentException(); } return BufferFactory.newDoubleBuffer(capacity); } /** Creates a new double buffer by wrapping the given double array. * <p> * Calling this method has the same effect as {@code wrap(array, 0, array.length)}. * </p> * * @param array the double array which the new buffer will be based on. * @return the created double buffer. * @since Android 1.0 */ public static DoubleBuffer wrap (double[] array) { return wrap(array, 0, array.length); } /** Creates a new double buffer by wrapping the given double array. * <p> * The new buffer's position will be {@code start}, limit will be {@code start + len}, capacity will be the length of the * array. * </p> * * @param array the double array which the new buffer will be based on. * @param start the start index, must not be negative and not greater than {@code array.length}. * @param len the length, must not be negative and not greater than {@code array.length - start}. * @return the created double buffer. * @exception IndexOutOfBoundsException if either {@code start} or {@code len} is invalid. * @since Android 1.0 */ public static DoubleBuffer wrap (double[] array, int start, int len) { int length = array.length; if (start < 0 || len < 0 || (long)start + (long)len > length) { throw new IndexOutOfBoundsException(); } DoubleBuffer buf = BufferFactory.newDoubleBuffer(array); buf.position = start; buf.limit = start + len; return buf; } /** Constructs a {@code DoubleBuffer} with given capacity. * * @param capacity the capacity of the buffer. */ DoubleBuffer (int capacity) { super(capacity); } /** Returns the double array which this buffer is based on, if there is one. * * @return the double array which this buffer is based on. * @exception ReadOnlyBufferException if this buffer is based on an array but it is read-only. * @exception UnsupportedOperationException if this buffer is not based on an array. * @since Android 1.0 */ public final double[] array () { return protectedArray(); } /** Returns the offset of the double array which this buffer is based on, if there is one. * <p> * The offset is the index of the array corresponding to the zero position of the buffer. * </p> * * @return the offset of the double array which this buffer is based on. * @exception ReadOnlyBufferException if this buffer is based on an array, but it is read-only. * @exception UnsupportedOperationException if this buffer is not based on an array. * @since Android 1.0 */ public final int arrayOffset () { return protectedArrayOffset(); } /** Returns a read-only buffer that shares its content with this buffer. * <p> * The returned buffer is guaranteed to be a new instance, even if this buffer is read-only itself. The new buffer's position, * limit, capacity and mark are the same as this buffer's. * </p> * <p> * The new buffer shares its content with this buffer, which means that this buffer's change of content will be visible to the * new buffer. The two buffer's position, limit and mark are independent. * </p> * * @return a read-only version of this buffer. * @since Android 1.0 */ public abstract DoubleBuffer asReadOnlyBuffer (); /** Compacts this double buffer. * <p> * The remaining doubles will be moved to the head of the buffer, staring from position zero. Then the position is set to * {@code remaining()}; the limit is set to capacity; the mark is cleared. * </p> * * @return this buffer. * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. * @since Android 1.0 */ public abstract DoubleBuffer compact (); /** Compare the remaining doubles of this buffer to another double buffer's remaining doubles. * * @param otherBuffer another double buffer. * @return a negative value if this is less than {@code other}; 0 if this equals to {@code other}; a positive value if this is * greater than {@code other}. * @exception ClassCastException if {@code other} is not a double buffer. * @since Android 1.0 */ public int compareTo (DoubleBuffer otherBuffer) { int compareRemaining = (remaining() < otherBuffer.remaining()) ? remaining() : otherBuffer.remaining(); int thisPos = position; int otherPos = otherBuffer.position; // BEGIN android-changed double thisDouble, otherDouble; while (compareRemaining > 0) { thisDouble = get(thisPos); otherDouble = otherBuffer.get(otherPos); // checks for double and NaN inequality if ((thisDouble != otherDouble) && ((thisDouble == thisDouble) || (otherDouble == otherDouble))) { return thisDouble < otherDouble ? -1 : 1; } thisPos++; otherPos++; compareRemaining--; } // END android-changed return remaining() - otherBuffer.remaining(); } /** Returns a duplicated buffer that shares its content with this buffer. * <p> * The duplicated buffer's position, limit, capacity and mark are the same as this buffer's. The duplicated buffer's read-only * property and byte order are the same as this buffer's, too. * </p> * <p> * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the * other. The two buffer's position, limit and mark are independent. * </p> * * @return a duplicated buffer that shares its content with this buffer. * @since Android 1.0 */ public abstract DoubleBuffer duplicate (); /** Checks whether this double buffer is equal to another object. * <p> * If {@code other} is not a double buffer then {@code false} is returned. Two double buffers are equal if and only if their * remaining doubles are exactly the same. Position, limit, capacity and mark are not considered. * </p> * * @param other the object to compare with this double buffer. * @return {@code true} if this double buffer is equal to {@code other}, {@code false} otherwise. * @since Android 1.0 */ public boolean equals (Object other) { if (!(other instanceof DoubleBuffer)) { return false; } DoubleBuffer otherBuffer = (DoubleBuffer)other; if (remaining() != otherBuffer.remaining()) { return false; } int myPosition = position; int otherPosition = otherBuffer.position; boolean equalSoFar = true; while (equalSoFar && (myPosition < limit)) { equalSoFar = get(myPosition++) == otherBuffer.get(otherPosition++); } return equalSoFar; } /** Returns the double at the current position and increases the position by 1. * * @return the double at the current position. * @exception BufferUnderflowException if the position is equal or greater than limit. * @since Android 1.0 */ public abstract double get (); /** Reads doubles from the current position into the specified double array and increases the position by the number of doubles * read. * <p> * Calling this method has the same effect as {@code get(dest, 0, dest.length)}. * </p> * * @param dest the destination double array. * @return this buffer. * @exception BufferUnderflowException if {@code dest.length} is greater than {@code remaining()}. * @since Android 1.0 */ public DoubleBuffer get (double[] dest) { return get(dest, 0, dest.length); } /** Reads doubles from the current position into the specified double array, starting from the specified offset, and increases * the position by the number of doubles read. * * @param dest the target double array. * @param off the offset of the double array, must not be negative and not greater than {@code dest.length}. * @param len the number of doubles to read, must be no less than zero and not greater than {@code dest.length - off}. * @return this buffer. * @exception IndexOutOfBoundsException if either {@code off} or {@code len} is invalid. * @exception BufferUnderflowException if {@code len} is greater than {@code remaining()}. * @since Android 1.0 */ public DoubleBuffer get (double[] dest, int off, int len) { int length = dest.length; if (off < 0 || len < 0 || (long)off + (long)len > length) { throw new IndexOutOfBoundsException(); } if (len > remaining()) { throw new BufferUnderflowException(); } for (int i = off; i < off + len; i++) { dest[i] = get(); } return this; } /** Returns a double at the specified index; the position is not changed. * * @param index the index, must not be negative and less than limit. * @return a double at the specified index. * @exception IndexOutOfBoundsException if index is invalid. * @since Android 1.0 */ public abstract double get (int index); /** Indicates whether this buffer is based on a double array and is read/write. * * @return {@code true} if this buffer is based on a double array and provides read/write access, {@code false} otherwise. * @since Android 1.0 */ public final boolean hasArray () { return protectedHasArray(); } // /** // * Calculates this buffer's hash code from the remaining chars. The // * position, limit, capacity and mark don't affect the hash code. // * // * @return the hash code calculated from the remaining chars. // * @since Android 1.0 // */ // public int hashCode() { // int myPosition = position; // int hash = 0; // long l; // while (myPosition < limit) { // l = Double.doubleToLongBits(get(myPosition++)); // hash = hash + ((int) l) ^ ((int) (l >> 32)); // } // return hash; // } /** Indicates whether this buffer is direct. A direct buffer will try its best to take advantage of native memory APIs and it * may not stay in the Java heap, so it is not affected by garbage collection. * <p> * A double buffer is direct if it is based on a byte buffer and the byte buffer is direct. * </p> * * @return {@code true} if this buffer is direct, {@code false} otherwise. * @since Android 1.0 */ public abstract boolean isDirect (); /** Returns the byte order used by this buffer when converting doubles from/to bytes. * <p> * If this buffer is not based on a byte buffer, then this always returns the platform's native byte order. * </p> * * @return the byte order used by this buffer when converting doubles from/to bytes. * @since Android 1.0 */ public abstract ByteOrder order (); /** Child class implements this method to realize {@code array()}. * * @see #array() */ abstract double[] protectedArray (); /** Child class implements this method to realize {@code arrayOffset()}. * * @see #arrayOffset() */ abstract int protectedArrayOffset (); /** Child class implements this method to realize {@code hasArray()}. * * @see #hasArray() */ abstract boolean protectedHasArray (); /** Writes the given double to the current position and increases the position by 1. * * @param d the double to write. * @return this buffer. * @exception BufferOverflowException if position is equal or greater than limit. * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. * @since Android 1.0 */ public abstract DoubleBuffer put (double d); /** Writes doubles from the given double array to the current position and increases the position by the number of doubles * written. * <p> * Calling this method has the same effect as {@code put(src, 0, src.length)}. * </p> * * @param src the source double array. * @return this buffer. * @exception BufferOverflowException if {@code remaining()} is less than {@code src.length}. * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. * @since Android 1.0 */ public final DoubleBuffer put (double[] src) { return put(src, 0, src.length); } /** Writes doubles from the given double array, starting from the specified offset, to the current position and increases the * position by the number of doubles written. * * @param src the source double array. * @param off the offset of double array, must not be negative and not greater than {@code src.length}. * @param len the number of doubles to write, must be no less than zero and not greater than {@code src.length - off}. * @return this buffer. * @exception BufferOverflowException if {@code remaining()} is less than {@code len}. * @exception IndexOutOfBoundsException if either {@code off} or {@code len} is invalid. * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. * @since Android 1.0 */ public DoubleBuffer put (double[] src, int off, int len) { int length = src.length; if (off < 0 || len < 0 || (long)off + (long)len > length) { throw new IndexOutOfBoundsException(); } if (len > remaining()) { throw new BufferOverflowException(); } for (int i = off; i < off + len; i++) { put(src[i]); } return this; } /** Writes all the remaining doubles of the {@code src} double buffer to this buffer's current position, and increases both * buffers' position by the number of doubles copied. * * @param src the source double buffer. * @return this buffer. * @exception BufferOverflowException if {@code src.remaining()} is greater than this buffer's {@code remaining()}. * @exception IllegalArgumentException if {@code src} is this buffer. * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. * @since Android 1.0 */ public DoubleBuffer put (DoubleBuffer src) { if (src == this) { throw new IllegalArgumentException(); } if (src.remaining() > remaining()) { throw new BufferOverflowException(); } double[] doubles = new double[src.remaining()]; src.get(doubles); put(doubles); return this; } /** Write a double to the specified index of this buffer and the position is not changed. * * @param index the index, must not be negative and less than the limit. * @param d the double to write. * @return this buffer. * @exception IndexOutOfBoundsException if index is invalid. * @exception ReadOnlyBufferException if no changes may be made to the contents of this buffer. * @since Android 1.0 */ public abstract DoubleBuffer put (int index, double d); /** Returns a sliced buffer that shares its content with this buffer. * <p> * The sliced buffer's capacity will be this buffer's {@code remaining()}, and its zero position will correspond to this * buffer's current position. The new buffer's position will be 0, limit will be its capacity, and its mark is cleared. The new * buffer's read-only property and byte order are the same as this buffer's. * </p> * <p> * The new buffer shares its content with this buffer, which means either buffer's change of content will be visible to the * other. The two buffer's position, limit and mark are independent. * </p> * * @return a sliced buffer that shares its content with this buffer. * @since Android 1.0 */ public abstract DoubleBuffer slice (); /** Returns a string representing the state of this double buffer. * * @return A string representing the state of this double buffer. * @since Android 1.0 */ public String toString () { StringBuilder sb = new StringBuilder(); sb.append(getClass().getName()); sb.append(", status: capacity="); //$NON-NLS-1$ sb.append(capacity()); sb.append(" position="); //$NON-NLS-1$ sb.append(position()); sb.append(" limit="); //$NON-NLS-1$ sb.append(limit()); return sb.toString(); } }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./extensions/gdx-bullet/jni/swig-src/linearmath/com/badlogic/gdx/physics/bullet/linearmath/btTransform.java
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.linearmath; import com.badlogic.gdx.physics.bullet.BulletBase; import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.math.Quaternion; import com.badlogic.gdx.math.Matrix3; import com.badlogic.gdx.math.Matrix4; public class btTransform extends BulletBase { private long swigCPtr; protected btTransform (final String className, long cPtr, boolean cMemoryOwn) { super(className, cPtr, cMemoryOwn); swigCPtr = cPtr; } /** Construct a new btTransform, normally you should not need this constructor it's intended for low-level usage. */ public btTransform (long cPtr, boolean cMemoryOwn) { this("btTransform", cPtr, cMemoryOwn); construct(); } @Override protected void reset (long cPtr, boolean cMemoryOwn) { if (!destroyed) destroy(); super.reset(swigCPtr = cPtr, cMemoryOwn); } public static long getCPtr (btTransform obj) { return (obj == null) ? 0 : obj.swigCPtr; } @Override protected void finalize () throws Throwable { if (!destroyed) destroy(); super.finalize(); } @Override protected synchronized void delete () { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; LinearMathJNI.delete_btTransform(swigCPtr); } swigCPtr = 0; } super.delete(); } public btTransform () { this(LinearMathJNI.new_btTransform__SWIG_0(), true); } public btTransform (Quaternion q, Vector3 c) { this(LinearMathJNI.new_btTransform__SWIG_1(q, c), true); } public btTransform (Quaternion q) { this(LinearMathJNI.new_btTransform__SWIG_2(q), true); } public btTransform (Matrix3 b, Vector3 c) { this(LinearMathJNI.new_btTransform__SWIG_3(b, c), true); } public btTransform (Matrix3 b) { this(LinearMathJNI.new_btTransform__SWIG_4(b), true); } public btTransform (Matrix4 other) { this(LinearMathJNI.new_btTransform__SWIG_5(other), true); } public Matrix4 operatorAssignment (Matrix4 other) { return LinearMathJNI.btTransform_operatorAssignment(swigCPtr, this, other); } public void mult (Matrix4 t1, Matrix4 t2) { LinearMathJNI.btTransform_mult(swigCPtr, this, t1, t2); } public Vector3 operatorFunctionCall (Vector3 x) { return LinearMathJNI.btTransform_operatorFunctionCall(swigCPtr, this, x); } public Vector3 operatorMultiplication (Vector3 x) { return LinearMathJNI.btTransform_operatorMultiplication__SWIG_0(swigCPtr, this, x); } public Quaternion operatorMultiplication (Quaternion q) { return LinearMathJNI.btTransform_operatorMultiplication__SWIG_1(swigCPtr, this, q); } public Matrix3 getBasis () { return LinearMathJNI.btTransform_getBasis(swigCPtr, this); } public Matrix3 getBasisConst () { return LinearMathJNI.btTransform_getBasisConst(swigCPtr, this); } public Vector3 getOrigin () { return LinearMathJNI.btTransform_getOrigin(swigCPtr, this); } public Vector3 getOriginConst () { return LinearMathJNI.btTransform_getOriginConst(swigCPtr, this); } public Quaternion getRotation () { return LinearMathJNI.btTransform_getRotation(swigCPtr, this); } public void setFromOpenGLMatrix (float[] m) { LinearMathJNI.btTransform_setFromOpenGLMatrix(swigCPtr, this, m); } public void getOpenGLMatrix (float[] m) { LinearMathJNI.btTransform_getOpenGLMatrix(swigCPtr, this, m); } public void setOrigin (Vector3 origin) { LinearMathJNI.btTransform_setOrigin(swigCPtr, this, origin); } public Vector3 invXform (Vector3 inVec) { return LinearMathJNI.btTransform_invXform(swigCPtr, this, inVec); } public void setBasis (Matrix3 basis) { LinearMathJNI.btTransform_setBasis(swigCPtr, this, basis); } public void setRotation (Quaternion q) { LinearMathJNI.btTransform_setRotation(swigCPtr, this, q); } public void setIdentity () { LinearMathJNI.btTransform_setIdentity(swigCPtr, this); } public Matrix4 operatorMultiplicationAssignment (Matrix4 t) { return LinearMathJNI.btTransform_operatorMultiplicationAssignment(swigCPtr, this, t); } public Matrix4 inverse () { return LinearMathJNI.btTransform_inverse(swigCPtr, this); } public Matrix4 inverseTimes (Matrix4 t) { return LinearMathJNI.btTransform_inverseTimes(swigCPtr, this, t); } public Matrix4 operatorMultiplication (Matrix4 t) { return LinearMathJNI.btTransform_operatorMultiplication__SWIG_2(swigCPtr, this, t); } public static Matrix4 getIdentity () { return LinearMathJNI.btTransform_getIdentity(); } public void serialize (btTransformFloatData dataOut) { LinearMathJNI.btTransform_serialize(swigCPtr, this, btTransformFloatData.getCPtr(dataOut), dataOut); } public void serializeFloat (btTransformFloatData dataOut) { LinearMathJNI.btTransform_serializeFloat(swigCPtr, this, btTransformFloatData.getCPtr(dataOut), dataOut); } public void deSerialize (btTransformFloatData dataIn) { LinearMathJNI.btTransform_deSerialize(swigCPtr, this, btTransformFloatData.getCPtr(dataIn), dataIn); } public void deSerializeDouble (btTransformDoubleData dataIn) { LinearMathJNI.btTransform_deSerializeDouble(swigCPtr, this, btTransformDoubleData.getCPtr(dataIn), dataIn); } public void deSerializeFloat (btTransformFloatData dataIn) { LinearMathJNI.btTransform_deSerializeFloat(swigCPtr, this, btTransformFloatData.getCPtr(dataIn), dataIn); } }
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.linearmath; import com.badlogic.gdx.physics.bullet.BulletBase; import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.math.Quaternion; import com.badlogic.gdx.math.Matrix3; import com.badlogic.gdx.math.Matrix4; public class btTransform extends BulletBase { private long swigCPtr; protected btTransform (final String className, long cPtr, boolean cMemoryOwn) { super(className, cPtr, cMemoryOwn); swigCPtr = cPtr; } /** Construct a new btTransform, normally you should not need this constructor it's intended for low-level usage. */ public btTransform (long cPtr, boolean cMemoryOwn) { this("btTransform", cPtr, cMemoryOwn); construct(); } @Override protected void reset (long cPtr, boolean cMemoryOwn) { if (!destroyed) destroy(); super.reset(swigCPtr = cPtr, cMemoryOwn); } public static long getCPtr (btTransform obj) { return (obj == null) ? 0 : obj.swigCPtr; } @Override protected void finalize () throws Throwable { if (!destroyed) destroy(); super.finalize(); } @Override protected synchronized void delete () { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; LinearMathJNI.delete_btTransform(swigCPtr); } swigCPtr = 0; } super.delete(); } public btTransform () { this(LinearMathJNI.new_btTransform__SWIG_0(), true); } public btTransform (Quaternion q, Vector3 c) { this(LinearMathJNI.new_btTransform__SWIG_1(q, c), true); } public btTransform (Quaternion q) { this(LinearMathJNI.new_btTransform__SWIG_2(q), true); } public btTransform (Matrix3 b, Vector3 c) { this(LinearMathJNI.new_btTransform__SWIG_3(b, c), true); } public btTransform (Matrix3 b) { this(LinearMathJNI.new_btTransform__SWIG_4(b), true); } public btTransform (Matrix4 other) { this(LinearMathJNI.new_btTransform__SWIG_5(other), true); } public Matrix4 operatorAssignment (Matrix4 other) { return LinearMathJNI.btTransform_operatorAssignment(swigCPtr, this, other); } public void mult (Matrix4 t1, Matrix4 t2) { LinearMathJNI.btTransform_mult(swigCPtr, this, t1, t2); } public Vector3 operatorFunctionCall (Vector3 x) { return LinearMathJNI.btTransform_operatorFunctionCall(swigCPtr, this, x); } public Vector3 operatorMultiplication (Vector3 x) { return LinearMathJNI.btTransform_operatorMultiplication__SWIG_0(swigCPtr, this, x); } public Quaternion operatorMultiplication (Quaternion q) { return LinearMathJNI.btTransform_operatorMultiplication__SWIG_1(swigCPtr, this, q); } public Matrix3 getBasis () { return LinearMathJNI.btTransform_getBasis(swigCPtr, this); } public Matrix3 getBasisConst () { return LinearMathJNI.btTransform_getBasisConst(swigCPtr, this); } public Vector3 getOrigin () { return LinearMathJNI.btTransform_getOrigin(swigCPtr, this); } public Vector3 getOriginConst () { return LinearMathJNI.btTransform_getOriginConst(swigCPtr, this); } public Quaternion getRotation () { return LinearMathJNI.btTransform_getRotation(swigCPtr, this); } public void setFromOpenGLMatrix (float[] m) { LinearMathJNI.btTransform_setFromOpenGLMatrix(swigCPtr, this, m); } public void getOpenGLMatrix (float[] m) { LinearMathJNI.btTransform_getOpenGLMatrix(swigCPtr, this, m); } public void setOrigin (Vector3 origin) { LinearMathJNI.btTransform_setOrigin(swigCPtr, this, origin); } public Vector3 invXform (Vector3 inVec) { return LinearMathJNI.btTransform_invXform(swigCPtr, this, inVec); } public void setBasis (Matrix3 basis) { LinearMathJNI.btTransform_setBasis(swigCPtr, this, basis); } public void setRotation (Quaternion q) { LinearMathJNI.btTransform_setRotation(swigCPtr, this, q); } public void setIdentity () { LinearMathJNI.btTransform_setIdentity(swigCPtr, this); } public Matrix4 operatorMultiplicationAssignment (Matrix4 t) { return LinearMathJNI.btTransform_operatorMultiplicationAssignment(swigCPtr, this, t); } public Matrix4 inverse () { return LinearMathJNI.btTransform_inverse(swigCPtr, this); } public Matrix4 inverseTimes (Matrix4 t) { return LinearMathJNI.btTransform_inverseTimes(swigCPtr, this, t); } public Matrix4 operatorMultiplication (Matrix4 t) { return LinearMathJNI.btTransform_operatorMultiplication__SWIG_2(swigCPtr, this, t); } public static Matrix4 getIdentity () { return LinearMathJNI.btTransform_getIdentity(); } public void serialize (btTransformFloatData dataOut) { LinearMathJNI.btTransform_serialize(swigCPtr, this, btTransformFloatData.getCPtr(dataOut), dataOut); } public void serializeFloat (btTransformFloatData dataOut) { LinearMathJNI.btTransform_serializeFloat(swigCPtr, this, btTransformFloatData.getCPtr(dataOut), dataOut); } public void deSerialize (btTransformFloatData dataIn) { LinearMathJNI.btTransform_deSerialize(swigCPtr, this, btTransformFloatData.getCPtr(dataIn), dataIn); } public void deSerializeDouble (btTransformDoubleData dataIn) { LinearMathJNI.btTransform_deSerializeDouble(swigCPtr, this, btTransformDoubleData.getCPtr(dataIn), dataIn); } public void deSerializeFloat (btTransformFloatData dataIn) { LinearMathJNI.btTransform_deSerializeFloat(swigCPtr, this, btTransformFloatData.getCPtr(dataIn), dataIn); } }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./extensions/gdx-bullet/jni/swig-src/collision/com/badlogic/gdx/physics/bullet/collision/btDbvtBroadphase.java
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.collision; import com.badlogic.gdx.physics.bullet.linearmath.*; import com.badlogic.gdx.math.Vector3; public class btDbvtBroadphase extends btBroadphaseInterface { private long swigCPtr; protected btDbvtBroadphase (final String className, long cPtr, boolean cMemoryOwn) { super(className, CollisionJNI.btDbvtBroadphase_SWIGUpcast(cPtr), cMemoryOwn); swigCPtr = cPtr; } /** Construct a new btDbvtBroadphase, normally you should not need this constructor it's intended for low-level usage. */ public btDbvtBroadphase (long cPtr, boolean cMemoryOwn) { this("btDbvtBroadphase", cPtr, cMemoryOwn); construct(); } @Override protected void reset (long cPtr, boolean cMemoryOwn) { if (!destroyed) destroy(); super.reset(CollisionJNI.btDbvtBroadphase_SWIGUpcast(swigCPtr = cPtr), cMemoryOwn); } public static long getCPtr (btDbvtBroadphase obj) { return (obj == null) ? 0 : obj.swigCPtr; } @Override protected void finalize () throws Throwable { if (!destroyed) destroy(); super.finalize(); } @Override protected synchronized void delete () { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; CollisionJNI.delete_btDbvtBroadphase(swigCPtr); } swigCPtr = 0; } super.delete(); } public void setSets (btDbvt value) { CollisionJNI.btDbvtBroadphase_sets_set(swigCPtr, this, btDbvt.getCPtr(value), value); } public btDbvt getSets () { long cPtr = CollisionJNI.btDbvtBroadphase_sets_get(swigCPtr, this); return (cPtr == 0) ? null : new btDbvt(cPtr, false); } public void setStageRoots (SWIGTYPE_p_p_btDbvtProxy value) { CollisionJNI.btDbvtBroadphase_stageRoots_set(swigCPtr, this, SWIGTYPE_p_p_btDbvtProxy.getCPtr(value)); } public SWIGTYPE_p_p_btDbvtProxy getStageRoots () { long cPtr = CollisionJNI.btDbvtBroadphase_stageRoots_get(swigCPtr, this); return (cPtr == 0) ? null : new SWIGTYPE_p_p_btDbvtProxy(cPtr, false); } public void setPaircache (btOverlappingPairCache value) { CollisionJNI.btDbvtBroadphase_paircache_set(swigCPtr, this, btOverlappingPairCache.getCPtr(value), value); } public btOverlappingPairCache getPaircache () { long cPtr = CollisionJNI.btDbvtBroadphase_paircache_get(swigCPtr, this); return (cPtr == 0) ? null : new btOverlappingPairCache(cPtr, false); } public void setPrediction (float value) { CollisionJNI.btDbvtBroadphase_prediction_set(swigCPtr, this, value); } public float getPrediction () { return CollisionJNI.btDbvtBroadphase_prediction_get(swigCPtr, this); } public void setStageCurrent (int value) { CollisionJNI.btDbvtBroadphase_stageCurrent_set(swigCPtr, this, value); } public int getStageCurrent () { return CollisionJNI.btDbvtBroadphase_stageCurrent_get(swigCPtr, this); } public void setFupdates (int value) { CollisionJNI.btDbvtBroadphase_fupdates_set(swigCPtr, this, value); } public int getFupdates () { return CollisionJNI.btDbvtBroadphase_fupdates_get(swigCPtr, this); } public void setDupdates (int value) { CollisionJNI.btDbvtBroadphase_dupdates_set(swigCPtr, this, value); } public int getDupdates () { return CollisionJNI.btDbvtBroadphase_dupdates_get(swigCPtr, this); } public void setCupdates (int value) { CollisionJNI.btDbvtBroadphase_cupdates_set(swigCPtr, this, value); } public int getCupdates () { return CollisionJNI.btDbvtBroadphase_cupdates_get(swigCPtr, this); } public void setNewpairs (int value) { CollisionJNI.btDbvtBroadphase_newpairs_set(swigCPtr, this, value); } public int getNewpairs () { return CollisionJNI.btDbvtBroadphase_newpairs_get(swigCPtr, this); } public void setFixedleft (int value) { CollisionJNI.btDbvtBroadphase_fixedleft_set(swigCPtr, this, value); } public int getFixedleft () { return CollisionJNI.btDbvtBroadphase_fixedleft_get(swigCPtr, this); } public void setUpdates_call (long value) { CollisionJNI.btDbvtBroadphase_updates_call_set(swigCPtr, this, value); } public long getUpdates_call () { return CollisionJNI.btDbvtBroadphase_updates_call_get(swigCPtr, this); } public void setUpdates_done (long value) { CollisionJNI.btDbvtBroadphase_updates_done_set(swigCPtr, this, value); } public long getUpdates_done () { return CollisionJNI.btDbvtBroadphase_updates_done_get(swigCPtr, this); } public void setUpdates_ratio (float value) { CollisionJNI.btDbvtBroadphase_updates_ratio_set(swigCPtr, this, value); } public float getUpdates_ratio () { return CollisionJNI.btDbvtBroadphase_updates_ratio_get(swigCPtr, this); } public void setPid (int value) { CollisionJNI.btDbvtBroadphase_pid_set(swigCPtr, this, value); } public int getPid () { return CollisionJNI.btDbvtBroadphase_pid_get(swigCPtr, this); } public void setCid (int value) { CollisionJNI.btDbvtBroadphase_cid_set(swigCPtr, this, value); } public int getCid () { return CollisionJNI.btDbvtBroadphase_cid_get(swigCPtr, this); } public void setGid (int value) { CollisionJNI.btDbvtBroadphase_gid_set(swigCPtr, this, value); } public int getGid () { return CollisionJNI.btDbvtBroadphase_gid_get(swigCPtr, this); } public void setReleasepaircache (boolean value) { CollisionJNI.btDbvtBroadphase_releasepaircache_set(swigCPtr, this, value); } public boolean getReleasepaircache () { return CollisionJNI.btDbvtBroadphase_releasepaircache_get(swigCPtr, this); } public void setDeferedcollide (boolean value) { CollisionJNI.btDbvtBroadphase_deferedcollide_set(swigCPtr, this, value); } public boolean getDeferedcollide () { return CollisionJNI.btDbvtBroadphase_deferedcollide_get(swigCPtr, this); } public void setNeedcleanup (boolean value) { CollisionJNI.btDbvtBroadphase_needcleanup_set(swigCPtr, this, value); } public boolean getNeedcleanup () { return CollisionJNI.btDbvtBroadphase_needcleanup_get(swigCPtr, this); } public void setRayTestStacks (SWIGTYPE_p_btAlignedObjectArrayT_btAlignedObjectArrayT_btDbvtNode_const_p_t_t value) { CollisionJNI.btDbvtBroadphase_rayTestStacks_set(swigCPtr, this, SWIGTYPE_p_btAlignedObjectArrayT_btAlignedObjectArrayT_btDbvtNode_const_p_t_t.getCPtr(value)); } public SWIGTYPE_p_btAlignedObjectArrayT_btAlignedObjectArrayT_btDbvtNode_const_p_t_t getRayTestStacks () { long cPtr = CollisionJNI.btDbvtBroadphase_rayTestStacks_get(swigCPtr, this); return (cPtr == 0) ? null : new SWIGTYPE_p_btAlignedObjectArrayT_btAlignedObjectArrayT_btDbvtNode_const_p_t_t(cPtr, false); } public btDbvtBroadphase (btOverlappingPairCache paircache) { this(CollisionJNI.new_btDbvtBroadphase__SWIG_0(btOverlappingPairCache.getCPtr(paircache), paircache), true); } public btDbvtBroadphase () { this(CollisionJNI.new_btDbvtBroadphase__SWIG_1(), true); } public void collide (btDispatcher dispatcher) { CollisionJNI.btDbvtBroadphase_collide(swigCPtr, this, btDispatcher.getCPtr(dispatcher), dispatcher); } public void optimize () { CollisionJNI.btDbvtBroadphase_optimize(swigCPtr, this); } public void rayTest (Vector3 rayFrom, Vector3 rayTo, btBroadphaseRayCallback rayCallback, Vector3 aabbMin, Vector3 aabbMax) { CollisionJNI.btDbvtBroadphase_rayTest__SWIG_0(swigCPtr, this, rayFrom, rayTo, btBroadphaseRayCallback.getCPtr(rayCallback), rayCallback, aabbMin, aabbMax); } public void rayTest (Vector3 rayFrom, Vector3 rayTo, btBroadphaseRayCallback rayCallback, Vector3 aabbMin) { CollisionJNI.btDbvtBroadphase_rayTest__SWIG_1(swigCPtr, this, rayFrom, rayTo, btBroadphaseRayCallback.getCPtr(rayCallback), rayCallback, aabbMin); } public void rayTest (Vector3 rayFrom, Vector3 rayTo, btBroadphaseRayCallback rayCallback) { CollisionJNI.btDbvtBroadphase_rayTest__SWIG_2(swigCPtr, this, rayFrom, rayTo, btBroadphaseRayCallback.getCPtr(rayCallback), rayCallback); } public void performDeferredRemoval (btDispatcher dispatcher) { CollisionJNI.btDbvtBroadphase_performDeferredRemoval(swigCPtr, this, btDispatcher.getCPtr(dispatcher), dispatcher); } public void setVelocityPrediction (float prediction) { CollisionJNI.btDbvtBroadphase_setVelocityPrediction(swigCPtr, this, prediction); } public float getVelocityPrediction () { return CollisionJNI.btDbvtBroadphase_getVelocityPrediction(swigCPtr, this); } public void setAabbForceUpdate (btBroadphaseProxy absproxy, Vector3 aabbMin, Vector3 aabbMax, btDispatcher arg3) { CollisionJNI.btDbvtBroadphase_setAabbForceUpdate(swigCPtr, this, btBroadphaseProxy.getCPtr(absproxy), absproxy, aabbMin, aabbMax, btDispatcher.getCPtr(arg3), arg3); } public static void benchmark (btBroadphaseInterface arg0) { CollisionJNI.btDbvtBroadphase_benchmark(btBroadphaseInterface.getCPtr(arg0), arg0); } public btDbvt getSet (int index) { long cPtr = CollisionJNI.btDbvtBroadphase_getSet(swigCPtr, this, index); return (cPtr == 0) ? null : new btDbvt(cPtr, false); } public btDbvt getSet0 () { long cPtr = CollisionJNI.btDbvtBroadphase_getSet0(swigCPtr, this); return (cPtr == 0) ? null : new btDbvt(cPtr, false); } public btDbvt getSet1 () { long cPtr = CollisionJNI.btDbvtBroadphase_getSet1(swigCPtr, this); return (cPtr == 0) ? null : new btDbvt(cPtr, false); } public final static int DYNAMIC_SET = 0; public final static int FIXED_SET = 1; public final static int STAGECOUNT = 2; }
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.collision; import com.badlogic.gdx.physics.bullet.linearmath.*; import com.badlogic.gdx.math.Vector3; public class btDbvtBroadphase extends btBroadphaseInterface { private long swigCPtr; protected btDbvtBroadphase (final String className, long cPtr, boolean cMemoryOwn) { super(className, CollisionJNI.btDbvtBroadphase_SWIGUpcast(cPtr), cMemoryOwn); swigCPtr = cPtr; } /** Construct a new btDbvtBroadphase, normally you should not need this constructor it's intended for low-level usage. */ public btDbvtBroadphase (long cPtr, boolean cMemoryOwn) { this("btDbvtBroadphase", cPtr, cMemoryOwn); construct(); } @Override protected void reset (long cPtr, boolean cMemoryOwn) { if (!destroyed) destroy(); super.reset(CollisionJNI.btDbvtBroadphase_SWIGUpcast(swigCPtr = cPtr), cMemoryOwn); } public static long getCPtr (btDbvtBroadphase obj) { return (obj == null) ? 0 : obj.swigCPtr; } @Override protected void finalize () throws Throwable { if (!destroyed) destroy(); super.finalize(); } @Override protected synchronized void delete () { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; CollisionJNI.delete_btDbvtBroadphase(swigCPtr); } swigCPtr = 0; } super.delete(); } public void setSets (btDbvt value) { CollisionJNI.btDbvtBroadphase_sets_set(swigCPtr, this, btDbvt.getCPtr(value), value); } public btDbvt getSets () { long cPtr = CollisionJNI.btDbvtBroadphase_sets_get(swigCPtr, this); return (cPtr == 0) ? null : new btDbvt(cPtr, false); } public void setStageRoots (SWIGTYPE_p_p_btDbvtProxy value) { CollisionJNI.btDbvtBroadphase_stageRoots_set(swigCPtr, this, SWIGTYPE_p_p_btDbvtProxy.getCPtr(value)); } public SWIGTYPE_p_p_btDbvtProxy getStageRoots () { long cPtr = CollisionJNI.btDbvtBroadphase_stageRoots_get(swigCPtr, this); return (cPtr == 0) ? null : new SWIGTYPE_p_p_btDbvtProxy(cPtr, false); } public void setPaircache (btOverlappingPairCache value) { CollisionJNI.btDbvtBroadphase_paircache_set(swigCPtr, this, btOverlappingPairCache.getCPtr(value), value); } public btOverlappingPairCache getPaircache () { long cPtr = CollisionJNI.btDbvtBroadphase_paircache_get(swigCPtr, this); return (cPtr == 0) ? null : new btOverlappingPairCache(cPtr, false); } public void setPrediction (float value) { CollisionJNI.btDbvtBroadphase_prediction_set(swigCPtr, this, value); } public float getPrediction () { return CollisionJNI.btDbvtBroadphase_prediction_get(swigCPtr, this); } public void setStageCurrent (int value) { CollisionJNI.btDbvtBroadphase_stageCurrent_set(swigCPtr, this, value); } public int getStageCurrent () { return CollisionJNI.btDbvtBroadphase_stageCurrent_get(swigCPtr, this); } public void setFupdates (int value) { CollisionJNI.btDbvtBroadphase_fupdates_set(swigCPtr, this, value); } public int getFupdates () { return CollisionJNI.btDbvtBroadphase_fupdates_get(swigCPtr, this); } public void setDupdates (int value) { CollisionJNI.btDbvtBroadphase_dupdates_set(swigCPtr, this, value); } public int getDupdates () { return CollisionJNI.btDbvtBroadphase_dupdates_get(swigCPtr, this); } public void setCupdates (int value) { CollisionJNI.btDbvtBroadphase_cupdates_set(swigCPtr, this, value); } public int getCupdates () { return CollisionJNI.btDbvtBroadphase_cupdates_get(swigCPtr, this); } public void setNewpairs (int value) { CollisionJNI.btDbvtBroadphase_newpairs_set(swigCPtr, this, value); } public int getNewpairs () { return CollisionJNI.btDbvtBroadphase_newpairs_get(swigCPtr, this); } public void setFixedleft (int value) { CollisionJNI.btDbvtBroadphase_fixedleft_set(swigCPtr, this, value); } public int getFixedleft () { return CollisionJNI.btDbvtBroadphase_fixedleft_get(swigCPtr, this); } public void setUpdates_call (long value) { CollisionJNI.btDbvtBroadphase_updates_call_set(swigCPtr, this, value); } public long getUpdates_call () { return CollisionJNI.btDbvtBroadphase_updates_call_get(swigCPtr, this); } public void setUpdates_done (long value) { CollisionJNI.btDbvtBroadphase_updates_done_set(swigCPtr, this, value); } public long getUpdates_done () { return CollisionJNI.btDbvtBroadphase_updates_done_get(swigCPtr, this); } public void setUpdates_ratio (float value) { CollisionJNI.btDbvtBroadphase_updates_ratio_set(swigCPtr, this, value); } public float getUpdates_ratio () { return CollisionJNI.btDbvtBroadphase_updates_ratio_get(swigCPtr, this); } public void setPid (int value) { CollisionJNI.btDbvtBroadphase_pid_set(swigCPtr, this, value); } public int getPid () { return CollisionJNI.btDbvtBroadphase_pid_get(swigCPtr, this); } public void setCid (int value) { CollisionJNI.btDbvtBroadphase_cid_set(swigCPtr, this, value); } public int getCid () { return CollisionJNI.btDbvtBroadphase_cid_get(swigCPtr, this); } public void setGid (int value) { CollisionJNI.btDbvtBroadphase_gid_set(swigCPtr, this, value); } public int getGid () { return CollisionJNI.btDbvtBroadphase_gid_get(swigCPtr, this); } public void setReleasepaircache (boolean value) { CollisionJNI.btDbvtBroadphase_releasepaircache_set(swigCPtr, this, value); } public boolean getReleasepaircache () { return CollisionJNI.btDbvtBroadphase_releasepaircache_get(swigCPtr, this); } public void setDeferedcollide (boolean value) { CollisionJNI.btDbvtBroadphase_deferedcollide_set(swigCPtr, this, value); } public boolean getDeferedcollide () { return CollisionJNI.btDbvtBroadphase_deferedcollide_get(swigCPtr, this); } public void setNeedcleanup (boolean value) { CollisionJNI.btDbvtBroadphase_needcleanup_set(swigCPtr, this, value); } public boolean getNeedcleanup () { return CollisionJNI.btDbvtBroadphase_needcleanup_get(swigCPtr, this); } public void setRayTestStacks (SWIGTYPE_p_btAlignedObjectArrayT_btAlignedObjectArrayT_btDbvtNode_const_p_t_t value) { CollisionJNI.btDbvtBroadphase_rayTestStacks_set(swigCPtr, this, SWIGTYPE_p_btAlignedObjectArrayT_btAlignedObjectArrayT_btDbvtNode_const_p_t_t.getCPtr(value)); } public SWIGTYPE_p_btAlignedObjectArrayT_btAlignedObjectArrayT_btDbvtNode_const_p_t_t getRayTestStacks () { long cPtr = CollisionJNI.btDbvtBroadphase_rayTestStacks_get(swigCPtr, this); return (cPtr == 0) ? null : new SWIGTYPE_p_btAlignedObjectArrayT_btAlignedObjectArrayT_btDbvtNode_const_p_t_t(cPtr, false); } public btDbvtBroadphase (btOverlappingPairCache paircache) { this(CollisionJNI.new_btDbvtBroadphase__SWIG_0(btOverlappingPairCache.getCPtr(paircache), paircache), true); } public btDbvtBroadphase () { this(CollisionJNI.new_btDbvtBroadphase__SWIG_1(), true); } public void collide (btDispatcher dispatcher) { CollisionJNI.btDbvtBroadphase_collide(swigCPtr, this, btDispatcher.getCPtr(dispatcher), dispatcher); } public void optimize () { CollisionJNI.btDbvtBroadphase_optimize(swigCPtr, this); } public void rayTest (Vector3 rayFrom, Vector3 rayTo, btBroadphaseRayCallback rayCallback, Vector3 aabbMin, Vector3 aabbMax) { CollisionJNI.btDbvtBroadphase_rayTest__SWIG_0(swigCPtr, this, rayFrom, rayTo, btBroadphaseRayCallback.getCPtr(rayCallback), rayCallback, aabbMin, aabbMax); } public void rayTest (Vector3 rayFrom, Vector3 rayTo, btBroadphaseRayCallback rayCallback, Vector3 aabbMin) { CollisionJNI.btDbvtBroadphase_rayTest__SWIG_1(swigCPtr, this, rayFrom, rayTo, btBroadphaseRayCallback.getCPtr(rayCallback), rayCallback, aabbMin); } public void rayTest (Vector3 rayFrom, Vector3 rayTo, btBroadphaseRayCallback rayCallback) { CollisionJNI.btDbvtBroadphase_rayTest__SWIG_2(swigCPtr, this, rayFrom, rayTo, btBroadphaseRayCallback.getCPtr(rayCallback), rayCallback); } public void performDeferredRemoval (btDispatcher dispatcher) { CollisionJNI.btDbvtBroadphase_performDeferredRemoval(swigCPtr, this, btDispatcher.getCPtr(dispatcher), dispatcher); } public void setVelocityPrediction (float prediction) { CollisionJNI.btDbvtBroadphase_setVelocityPrediction(swigCPtr, this, prediction); } public float getVelocityPrediction () { return CollisionJNI.btDbvtBroadphase_getVelocityPrediction(swigCPtr, this); } public void setAabbForceUpdate (btBroadphaseProxy absproxy, Vector3 aabbMin, Vector3 aabbMax, btDispatcher arg3) { CollisionJNI.btDbvtBroadphase_setAabbForceUpdate(swigCPtr, this, btBroadphaseProxy.getCPtr(absproxy), absproxy, aabbMin, aabbMax, btDispatcher.getCPtr(arg3), arg3); } public static void benchmark (btBroadphaseInterface arg0) { CollisionJNI.btDbvtBroadphase_benchmark(btBroadphaseInterface.getCPtr(arg0), arg0); } public btDbvt getSet (int index) { long cPtr = CollisionJNI.btDbvtBroadphase_getSet(swigCPtr, this, index); return (cPtr == 0) ? null : new btDbvt(cPtr, false); } public btDbvt getSet0 () { long cPtr = CollisionJNI.btDbvtBroadphase_getSet0(swigCPtr, this); return (cPtr == 0) ? null : new btDbvt(cPtr, false); } public btDbvt getSet1 () { long cPtr = CollisionJNI.btDbvtBroadphase_getSet1(swigCPtr, this); return (cPtr == 0) ? null : new btDbvt(cPtr, false); } public final static int DYNAMIC_SET = 0; public final static int FIXED_SET = 1; public final static int STAGECOUNT = 2; }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./gdx/src/com/badlogic/gdx/math/CatmullRomSpline.java
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.math; /** @author Xoppa */ public class CatmullRomSpline<T extends Vector<T>> implements Path<T> { /** Calculates the catmullrom value for the given position (t). * @param out The Vector to set to the result. * @param t The position (0<=t<=1) on the spline * @param points The control points * @param continuous If true the b-spline restarts at 0 when reaching 1 * @param tmp A temporary vector used for the calculation * @return The value of out */ public static <T extends Vector<T>> T calculate (final T out, final float t, final T[] points, final boolean continuous, final T tmp) { final int n = continuous ? points.length : points.length - 3; float u = t * n; int i = (t >= 1f) ? (n - 1) : (int)u; u -= i; return calculate(out, i, u, points, continuous, tmp); } /** Calculates the catmullrom value for the given span (i) at the given position (u). * @param out The Vector to set to the result. * @param i The span (0<=i<spanCount) spanCount = continuous ? points.length : points.length - degree * @param u The position (0<=u<=1) on the span * @param points The control points * @param continuous If true the b-spline restarts at 0 when reaching 1 * @param tmp A temporary vector used for the calculation * @return The value of out */ public static <T extends Vector<T>> T calculate (final T out, final int i, final float u, final T[] points, final boolean continuous, final T tmp) { final int n = points.length; final float u2 = u * u; final float u3 = u2 * u; out.set(points[i]).scl(1.5f * u3 - 2.5f * u2 + 1.0f); if (continuous || i > 0) out.add(tmp.set(points[(n + i - 1) % n]).scl(-0.5f * u3 + u2 - 0.5f * u)); if (continuous || i < (n - 1)) out.add(tmp.set(points[(i + 1) % n]).scl(-1.5f * u3 + 2f * u2 + 0.5f * u)); if (continuous || i < (n - 2)) out.add(tmp.set(points[(i + 2) % n]).scl(0.5f * u3 - 0.5f * u2)); return out; } /** Calculates the derivative of the catmullrom spline for the given position (t). * @param out The Vector to set to the result. * @param t The position (0<=t<=1) on the spline * @param points The control points * @param continuous If true the b-spline restarts at 0 when reaching 1 * @param tmp A temporary vector used for the calculation * @return The value of out */ public static <T extends Vector<T>> T derivative (final T out, final float t, final T[] points, final boolean continuous, final T tmp) { final int n = continuous ? points.length : points.length - 3; float u = t * n; int i = (t >= 1f) ? (n - 1) : (int)u; u -= i; return derivative(out, i, u, points, continuous, tmp); } /** Calculates the derivative of the catmullrom spline for the given span (i) at the given position (u). * @param out The Vector to set to the result. * @param i The span (0<=i<spanCount) spanCount = continuous ? points.length : points.length - degree * @param u The position (0<=u<=1) on the span * @param points The control points * @param continuous If true the b-spline restarts at 0 when reaching 1 * @param tmp A temporary vector used for the calculation * @return The value of out */ public static <T extends Vector<T>> T derivative (final T out, final int i, final float u, final T[] points, final boolean continuous, final T tmp) { /* * catmull'(u) = 0.5 *((-p0 + p2) + 2 * (2*p0 - 5*p1 + 4*p2 - p3) * u + 3 * (-p0 + 3*p1 - 3*p2 + p3) * u * u) */ final int n = points.length; final float u2 = u * u; // final float u3 = u2 * u; out.set(points[i]).scl(-u * 5 + u2 * 4.5f); if (continuous || i > 0) out.add(tmp.set(points[(n + i - 1) % n]).scl(-0.5f + u * 2 - u2 * 1.5f)); if (continuous || i < (n - 1)) out.add(tmp.set(points[(i + 1) % n]).scl(0.5f + u * 4 - u2 * 4.5f)); if (continuous || i < (n - 2)) out.add(tmp.set(points[(i + 2) % n]).scl(-u + u2 * 1.5f)); return out; } public T[] controlPoints; public boolean continuous; public int spanCount; private T tmp; private T tmp2; private T tmp3; public CatmullRomSpline () { } public CatmullRomSpline (final T[] controlPoints, final boolean continuous) { set(controlPoints, continuous); } public CatmullRomSpline set (final T[] controlPoints, final boolean continuous) { if (tmp == null) tmp = controlPoints[0].cpy(); if (tmp2 == null) tmp2 = controlPoints[0].cpy(); if (tmp3 == null) tmp3 = controlPoints[0].cpy(); this.controlPoints = controlPoints; this.continuous = continuous; this.spanCount = continuous ? controlPoints.length : controlPoints.length - 3; return this; } @Override public T valueAt (T out, float t) { final int n = spanCount; float u = t * n; int i = (t >= 1f) ? (n - 1) : (int)u; u -= i; return valueAt(out, i, u); } /** @return The value of the spline at position u of the specified span */ public T valueAt (final T out, final int span, final float u) { return calculate(out, continuous ? span : (span + 1), u, controlPoints, continuous, tmp); } @Override public T derivativeAt (T out, float t) { final int n = spanCount; float u = t * n; int i = (t >= 1f) ? (n - 1) : (int)u; u -= i; return derivativeAt(out, i, u); } /** @return The derivative of the spline at position u of the specified span */ public T derivativeAt (final T out, final int span, final float u) { return derivative(out, continuous ? span : (span + 1), u, controlPoints, continuous, tmp); } /** @return The span closest to the specified value */ public int nearest (final T in) { return nearest(in, 0, spanCount); } /** @return The span closest to the specified value, restricting to the specified spans. */ public int nearest (final T in, int start, final int count) { while (start < 0) start += spanCount; int result = start % spanCount; float dst = in.dst2(controlPoints[result]); for (int i = 1; i < count; i++) { final int idx = (start + i) % spanCount; final float d = in.dst2(controlPoints[idx]); if (d < dst) { dst = d; result = idx; } } return result; } @Override public float approximate (T v) { return approximate(v, nearest(v)); } public float approximate (final T in, int start, final int count) { return approximate(in, nearest(in, start, count)); } public float approximate (final T in, final int near) { int n = near; final T nearest = controlPoints[n]; final T previous = controlPoints[n > 0 ? n - 1 : spanCount - 1]; final T next = controlPoints[(n + 1) % spanCount]; final float dstPrev2 = in.dst2(previous); final float dstNext2 = in.dst2(next); T P1, P2, P3; if (dstNext2 < dstPrev2) { P1 = nearest; P2 = next; P3 = in; } else { P1 = previous; P2 = nearest; P3 = in; n = n > 0 ? n - 1 : spanCount - 1; } float L1Sqr = P1.dst2(P2); float L2Sqr = P3.dst2(P2); float L3Sqr = P3.dst2(P1); float L1 = (float)Math.sqrt(L1Sqr); float s = (L2Sqr + L1Sqr - L3Sqr) / (2f * L1); float u = MathUtils.clamp((L1 - s) / L1, 0f, 1f); return (n + u) / spanCount; } @Override public float locate (T v) { return approximate(v); } @Override public float approxLength (int samples) { float tempLength = 0; for (int i = 0; i < samples; ++i) { tmp2.set(tmp3); valueAt(tmp3, (i) / ((float)samples - 1)); if (i > 0) tempLength += tmp2.dst(tmp3); } return tempLength; } }
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.math; /** @author Xoppa */ public class CatmullRomSpline<T extends Vector<T>> implements Path<T> { /** Calculates the catmullrom value for the given position (t). * @param out The Vector to set to the result. * @param t The position (0<=t<=1) on the spline * @param points The control points * @param continuous If true the b-spline restarts at 0 when reaching 1 * @param tmp A temporary vector used for the calculation * @return The value of out */ public static <T extends Vector<T>> T calculate (final T out, final float t, final T[] points, final boolean continuous, final T tmp) { final int n = continuous ? points.length : points.length - 3; float u = t * n; int i = (t >= 1f) ? (n - 1) : (int)u; u -= i; return calculate(out, i, u, points, continuous, tmp); } /** Calculates the catmullrom value for the given span (i) at the given position (u). * @param out The Vector to set to the result. * @param i The span (0<=i<spanCount) spanCount = continuous ? points.length : points.length - degree * @param u The position (0<=u<=1) on the span * @param points The control points * @param continuous If true the b-spline restarts at 0 when reaching 1 * @param tmp A temporary vector used for the calculation * @return The value of out */ public static <T extends Vector<T>> T calculate (final T out, final int i, final float u, final T[] points, final boolean continuous, final T tmp) { final int n = points.length; final float u2 = u * u; final float u3 = u2 * u; out.set(points[i]).scl(1.5f * u3 - 2.5f * u2 + 1.0f); if (continuous || i > 0) out.add(tmp.set(points[(n + i - 1) % n]).scl(-0.5f * u3 + u2 - 0.5f * u)); if (continuous || i < (n - 1)) out.add(tmp.set(points[(i + 1) % n]).scl(-1.5f * u3 + 2f * u2 + 0.5f * u)); if (continuous || i < (n - 2)) out.add(tmp.set(points[(i + 2) % n]).scl(0.5f * u3 - 0.5f * u2)); return out; } /** Calculates the derivative of the catmullrom spline for the given position (t). * @param out The Vector to set to the result. * @param t The position (0<=t<=1) on the spline * @param points The control points * @param continuous If true the b-spline restarts at 0 when reaching 1 * @param tmp A temporary vector used for the calculation * @return The value of out */ public static <T extends Vector<T>> T derivative (final T out, final float t, final T[] points, final boolean continuous, final T tmp) { final int n = continuous ? points.length : points.length - 3; float u = t * n; int i = (t >= 1f) ? (n - 1) : (int)u; u -= i; return derivative(out, i, u, points, continuous, tmp); } /** Calculates the derivative of the catmullrom spline for the given span (i) at the given position (u). * @param out The Vector to set to the result. * @param i The span (0<=i<spanCount) spanCount = continuous ? points.length : points.length - degree * @param u The position (0<=u<=1) on the span * @param points The control points * @param continuous If true the b-spline restarts at 0 when reaching 1 * @param tmp A temporary vector used for the calculation * @return The value of out */ public static <T extends Vector<T>> T derivative (final T out, final int i, final float u, final T[] points, final boolean continuous, final T tmp) { /* * catmull'(u) = 0.5 *((-p0 + p2) + 2 * (2*p0 - 5*p1 + 4*p2 - p3) * u + 3 * (-p0 + 3*p1 - 3*p2 + p3) * u * u) */ final int n = points.length; final float u2 = u * u; // final float u3 = u2 * u; out.set(points[i]).scl(-u * 5 + u2 * 4.5f); if (continuous || i > 0) out.add(tmp.set(points[(n + i - 1) % n]).scl(-0.5f + u * 2 - u2 * 1.5f)); if (continuous || i < (n - 1)) out.add(tmp.set(points[(i + 1) % n]).scl(0.5f + u * 4 - u2 * 4.5f)); if (continuous || i < (n - 2)) out.add(tmp.set(points[(i + 2) % n]).scl(-u + u2 * 1.5f)); return out; } public T[] controlPoints; public boolean continuous; public int spanCount; private T tmp; private T tmp2; private T tmp3; public CatmullRomSpline () { } public CatmullRomSpline (final T[] controlPoints, final boolean continuous) { set(controlPoints, continuous); } public CatmullRomSpline set (final T[] controlPoints, final boolean continuous) { if (tmp == null) tmp = controlPoints[0].cpy(); if (tmp2 == null) tmp2 = controlPoints[0].cpy(); if (tmp3 == null) tmp3 = controlPoints[0].cpy(); this.controlPoints = controlPoints; this.continuous = continuous; this.spanCount = continuous ? controlPoints.length : controlPoints.length - 3; return this; } @Override public T valueAt (T out, float t) { final int n = spanCount; float u = t * n; int i = (t >= 1f) ? (n - 1) : (int)u; u -= i; return valueAt(out, i, u); } /** @return The value of the spline at position u of the specified span */ public T valueAt (final T out, final int span, final float u) { return calculate(out, continuous ? span : (span + 1), u, controlPoints, continuous, tmp); } @Override public T derivativeAt (T out, float t) { final int n = spanCount; float u = t * n; int i = (t >= 1f) ? (n - 1) : (int)u; u -= i; return derivativeAt(out, i, u); } /** @return The derivative of the spline at position u of the specified span */ public T derivativeAt (final T out, final int span, final float u) { return derivative(out, continuous ? span : (span + 1), u, controlPoints, continuous, tmp); } /** @return The span closest to the specified value */ public int nearest (final T in) { return nearest(in, 0, spanCount); } /** @return The span closest to the specified value, restricting to the specified spans. */ public int nearest (final T in, int start, final int count) { while (start < 0) start += spanCount; int result = start % spanCount; float dst = in.dst2(controlPoints[result]); for (int i = 1; i < count; i++) { final int idx = (start + i) % spanCount; final float d = in.dst2(controlPoints[idx]); if (d < dst) { dst = d; result = idx; } } return result; } @Override public float approximate (T v) { return approximate(v, nearest(v)); } public float approximate (final T in, int start, final int count) { return approximate(in, nearest(in, start, count)); } public float approximate (final T in, final int near) { int n = near; final T nearest = controlPoints[n]; final T previous = controlPoints[n > 0 ? n - 1 : spanCount - 1]; final T next = controlPoints[(n + 1) % spanCount]; final float dstPrev2 = in.dst2(previous); final float dstNext2 = in.dst2(next); T P1, P2, P3; if (dstNext2 < dstPrev2) { P1 = nearest; P2 = next; P3 = in; } else { P1 = previous; P2 = nearest; P3 = in; n = n > 0 ? n - 1 : spanCount - 1; } float L1Sqr = P1.dst2(P2); float L2Sqr = P3.dst2(P2); float L3Sqr = P3.dst2(P1); float L1 = (float)Math.sqrt(L1Sqr); float s = (L2Sqr + L1Sqr - L3Sqr) / (2f * L1); float u = MathUtils.clamp((L1 - s) / L1, 0f, 1f); return (n + u) / spanCount; } @Override public float locate (T v) { return approximate(v); } @Override public float approxLength (int samples) { float tempLength = 0; for (int i = 0; i < samples; ++i) { tmp2.set(tmp3); valueAt(tmp3, (i) / ((float)samples - 1)); if (i > 0) tempLength += tmp2.dst(tmp3); } return tempLength; } }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./tests/gdx-tests/src/com/badlogic/gdx/tests/net/PingPongSocketExample.java
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.tests.net; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Net.Protocol; import com.badlogic.gdx.net.ServerSocket; import com.badlogic.gdx.net.ServerSocketHints; import com.badlogic.gdx.net.Socket; import com.badlogic.gdx.net.SocketHints; import com.badlogic.gdx.tests.utils.GdxTest; /** Demonstrates how to do very simple socket programming. Implements a classic PING-PONG sequence, client connects to server, * sends message, server sends message back to client. Both client and server run locally. We quit as soon as the client received * the PONG message from the server. This example won't work in HTML. Messages are delimited by the new line character, so we can * use a {@link BufferedReader}. * @author badlogic */ public class PingPongSocketExample extends GdxTest { @Override public void create () { // setup a server thread where we wait for incoming connections // to the server new Thread(new Runnable() { @Override public void run () { ServerSocketHints hints = new ServerSocketHints(); ServerSocket server = Gdx.net.newServerSocket(Protocol.TCP, "localhost", 9999, hints); // wait for the next client connection Socket client = server.accept(null); // read message and send it back try { String message = new BufferedReader(new InputStreamReader(client.getInputStream())).readLine(); Gdx.app.log("PingPongSocketExample", "got client message: " + message); client.getOutputStream().write("PONG\n".getBytes()); } catch (IOException e) { Gdx.app.log("PingPongSocketExample", "an error occured", e); } } }).start(); // create the client send a message, then wait for the // server to reply SocketHints hints = new SocketHints(); Socket client = Gdx.net.newClientSocket(Protocol.TCP, "localhost", 9999, hints); try { client.getOutputStream().write("PING\n".getBytes()); String response = new BufferedReader(new InputStreamReader(client.getInputStream())).readLine(); Gdx.app.log("PingPongSocketExample", "got server message: " + response); } catch (IOException e) { Gdx.app.log("PingPongSocketExample", "an error occured", e); } } }
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.tests.net; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Net.Protocol; import com.badlogic.gdx.net.ServerSocket; import com.badlogic.gdx.net.ServerSocketHints; import com.badlogic.gdx.net.Socket; import com.badlogic.gdx.net.SocketHints; import com.badlogic.gdx.tests.utils.GdxTest; /** Demonstrates how to do very simple socket programming. Implements a classic PING-PONG sequence, client connects to server, * sends message, server sends message back to client. Both client and server run locally. We quit as soon as the client received * the PONG message from the server. This example won't work in HTML. Messages are delimited by the new line character, so we can * use a {@link BufferedReader}. * @author badlogic */ public class PingPongSocketExample extends GdxTest { @Override public void create () { // setup a server thread where we wait for incoming connections // to the server new Thread(new Runnable() { @Override public void run () { ServerSocketHints hints = new ServerSocketHints(); ServerSocket server = Gdx.net.newServerSocket(Protocol.TCP, "localhost", 9999, hints); // wait for the next client connection Socket client = server.accept(null); // read message and send it back try { String message = new BufferedReader(new InputStreamReader(client.getInputStream())).readLine(); Gdx.app.log("PingPongSocketExample", "got client message: " + message); client.getOutputStream().write("PONG\n".getBytes()); } catch (IOException e) { Gdx.app.log("PingPongSocketExample", "an error occured", e); } } }).start(); // create the client send a message, then wait for the // server to reply SocketHints hints = new SocketHints(); Socket client = Gdx.net.newClientSocket(Protocol.TCP, "localhost", 9999, hints); try { client.getOutputStream().write("PING\n".getBytes()); String response = new BufferedReader(new InputStreamReader(client.getInputStream())).readLine(); Gdx.app.log("PingPongSocketExample", "got server message: " + response); } catch (IOException e) { Gdx.app.log("PingPongSocketExample", "an error occured", e); } } }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./backends/gdx-backends-gwt/src/com/badlogic/gdx/backends/gwt/emu/java/lang/Readable.java
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package java.lang; import java.io.IOException; import java.nio.CharBuffer; public interface Readable { int read (CharBuffer cb) throws IOException; }
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package java.lang; import java.io.IOException; import java.nio.CharBuffer; public interface Readable { int read (CharBuffer cb) throws IOException; }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./extensions/gdx-bullet/jni/swig-src/inversedynamics/com/badlogic/gdx/physics/bullet/inversedynamics/SWIGTYPE_p_mat33.java
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.inversedynamics; public class SWIGTYPE_p_mat33 { private transient long swigCPtr; protected SWIGTYPE_p_mat33 (long cPtr, @SuppressWarnings("unused") boolean futureUse) { swigCPtr = cPtr; } protected SWIGTYPE_p_mat33 () { swigCPtr = 0; } protected static long getCPtr (SWIGTYPE_p_mat33 obj) { return (obj == null) ? 0 : obj.swigCPtr; } }
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.inversedynamics; public class SWIGTYPE_p_mat33 { private transient long swigCPtr; protected SWIGTYPE_p_mat33 (long cPtr, @SuppressWarnings("unused") boolean futureUse) { swigCPtr = cPtr; } protected SWIGTYPE_p_mat33 () { swigCPtr = 0; } protected static long getCPtr (SWIGTYPE_p_mat33 obj) { return (obj == null) ? 0 : obj.swigCPtr; } }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./gdx/src/com/badlogic/gdx/graphics/glutils/FrameBufferCubemap.java
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.graphics.glutils; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Cubemap; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.Pixmap; import com.badlogic.gdx.graphics.Texture.TextureFilter; import com.badlogic.gdx.graphics.Texture.TextureWrap; import com.badlogic.gdx.utils.GdxRuntimeException; /** * <p> * Encapsulates OpenGL ES 2.0 frame buffer objects. This is a simple helper class which should cover most FBO uses. It will * automatically create a cubemap for the color attachment and a renderbuffer for the depth buffer. You can get a hold of the * cubemap by {@link FrameBufferCubemap#getColorBufferTexture()}. This class will only work with OpenGL ES 2.0. * </p> * * <p> * FrameBuffers are managed. In case of an OpenGL context loss, which only happens on Android when a user switches to another * application or receives an incoming call, the framebuffer will be automatically recreated. * </p> * * <p> * A FrameBuffer must be disposed if it is no longer needed * </p> * * <p> * Typical use: <br /> * FrameBufferCubemap frameBuffer = new FrameBufferCubemap(Format.RGBA8888, fSize, fSize, true); <br /> * frameBuffer.begin(); <br /> * while( frameBuffer.nextSide() ) { <br /> * frameBuffer.getSide().getUp(camera.up); <br /> * frameBuffer.getSide().getDirection(camera.direction);<br /> * camera.update(); <br /> * * Gdx.gl.glClearColor(0, 0, 0, 1); <br /> * Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); <br /> * modelBatch.begin(camera); <br /> * modelBatch.render(renderableProviders); <br /> * modelBatch.end(); <br /> * } <br /> * frameBuffer.end(); <br /> * Cubemap cubemap = frameBuffer.getColorBufferCubemap(); * </p> * * @author realitix */ public class FrameBufferCubemap extends GLFrameBuffer<Cubemap> { /** the zero-based index of the active side **/ private int currentSide; /** cubemap sides cache */ private static final Cubemap.CubemapSide[] cubemapSides = Cubemap.CubemapSide.values(); FrameBufferCubemap () { } /** Creates a GLFrameBuffer from the specifications provided by bufferBuilder * * @param bufferBuilder **/ protected FrameBufferCubemap (GLFrameBufferBuilder<? extends GLFrameBuffer<Cubemap>> bufferBuilder) { super(bufferBuilder); } /** Creates a new FrameBuffer having the given dimensions and potentially a depth buffer attached. * * @param format * @param width * @param height * @param hasDepth */ public FrameBufferCubemap (Pixmap.Format format, int width, int height, boolean hasDepth) { this(format, width, height, hasDepth, false); } /** Creates a new FrameBuffer having the given dimensions and potentially a depth and a stencil buffer attached. * * @param format the format of the color buffer; according to the OpenGL ES 2.0 spec, only RGB565, RGBA4444 and RGB5_A1 are * color-renderable * @param width the width of the cubemap in pixels * @param height the height of the cubemap in pixels * @param hasDepth whether to attach a depth buffer * @param hasStencil whether to attach a stencil buffer * @throws com.badlogic.gdx.utils.GdxRuntimeException in case the FrameBuffer could not be created */ public FrameBufferCubemap (Pixmap.Format format, int width, int height, boolean hasDepth, boolean hasStencil) { FrameBufferCubemapBuilder frameBufferBuilder = new FrameBufferCubemapBuilder(width, height); frameBufferBuilder.addBasicColorTextureAttachment(format); if (hasDepth) frameBufferBuilder.addBasicDepthRenderBuffer(); if (hasStencil) frameBufferBuilder.addBasicStencilRenderBuffer(); this.bufferBuilder = frameBufferBuilder; build(); } @Override protected Cubemap createTexture (FrameBufferTextureAttachmentSpec attachmentSpec) { GLOnlyTextureData data = new GLOnlyTextureData(bufferBuilder.width, bufferBuilder.height, 0, attachmentSpec.internalFormat, attachmentSpec.format, attachmentSpec.type); Cubemap result = new Cubemap(data, data, data, data, data, data); result.setFilter(TextureFilter.Linear, TextureFilter.Linear); result.setWrap(TextureWrap.ClampToEdge, TextureWrap.ClampToEdge); return result; } @Override protected void disposeColorTexture (Cubemap colorTexture) { colorTexture.dispose(); } @Override protected void attachFrameBufferColorTexture (Cubemap texture) { GL20 gl = Gdx.gl20; int glHandle = texture.getTextureObjectHandle(); Cubemap.CubemapSide[] sides = Cubemap.CubemapSide.values(); for (Cubemap.CubemapSide side : sides) { gl.glFramebufferTexture2D(GL20.GL_FRAMEBUFFER, GL20.GL_COLOR_ATTACHMENT0, side.glEnum, glHandle, 0); } } /** Makes the frame buffer current so everything gets drawn to it, must be followed by call to either {@link #nextSide()} or * {@link #bindSide(com.badlogic.gdx.graphics.Cubemap.CubemapSide)} to activate the side to render onto. */ @Override public void bind () { currentSide = -1; super.bind(); } /** Bind the next side of cubemap and return false if no more side. Should be called in between a call to {@link #begin()} and * #end to cycle to each side of the cubemap to render on. */ public boolean nextSide () { if (currentSide > 5) { throw new GdxRuntimeException("No remaining sides."); } else if (currentSide == 5) { return false; } currentSide++; bindSide(getSide()); return true; } /** Bind the side, making it active to render on. Should be called in between a call to {@link #begin()} and {@link #end()}. * @param side The side to bind */ protected void bindSide (final Cubemap.CubemapSide side) { Gdx.gl20.glFramebufferTexture2D(GL20.GL_FRAMEBUFFER, GL20.GL_COLOR_ATTACHMENT0, side.glEnum, getColorBufferTexture().getTextureObjectHandle(), 0); } /** Get the currently bound side. */ public Cubemap.CubemapSide getSide () { return currentSide < 0 ? null : cubemapSides[currentSide]; } }
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.graphics.glutils; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Cubemap; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.Pixmap; import com.badlogic.gdx.graphics.Texture.TextureFilter; import com.badlogic.gdx.graphics.Texture.TextureWrap; import com.badlogic.gdx.utils.GdxRuntimeException; /** * <p> * Encapsulates OpenGL ES 2.0 frame buffer objects. This is a simple helper class which should cover most FBO uses. It will * automatically create a cubemap for the color attachment and a renderbuffer for the depth buffer. You can get a hold of the * cubemap by {@link FrameBufferCubemap#getColorBufferTexture()}. This class will only work with OpenGL ES 2.0. * </p> * * <p> * FrameBuffers are managed. In case of an OpenGL context loss, which only happens on Android when a user switches to another * application or receives an incoming call, the framebuffer will be automatically recreated. * </p> * * <p> * A FrameBuffer must be disposed if it is no longer needed * </p> * * <p> * Typical use: <br /> * FrameBufferCubemap frameBuffer = new FrameBufferCubemap(Format.RGBA8888, fSize, fSize, true); <br /> * frameBuffer.begin(); <br /> * while( frameBuffer.nextSide() ) { <br /> * frameBuffer.getSide().getUp(camera.up); <br /> * frameBuffer.getSide().getDirection(camera.direction);<br /> * camera.update(); <br /> * * Gdx.gl.glClearColor(0, 0, 0, 1); <br /> * Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); <br /> * modelBatch.begin(camera); <br /> * modelBatch.render(renderableProviders); <br /> * modelBatch.end(); <br /> * } <br /> * frameBuffer.end(); <br /> * Cubemap cubemap = frameBuffer.getColorBufferCubemap(); * </p> * * @author realitix */ public class FrameBufferCubemap extends GLFrameBuffer<Cubemap> { /** the zero-based index of the active side **/ private int currentSide; /** cubemap sides cache */ private static final Cubemap.CubemapSide[] cubemapSides = Cubemap.CubemapSide.values(); FrameBufferCubemap () { } /** Creates a GLFrameBuffer from the specifications provided by bufferBuilder * * @param bufferBuilder **/ protected FrameBufferCubemap (GLFrameBufferBuilder<? extends GLFrameBuffer<Cubemap>> bufferBuilder) { super(bufferBuilder); } /** Creates a new FrameBuffer having the given dimensions and potentially a depth buffer attached. * * @param format * @param width * @param height * @param hasDepth */ public FrameBufferCubemap (Pixmap.Format format, int width, int height, boolean hasDepth) { this(format, width, height, hasDepth, false); } /** Creates a new FrameBuffer having the given dimensions and potentially a depth and a stencil buffer attached. * * @param format the format of the color buffer; according to the OpenGL ES 2.0 spec, only RGB565, RGBA4444 and RGB5_A1 are * color-renderable * @param width the width of the cubemap in pixels * @param height the height of the cubemap in pixels * @param hasDepth whether to attach a depth buffer * @param hasStencil whether to attach a stencil buffer * @throws com.badlogic.gdx.utils.GdxRuntimeException in case the FrameBuffer could not be created */ public FrameBufferCubemap (Pixmap.Format format, int width, int height, boolean hasDepth, boolean hasStencil) { FrameBufferCubemapBuilder frameBufferBuilder = new FrameBufferCubemapBuilder(width, height); frameBufferBuilder.addBasicColorTextureAttachment(format); if (hasDepth) frameBufferBuilder.addBasicDepthRenderBuffer(); if (hasStencil) frameBufferBuilder.addBasicStencilRenderBuffer(); this.bufferBuilder = frameBufferBuilder; build(); } @Override protected Cubemap createTexture (FrameBufferTextureAttachmentSpec attachmentSpec) { GLOnlyTextureData data = new GLOnlyTextureData(bufferBuilder.width, bufferBuilder.height, 0, attachmentSpec.internalFormat, attachmentSpec.format, attachmentSpec.type); Cubemap result = new Cubemap(data, data, data, data, data, data); result.setFilter(TextureFilter.Linear, TextureFilter.Linear); result.setWrap(TextureWrap.ClampToEdge, TextureWrap.ClampToEdge); return result; } @Override protected void disposeColorTexture (Cubemap colorTexture) { colorTexture.dispose(); } @Override protected void attachFrameBufferColorTexture (Cubemap texture) { GL20 gl = Gdx.gl20; int glHandle = texture.getTextureObjectHandle(); Cubemap.CubemapSide[] sides = Cubemap.CubemapSide.values(); for (Cubemap.CubemapSide side : sides) { gl.glFramebufferTexture2D(GL20.GL_FRAMEBUFFER, GL20.GL_COLOR_ATTACHMENT0, side.glEnum, glHandle, 0); } } /** Makes the frame buffer current so everything gets drawn to it, must be followed by call to either {@link #nextSide()} or * {@link #bindSide(com.badlogic.gdx.graphics.Cubemap.CubemapSide)} to activate the side to render onto. */ @Override public void bind () { currentSide = -1; super.bind(); } /** Bind the next side of cubemap and return false if no more side. Should be called in between a call to {@link #begin()} and * #end to cycle to each side of the cubemap to render on. */ public boolean nextSide () { if (currentSide > 5) { throw new GdxRuntimeException("No remaining sides."); } else if (currentSide == 5) { return false; } currentSide++; bindSide(getSide()); return true; } /** Bind the side, making it active to render on. Should be called in between a call to {@link #begin()} and {@link #end()}. * @param side The side to bind */ protected void bindSide (final Cubemap.CubemapSide side) { Gdx.gl20.glFramebufferTexture2D(GL20.GL_FRAMEBUFFER, GL20.GL_COLOR_ATTACHMENT0, side.glEnum, getColorBufferTexture().getTextureObjectHandle(), 0); } /** Get the currently bound side. */ public Cubemap.CubemapSide getSide () { return currentSide < 0 ? null : cubemapSides[currentSide]; } }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./backends/gdx-backend-lwjgl/src/com/badlogic/gdx/backends/lwjgl/LwjglFileHandle.java
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.backends.lwjgl; import java.io.File; import com.badlogic.gdx.Files.FileType; import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.utils.GdxRuntimeException; /** @author mzechner * @author Nathan Sweet */ public final class LwjglFileHandle extends FileHandle { public LwjglFileHandle (String fileName, FileType type) { super(fileName, type); } public LwjglFileHandle (File file, FileType type) { super(file, type); } public FileHandle child (String name) { if (file.getPath().length() == 0) return new LwjglFileHandle(new File(name), type); return new LwjglFileHandle(new File(file, name), type); } public FileHandle sibling (String name) { if (file.getPath().length() == 0) throw new GdxRuntimeException("Cannot get the sibling of the root."); return new LwjglFileHandle(new File(file.getParent(), name), type); } public FileHandle parent () { File parent = file.getParentFile(); if (parent == null) { if (type == FileType.Absolute) parent = new File("/"); else parent = new File(""); } return new LwjglFileHandle(parent, type); } public File file () { if (type == FileType.External) return new File(LwjglFiles.externalPath, file.getPath()); if (type == FileType.Local) return new File(LwjglFiles.localPath, file.getPath()); return file; } }
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.backends.lwjgl; import java.io.File; import com.badlogic.gdx.Files.FileType; import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.utils.GdxRuntimeException; /** @author mzechner * @author Nathan Sweet */ public final class LwjglFileHandle extends FileHandle { public LwjglFileHandle (String fileName, FileType type) { super(fileName, type); } public LwjglFileHandle (File file, FileType type) { super(file, type); } public FileHandle child (String name) { if (file.getPath().length() == 0) return new LwjglFileHandle(new File(name), type); return new LwjglFileHandle(new File(file, name), type); } public FileHandle sibling (String name) { if (file.getPath().length() == 0) throw new GdxRuntimeException("Cannot get the sibling of the root."); return new LwjglFileHandle(new File(file.getParent(), name), type); } public FileHandle parent () { File parent = file.getParentFile(); if (parent == null) { if (type == FileType.Absolute) parent = new File("/"); else parent = new File(""); } return new LwjglFileHandle(parent, type); } public File file () { if (type == FileType.External) return new File(LwjglFiles.externalPath, file.getPath()); if (type == FileType.Local) return new File(LwjglFiles.localPath, file.getPath()); return file; } }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./extensions/gdx-bullet/jni/swig-src/collision/com/badlogic/gdx/physics/bullet/collision/ContactCallbackEvent.java
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.collision; public final class ContactCallbackEvent { public final static int TYPE_MASK = 0x0F; public final static int BY_MASK = 12; public final static int FILTERED = 1; public final static int INCLUDE_POINT = 2; public final static int BY_WRAPPER = 4; public final static int BY_MANIFOLD = 4; public final static int BY_OBJECT = 8; public final static int BY_VALUE = 12; public final static int SHIFT_ON_ADDED = 0; public final static int SHIFT_ON_PROCESSED = 4; public final static int SHIFT_ON_DESTROYED = 8; public final static int SHIFT_ON_STARTED = 12; public final static int SHIFT_ON_ENDED = 16; public final static int ON_ADDED_UNFILTERED_WRAPPER = (BY_WRAPPER) << SHIFT_ON_ADDED; public final static int ON_ADDED_UNFILTERED_OBJECT = (BY_OBJECT) << SHIFT_ON_ADDED; public final static int ON_ADDED_UNFILTERED_VALUE = (BY_VALUE) << SHIFT_ON_ADDED; public final static int ON_ADDED_UNFILTERED_WRAPPER_INCLUDEPOINT = (BY_WRAPPER | INCLUDE_POINT) << SHIFT_ON_ADDED; public final static int ON_ADDED_UNFILTERED_OBJECT_INCLUDEPOINT = (BY_OBJECT | INCLUDE_POINT) << SHIFT_ON_ADDED; public final static int ON_ADDED_UNFILTERED_VALUE_INCLUDEPOINT = (BY_VALUE | INCLUDE_POINT) << SHIFT_ON_ADDED; public final static int ON_ADDED_FILTERED_WRAPPER = (FILTERED | BY_WRAPPER) << SHIFT_ON_ADDED; public final static int ON_ADDED_FILTERED_OBJECT = (FILTERED | BY_OBJECT) << SHIFT_ON_ADDED; public final static int ON_ADDED_FILTERED_VALUE = (FILTERED | BY_VALUE) << SHIFT_ON_ADDED; public final static int ON_ADDED_FILTERED_WRAPPER_INCLUDEPOINT = (FILTERED | BY_WRAPPER | INCLUDE_POINT) << SHIFT_ON_ADDED; public final static int ON_ADDED_FILTERED_OBJECT_INCLUDEPOINT = (FILTERED | BY_OBJECT | INCLUDE_POINT) << SHIFT_ON_ADDED; public final static int ON_ADDED_FILTERED_VALUE_INCLUDEPOINT = (FILTERED | BY_VALUE | INCLUDE_POINT) << SHIFT_ON_ADDED; public final static int ON_PROCESSED_UNFILTERED_OBJECT = (BY_OBJECT) << SHIFT_ON_PROCESSED; public final static int ON_PROCESSED_UNFILTERED_VALUE = (BY_VALUE) << SHIFT_ON_PROCESSED; public final static int ON_PROCESSED_UNFILTERED_OBJECT_INCLUDEPOINT = (BY_OBJECT | INCLUDE_POINT) << SHIFT_ON_PROCESSED; public final static int ON_PROCESSED_UNFILTERED_VALUE_INCLUDEPOINT = (BY_VALUE | INCLUDE_POINT) << SHIFT_ON_PROCESSED; public final static int ON_PROCESSED_FILTERED_OBJECT = (FILTERED | BY_OBJECT) << SHIFT_ON_PROCESSED; public final static int ON_PROCESSED_FILTERED_VALUE = (FILTERED | BY_VALUE) << SHIFT_ON_PROCESSED; public final static int ON_PROCESSED_FILTERED_OBJECT_INCLUDEPOINT = (FILTERED | BY_OBJECT | INCLUDE_POINT) << SHIFT_ON_PROCESSED; public final static int ON_PROCESSED_FILTERED_VALUE_INCLUDEPOINT = (FILTERED | BY_VALUE | INCLUDE_POINT) << SHIFT_ON_PROCESSED; public final static int ON_DESTROYED = BY_VALUE << SHIFT_ON_DESTROYED; public final static int ON_STARTED_UNFILTERED_MANIFOLD = (BY_MANIFOLD) << SHIFT_ON_STARTED; public final static int ON_STARTED_UNFILTERED_OBJECT = (BY_OBJECT) << SHIFT_ON_STARTED; public final static int ON_STARTED_UNFILTERED_VALUE = (BY_VALUE) << SHIFT_ON_STARTED; public final static int ON_STARTED_FILTERED_MANIFOLD = (FILTERED | BY_MANIFOLD) << SHIFT_ON_STARTED; public final static int ON_STARTED_FILTERED_OBJECT = (FILTERED | BY_OBJECT) << SHIFT_ON_STARTED; public final static int ON_STARTED_FILTERED_VALUE = (FILTERED | BY_VALUE) << SHIFT_ON_STARTED; public final static int ON_ENDED_UNFILTERED_MANIFOLD = (BY_MANIFOLD) << SHIFT_ON_ENDED; public final static int ON_ENDED_UNFILTERED_OBJECT = (BY_OBJECT) << SHIFT_ON_ENDED; public final static int ON_ENDED_UNFILTERED_VALUE = (BY_VALUE) << SHIFT_ON_ENDED; public final static int ON_ENDED_FILTERED_MANIFOLD = (FILTERED | BY_MANIFOLD) << SHIFT_ON_ENDED; public final static int ON_ENDED_FILTERED_OBJECT = (FILTERED | BY_OBJECT) << SHIFT_ON_ENDED; public final static int ON_ENDED_FILTERED_VALUE = (FILTERED | BY_VALUE) << SHIFT_ON_ENDED; }
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.collision; public final class ContactCallbackEvent { public final static int TYPE_MASK = 0x0F; public final static int BY_MASK = 12; public final static int FILTERED = 1; public final static int INCLUDE_POINT = 2; public final static int BY_WRAPPER = 4; public final static int BY_MANIFOLD = 4; public final static int BY_OBJECT = 8; public final static int BY_VALUE = 12; public final static int SHIFT_ON_ADDED = 0; public final static int SHIFT_ON_PROCESSED = 4; public final static int SHIFT_ON_DESTROYED = 8; public final static int SHIFT_ON_STARTED = 12; public final static int SHIFT_ON_ENDED = 16; public final static int ON_ADDED_UNFILTERED_WRAPPER = (BY_WRAPPER) << SHIFT_ON_ADDED; public final static int ON_ADDED_UNFILTERED_OBJECT = (BY_OBJECT) << SHIFT_ON_ADDED; public final static int ON_ADDED_UNFILTERED_VALUE = (BY_VALUE) << SHIFT_ON_ADDED; public final static int ON_ADDED_UNFILTERED_WRAPPER_INCLUDEPOINT = (BY_WRAPPER | INCLUDE_POINT) << SHIFT_ON_ADDED; public final static int ON_ADDED_UNFILTERED_OBJECT_INCLUDEPOINT = (BY_OBJECT | INCLUDE_POINT) << SHIFT_ON_ADDED; public final static int ON_ADDED_UNFILTERED_VALUE_INCLUDEPOINT = (BY_VALUE | INCLUDE_POINT) << SHIFT_ON_ADDED; public final static int ON_ADDED_FILTERED_WRAPPER = (FILTERED | BY_WRAPPER) << SHIFT_ON_ADDED; public final static int ON_ADDED_FILTERED_OBJECT = (FILTERED | BY_OBJECT) << SHIFT_ON_ADDED; public final static int ON_ADDED_FILTERED_VALUE = (FILTERED | BY_VALUE) << SHIFT_ON_ADDED; public final static int ON_ADDED_FILTERED_WRAPPER_INCLUDEPOINT = (FILTERED | BY_WRAPPER | INCLUDE_POINT) << SHIFT_ON_ADDED; public final static int ON_ADDED_FILTERED_OBJECT_INCLUDEPOINT = (FILTERED | BY_OBJECT | INCLUDE_POINT) << SHIFT_ON_ADDED; public final static int ON_ADDED_FILTERED_VALUE_INCLUDEPOINT = (FILTERED | BY_VALUE | INCLUDE_POINT) << SHIFT_ON_ADDED; public final static int ON_PROCESSED_UNFILTERED_OBJECT = (BY_OBJECT) << SHIFT_ON_PROCESSED; public final static int ON_PROCESSED_UNFILTERED_VALUE = (BY_VALUE) << SHIFT_ON_PROCESSED; public final static int ON_PROCESSED_UNFILTERED_OBJECT_INCLUDEPOINT = (BY_OBJECT | INCLUDE_POINT) << SHIFT_ON_PROCESSED; public final static int ON_PROCESSED_UNFILTERED_VALUE_INCLUDEPOINT = (BY_VALUE | INCLUDE_POINT) << SHIFT_ON_PROCESSED; public final static int ON_PROCESSED_FILTERED_OBJECT = (FILTERED | BY_OBJECT) << SHIFT_ON_PROCESSED; public final static int ON_PROCESSED_FILTERED_VALUE = (FILTERED | BY_VALUE) << SHIFT_ON_PROCESSED; public final static int ON_PROCESSED_FILTERED_OBJECT_INCLUDEPOINT = (FILTERED | BY_OBJECT | INCLUDE_POINT) << SHIFT_ON_PROCESSED; public final static int ON_PROCESSED_FILTERED_VALUE_INCLUDEPOINT = (FILTERED | BY_VALUE | INCLUDE_POINT) << SHIFT_ON_PROCESSED; public final static int ON_DESTROYED = BY_VALUE << SHIFT_ON_DESTROYED; public final static int ON_STARTED_UNFILTERED_MANIFOLD = (BY_MANIFOLD) << SHIFT_ON_STARTED; public final static int ON_STARTED_UNFILTERED_OBJECT = (BY_OBJECT) << SHIFT_ON_STARTED; public final static int ON_STARTED_UNFILTERED_VALUE = (BY_VALUE) << SHIFT_ON_STARTED; public final static int ON_STARTED_FILTERED_MANIFOLD = (FILTERED | BY_MANIFOLD) << SHIFT_ON_STARTED; public final static int ON_STARTED_FILTERED_OBJECT = (FILTERED | BY_OBJECT) << SHIFT_ON_STARTED; public final static int ON_STARTED_FILTERED_VALUE = (FILTERED | BY_VALUE) << SHIFT_ON_STARTED; public final static int ON_ENDED_UNFILTERED_MANIFOLD = (BY_MANIFOLD) << SHIFT_ON_ENDED; public final static int ON_ENDED_UNFILTERED_OBJECT = (BY_OBJECT) << SHIFT_ON_ENDED; public final static int ON_ENDED_UNFILTERED_VALUE = (BY_VALUE) << SHIFT_ON_ENDED; public final static int ON_ENDED_FILTERED_MANIFOLD = (FILTERED | BY_MANIFOLD) << SHIFT_ON_ENDED; public final static int ON_ENDED_FILTERED_OBJECT = (FILTERED | BY_OBJECT) << SHIFT_ON_ENDED; public final static int ON_ENDED_FILTERED_VALUE = (FILTERED | BY_VALUE) << SHIFT_ON_ENDED; }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./tests/gdx-tests-lwjgl3/src/com/badlogic/gdx/tests/lwjgl3/MultiWindowTest.java
package com.badlogic.gdx.tests.lwjgl3; import com.badlogic.gdx.ApplicationAdapter; import com.badlogic.gdx.ApplicationListener; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Input; import com.badlogic.gdx.Graphics.DisplayMode; import com.badlogic.gdx.backends.lwjgl3.Lwjgl3WindowAdapter; import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application; import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration; import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Window; import com.badlogic.gdx.backends.lwjgl3.Lwjgl3WindowConfiguration; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Pixmap; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Pixmap.Blending; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.tests.NoncontinuousRenderingTest; import com.badlogic.gdx.tests.UITest; import com.badlogic.gdx.tests.g3d.Basic3DSceneTest; import com.badlogic.gdx.tests.g3d.ShaderCollectionTest; import com.badlogic.gdx.utils.GdxRuntimeException; import com.badlogic.gdx.utils.ScreenUtils; public class MultiWindowTest { static Texture sharedTexture; static SpriteBatch sharedSpriteBatch; public static class MainWindow extends ApplicationAdapter { Class[] childWindowClasses = {NoncontinuousRenderingTest.class, ShaderCollectionTest.class, Basic3DSceneTest.class, UITest.class}; Lwjgl3Window latestWindow; int index; @Override public void create () { System.out.println(Gdx.graphics.getGLVersion().getRendererString()); sharedSpriteBatch = new SpriteBatch(); sharedTexture = new Texture("data/badlogic.jpg"); } @Override public void render () { ScreenUtils.clear(1, 0, 0, 1); sharedSpriteBatch.getProjectionMatrix().setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); sharedSpriteBatch.begin(); sharedSpriteBatch.draw(sharedTexture, Gdx.input.getX(), Gdx.graphics.getHeight() - Gdx.input.getY() - 1); sharedSpriteBatch.end(); if (Gdx.input.justTouched()) { Lwjgl3Application app = (Lwjgl3Application)Gdx.app; Lwjgl3WindowConfiguration config = new Lwjgl3WindowConfiguration(); DisplayMode mode = Gdx.graphics.getDisplayMode(); config.setWindowPosition(MathUtils.random(0, mode.width - 640), MathUtils.random(0, mode.height - 480)); config.setTitle("Child window"); config.useVsync(false); config.setWindowListener(new Lwjgl3WindowAdapter() { @Override public void created (Lwjgl3Window window) { latestWindow = window; } }); Class clazz = childWindowClasses[index++ % childWindowClasses.length]; ApplicationListener listener = createChildWindowClass(clazz); app.newWindow(listener, config); } if (Gdx.input.isKeyJustPressed(Input.Keys.SPACE) && latestWindow != null) { latestWindow.setTitle("Retitled window"); int size = 48; Pixmap icon = new Pixmap(size, size, Pixmap.Format.RGBA8888); icon.setBlending(Blending.None); icon.setColor(Color.BLUE); icon.fill(); icon.setColor(Color.CLEAR); for (int i = 0; i < size; i += 3) for (int j = 0; j < size; j += 3) icon.drawPixel(i, j); latestWindow.setIcon(icon); icon.dispose(); } } public ApplicationListener createChildWindowClass (Class clazz) { try { return (ApplicationListener)clazz.newInstance(); } catch (Throwable t) { throw new GdxRuntimeException("Couldn't instantiate app listener", t); } } } public static void main (String[] argv) { Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration(); config.setTitle("Multi-window test"); config.useVsync(true); config.setOpenGLEmulation(Lwjgl3ApplicationConfiguration.GLEmulation.ANGLE_GLES20, 0, 0); new Lwjgl3Application(new MainWindow(), config); } }
package com.badlogic.gdx.tests.lwjgl3; import com.badlogic.gdx.ApplicationAdapter; import com.badlogic.gdx.ApplicationListener; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Input; import com.badlogic.gdx.Graphics.DisplayMode; import com.badlogic.gdx.backends.lwjgl3.Lwjgl3WindowAdapter; import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application; import com.badlogic.gdx.backends.lwjgl3.Lwjgl3ApplicationConfiguration; import com.badlogic.gdx.backends.lwjgl3.Lwjgl3Window; import com.badlogic.gdx.backends.lwjgl3.Lwjgl3WindowConfiguration; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Pixmap; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Pixmap.Blending; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.tests.NoncontinuousRenderingTest; import com.badlogic.gdx.tests.UITest; import com.badlogic.gdx.tests.g3d.Basic3DSceneTest; import com.badlogic.gdx.tests.g3d.ShaderCollectionTest; import com.badlogic.gdx.utils.GdxRuntimeException; import com.badlogic.gdx.utils.ScreenUtils; public class MultiWindowTest { static Texture sharedTexture; static SpriteBatch sharedSpriteBatch; public static class MainWindow extends ApplicationAdapter { Class[] childWindowClasses = {NoncontinuousRenderingTest.class, ShaderCollectionTest.class, Basic3DSceneTest.class, UITest.class}; Lwjgl3Window latestWindow; int index; @Override public void create () { System.out.println(Gdx.graphics.getGLVersion().getRendererString()); sharedSpriteBatch = new SpriteBatch(); sharedTexture = new Texture("data/badlogic.jpg"); } @Override public void render () { ScreenUtils.clear(1, 0, 0, 1); sharedSpriteBatch.getProjectionMatrix().setToOrtho2D(0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); sharedSpriteBatch.begin(); sharedSpriteBatch.draw(sharedTexture, Gdx.input.getX(), Gdx.graphics.getHeight() - Gdx.input.getY() - 1); sharedSpriteBatch.end(); if (Gdx.input.justTouched()) { Lwjgl3Application app = (Lwjgl3Application)Gdx.app; Lwjgl3WindowConfiguration config = new Lwjgl3WindowConfiguration(); DisplayMode mode = Gdx.graphics.getDisplayMode(); config.setWindowPosition(MathUtils.random(0, mode.width - 640), MathUtils.random(0, mode.height - 480)); config.setTitle("Child window"); config.useVsync(false); config.setWindowListener(new Lwjgl3WindowAdapter() { @Override public void created (Lwjgl3Window window) { latestWindow = window; } }); Class clazz = childWindowClasses[index++ % childWindowClasses.length]; ApplicationListener listener = createChildWindowClass(clazz); app.newWindow(listener, config); } if (Gdx.input.isKeyJustPressed(Input.Keys.SPACE) && latestWindow != null) { latestWindow.setTitle("Retitled window"); int size = 48; Pixmap icon = new Pixmap(size, size, Pixmap.Format.RGBA8888); icon.setBlending(Blending.None); icon.setColor(Color.BLUE); icon.fill(); icon.setColor(Color.CLEAR); for (int i = 0; i < size; i += 3) for (int j = 0; j < size; j += 3) icon.drawPixel(i, j); latestWindow.setIcon(icon); icon.dispose(); } } public ApplicationListener createChildWindowClass (Class clazz) { try { return (ApplicationListener)clazz.newInstance(); } catch (Throwable t) { throw new GdxRuntimeException("Couldn't instantiate app listener", t); } } } public static void main (String[] argv) { Lwjgl3ApplicationConfiguration config = new Lwjgl3ApplicationConfiguration(); config.setTitle("Multi-window test"); config.useVsync(true); config.setOpenGLEmulation(Lwjgl3ApplicationConfiguration.GLEmulation.ANGLE_GLES20, 0, 0); new Lwjgl3Application(new MainWindow(), config); } }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./tests/gdx-tests/src/com/badlogic/gdx/tests/PolygonRegionTest.java
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.tests; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.OrthographicCamera; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.PolygonRegion; import com.badlogic.gdx.graphics.g2d.PolygonRegionLoader; import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch; import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.math.Matrix4; import com.badlogic.gdx.tests.utils.GdxTest; import com.badlogic.gdx.utils.Disposable; import com.badlogic.gdx.utils.ScreenUtils; public class PolygonRegionTest extends GdxTest { PolygonSpriteBatch batch; PolygonRegionDebugRenderer debugRenderer; Texture texture; OrthographicCamera camera; PolygonRegion region; PolygonRegion region2; boolean usePolygonBatch = true; @Override public void create () { texture = new Texture(Gdx.files.internal("data/tree.png")); PolygonRegionLoader loader = new PolygonRegionLoader(); region = loader.load(new TextureRegion(texture), Gdx.files.internal("data/tree.psh")); // create a region from an arbitrary set of vertices (a triangle in this case) region2 = new PolygonRegion(new TextureRegion(texture), new float[] {0, 0, 100, 100, 0, 100}, new short[] {0, 1, 2}); camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); camera.position.x = 0; camera.position.y = 0; batch = new PolygonSpriteBatch(); debugRenderer = new PolygonRegionDebugRenderer(); Gdx.input.setInputProcessor(this); } @Override public void resize (int width, int height) { camera.viewportWidth = width; camera.viewportHeight = height; camera.update(); } @Override public void render () { ScreenUtils.clear(0.25f, 0.25f, 0.25f, 1.0f); camera.update(); batch.setProjectionMatrix(camera.combined); batch.begin(); // draw bot regions side-by-side float width = 256; float x = -width; batch.draw(region, x, -128, 256, 256); batch.draw(region2, x + width + 10, -128, 256, 256); batch.end(); debugRenderer.setProjectionMatrix(camera.combined); debugRenderer.draw(region, x, -128, 0, 0, 256, 256, 1, 1, 0); debugRenderer.draw(region2, x + width + 10, -128, 0, 0, 256, 256, 1, 1, 0); } @Override public void dispose () { debugRenderer.dispose(); texture.dispose(); batch.dispose(); } public class PolygonRegionDebugRenderer implements Disposable { ShapeRenderer renderer; public PolygonRegionDebugRenderer () { renderer = new ShapeRenderer(); } public void draw (PolygonRegion region, float x, float y, float originX, float originY, float width, float height, float scaleX, float scaleY, float rotation) { float[] vertices = region.getVertices(); short[] triangles = region.getTriangles(); float[] textureCoords = region.getTextureCoords(); // bottom left and top right corner points relative to origin final float worldOriginX = x + originX; final float worldOriginY = y + originY; float sX = width / region.getRegion().getRegionWidth(); float sY = height / region.getRegion().getRegionHeight(); float fx1, fx2, fx3, px1, px2, px3; float fy1, fy2, fy3, py1, py2, py3; final float cos = MathUtils.cosDeg(rotation); final float sin = MathUtils.sinDeg(rotation); renderer.setColor(Color.RED); renderer.begin(ShapeType.Line); for (int i = 0, n = triangles.length; i < n; i += 3) { int p1 = triangles[i] * 2; int p2 = triangles[i + 1] * 2; int p3 = triangles[i + 2] * 2; fx1 = vertices[p1] * sX; fy1 = vertices[p1 + 1] * sY; fx2 = vertices[p2] * sX; fy2 = vertices[p2 + 1] * sY; fx3 = vertices[p3] * sX; fy3 = vertices[p3 + 1] * sY; fx1 -= originX; fy1 -= originY; fx2 -= originX; fy2 -= originY; fx3 -= originX; fy3 -= originY; if (scaleX != 1 || scaleY != 1) { fx1 *= scaleX; fy1 *= scaleY; fx2 *= scaleX; fy2 *= scaleY; fx3 *= scaleX; fy3 *= scaleY; } px1 = cos * fx1 - sin * fy1; py1 = sin * fx1 + cos * fy1; px2 = cos * fx2 - sin * fy2; py2 = sin * fx2 + cos * fy2; px3 = cos * fx3 - sin * fy3; py3 = sin * fx3 + cos * fy3; px1 += worldOriginX; py1 += worldOriginY; px2 += worldOriginX; py2 += worldOriginY; px3 += worldOriginX; py3 += worldOriginY; renderer.line(px1, py1, px2, py2); renderer.line(px2, py2, px3, py3); renderer.line(px3, py3, px1, py1); } renderer.end(); renderer.setColor(Color.BLUE); renderer.begin(ShapeType.Filled); renderer.circle(worldOriginX, worldOriginY, 4); renderer.end(); // Calculate the bounding rect, is there a better way?! // bottom left and top right corner points relative to origin fx1 = -originX; fy1 = -originY; fx2 = width - originX; fy2 = height - originY; // scale if (scaleX != 1 || scaleY != 1) { fx1 *= scaleX; fy1 *= scaleY; fx2 *= scaleX; fy2 *= scaleY; } // construct corner points, start from top left and go counter clockwise final float p1x = fx1; final float p1y = fy1; final float p2x = fx1; final float p2y = fy2; final float p3x = fx2; final float p3y = fy2; final float p4x = fx2; final float p4y = fy1; float x1; float y1; float x2; float y2; float x3; float y3; float x4; float y4; // rotate if (rotation != 0) { x1 = cos * p1x - sin * p1y; y1 = sin * p1x + cos * p1y; x2 = cos * p2x - sin * p2y; y2 = sin * p2x + cos * p2y; x3 = cos * p3x - sin * p3y; y3 = sin * p3x + cos * p3y; x4 = x1 + (x3 - x2); y4 = y3 - (y2 - y1); } else { x1 = p1x; y1 = p1y; x2 = p2x; y2 = p2y; x3 = p3x; y3 = p3y; x4 = p4x; y4 = p4y; } x1 += worldOriginX; y1 += worldOriginY; x2 += worldOriginX; y2 += worldOriginY; x3 += worldOriginX; y3 += worldOriginY; x4 += worldOriginX; y4 += worldOriginY; // Draw the bounding rectangle renderer.setColor(Color.GREEN); renderer.begin(ShapeType.Line); renderer.line(x1, y1, x2, y2); renderer.line(x2, y2, x3, y3); renderer.line(x3, y3, x4, y4); renderer.line(x4, y4, x1, y1); renderer.end(); } public void setProjectionMatrix (Matrix4 matrix) { this.renderer.setProjectionMatrix(matrix); } @Override public void dispose () { renderer.dispose(); } } }
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.tests; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.OrthographicCamera; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.g2d.PolygonRegion; import com.badlogic.gdx.graphics.g2d.PolygonRegionLoader; import com.badlogic.gdx.graphics.g2d.PolygonSpriteBatch; import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.graphics.glutils.ShapeRenderer.ShapeType; import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.math.Matrix4; import com.badlogic.gdx.tests.utils.GdxTest; import com.badlogic.gdx.utils.Disposable; import com.badlogic.gdx.utils.ScreenUtils; public class PolygonRegionTest extends GdxTest { PolygonSpriteBatch batch; PolygonRegionDebugRenderer debugRenderer; Texture texture; OrthographicCamera camera; PolygonRegion region; PolygonRegion region2; boolean usePolygonBatch = true; @Override public void create () { texture = new Texture(Gdx.files.internal("data/tree.png")); PolygonRegionLoader loader = new PolygonRegionLoader(); region = loader.load(new TextureRegion(texture), Gdx.files.internal("data/tree.psh")); // create a region from an arbitrary set of vertices (a triangle in this case) region2 = new PolygonRegion(new TextureRegion(texture), new float[] {0, 0, 100, 100, 0, 100}, new short[] {0, 1, 2}); camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); camera.position.x = 0; camera.position.y = 0; batch = new PolygonSpriteBatch(); debugRenderer = new PolygonRegionDebugRenderer(); Gdx.input.setInputProcessor(this); } @Override public void resize (int width, int height) { camera.viewportWidth = width; camera.viewportHeight = height; camera.update(); } @Override public void render () { ScreenUtils.clear(0.25f, 0.25f, 0.25f, 1.0f); camera.update(); batch.setProjectionMatrix(camera.combined); batch.begin(); // draw bot regions side-by-side float width = 256; float x = -width; batch.draw(region, x, -128, 256, 256); batch.draw(region2, x + width + 10, -128, 256, 256); batch.end(); debugRenderer.setProjectionMatrix(camera.combined); debugRenderer.draw(region, x, -128, 0, 0, 256, 256, 1, 1, 0); debugRenderer.draw(region2, x + width + 10, -128, 0, 0, 256, 256, 1, 1, 0); } @Override public void dispose () { debugRenderer.dispose(); texture.dispose(); batch.dispose(); } public class PolygonRegionDebugRenderer implements Disposable { ShapeRenderer renderer; public PolygonRegionDebugRenderer () { renderer = new ShapeRenderer(); } public void draw (PolygonRegion region, float x, float y, float originX, float originY, float width, float height, float scaleX, float scaleY, float rotation) { float[] vertices = region.getVertices(); short[] triangles = region.getTriangles(); float[] textureCoords = region.getTextureCoords(); // bottom left and top right corner points relative to origin final float worldOriginX = x + originX; final float worldOriginY = y + originY; float sX = width / region.getRegion().getRegionWidth(); float sY = height / region.getRegion().getRegionHeight(); float fx1, fx2, fx3, px1, px2, px3; float fy1, fy2, fy3, py1, py2, py3; final float cos = MathUtils.cosDeg(rotation); final float sin = MathUtils.sinDeg(rotation); renderer.setColor(Color.RED); renderer.begin(ShapeType.Line); for (int i = 0, n = triangles.length; i < n; i += 3) { int p1 = triangles[i] * 2; int p2 = triangles[i + 1] * 2; int p3 = triangles[i + 2] * 2; fx1 = vertices[p1] * sX; fy1 = vertices[p1 + 1] * sY; fx2 = vertices[p2] * sX; fy2 = vertices[p2 + 1] * sY; fx3 = vertices[p3] * sX; fy3 = vertices[p3 + 1] * sY; fx1 -= originX; fy1 -= originY; fx2 -= originX; fy2 -= originY; fx3 -= originX; fy3 -= originY; if (scaleX != 1 || scaleY != 1) { fx1 *= scaleX; fy1 *= scaleY; fx2 *= scaleX; fy2 *= scaleY; fx3 *= scaleX; fy3 *= scaleY; } px1 = cos * fx1 - sin * fy1; py1 = sin * fx1 + cos * fy1; px2 = cos * fx2 - sin * fy2; py2 = sin * fx2 + cos * fy2; px3 = cos * fx3 - sin * fy3; py3 = sin * fx3 + cos * fy3; px1 += worldOriginX; py1 += worldOriginY; px2 += worldOriginX; py2 += worldOriginY; px3 += worldOriginX; py3 += worldOriginY; renderer.line(px1, py1, px2, py2); renderer.line(px2, py2, px3, py3); renderer.line(px3, py3, px1, py1); } renderer.end(); renderer.setColor(Color.BLUE); renderer.begin(ShapeType.Filled); renderer.circle(worldOriginX, worldOriginY, 4); renderer.end(); // Calculate the bounding rect, is there a better way?! // bottom left and top right corner points relative to origin fx1 = -originX; fy1 = -originY; fx2 = width - originX; fy2 = height - originY; // scale if (scaleX != 1 || scaleY != 1) { fx1 *= scaleX; fy1 *= scaleY; fx2 *= scaleX; fy2 *= scaleY; } // construct corner points, start from top left and go counter clockwise final float p1x = fx1; final float p1y = fy1; final float p2x = fx1; final float p2y = fy2; final float p3x = fx2; final float p3y = fy2; final float p4x = fx2; final float p4y = fy1; float x1; float y1; float x2; float y2; float x3; float y3; float x4; float y4; // rotate if (rotation != 0) { x1 = cos * p1x - sin * p1y; y1 = sin * p1x + cos * p1y; x2 = cos * p2x - sin * p2y; y2 = sin * p2x + cos * p2y; x3 = cos * p3x - sin * p3y; y3 = sin * p3x + cos * p3y; x4 = x1 + (x3 - x2); y4 = y3 - (y2 - y1); } else { x1 = p1x; y1 = p1y; x2 = p2x; y2 = p2y; x3 = p3x; y3 = p3y; x4 = p4x; y4 = p4y; } x1 += worldOriginX; y1 += worldOriginY; x2 += worldOriginX; y2 += worldOriginY; x3 += worldOriginX; y3 += worldOriginY; x4 += worldOriginX; y4 += worldOriginY; // Draw the bounding rectangle renderer.setColor(Color.GREEN); renderer.begin(ShapeType.Line); renderer.line(x1, y1, x2, y2); renderer.line(x2, y2, x3, y3); renderer.line(x3, y3, x4, y4); renderer.line(x4, y4, x1, y1); renderer.end(); } public void setProjectionMatrix (Matrix4 matrix) { this.renderer.setProjectionMatrix(matrix); } @Override public void dispose () { renderer.dispose(); } } }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./extensions/gdx-box2d/gdx-box2d-gwt/src/com/badlogic/gdx/physics/box2d/gwt/emu/org/jbox2d/dynamics/joints/PulleyJointDef.java
/******************************************************************************* * Copyright (c) 2013, Daniel Murphy * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. ******************************************************************************/ /** * Created at 12:11:41 PM Jan 23, 2011 */ package org.jbox2d.dynamics.joints; import org.jbox2d.common.Settings; import org.jbox2d.common.Vec2; import org.jbox2d.dynamics.Body; /** Pulley joint definition. This requires two ground anchors, two dynamic body anchor points, and a pulley ratio. * * @author Daniel Murphy */ public class PulleyJointDef extends JointDef { /** The first ground anchor in world coordinates. This point never moves. */ public Vec2 groundAnchorA; /** The second ground anchor in world coordinates. This point never moves. */ public Vec2 groundAnchorB; /** The local anchor point relative to bodyA's origin. */ public Vec2 localAnchorA; /** The local anchor point relative to bodyB's origin. */ public Vec2 localAnchorB; /** The a reference length for the segment attached to bodyA. */ public float lengthA; /** The a reference length for the segment attached to bodyB. */ public float lengthB; /** The pulley ratio, used to simulate a block-and-tackle. */ public float ratio; public PulleyJointDef () { super(JointType.PULLEY); groundAnchorA = new Vec2(-1.0f, 1.0f); groundAnchorB = new Vec2(1.0f, 1.0f); localAnchorA = new Vec2(-1.0f, 0.0f); localAnchorB = new Vec2(1.0f, 0.0f); lengthA = 0.0f; lengthB = 0.0f; ratio = 1.0f; collideConnected = true; } /** Initialize the bodies, anchors, lengths, max lengths, and ratio using the world anchors. */ public void initialize (Body b1, Body b2, Vec2 ga1, Vec2 ga2, Vec2 anchor1, Vec2 anchor2, float r) { bodyA = b1; bodyB = b2; groundAnchorA = ga1; groundAnchorB = ga2; localAnchorA = bodyA.getLocalPoint(anchor1); localAnchorB = bodyB.getLocalPoint(anchor2); Vec2 d1 = anchor1.sub(ga1); lengthA = d1.length(); Vec2 d2 = anchor2.sub(ga2); lengthB = d2.length(); ratio = r; assert (ratio > Settings.EPSILON); } }
/******************************************************************************* * Copyright (c) 2013, Daniel Murphy * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. ******************************************************************************/ /** * Created at 12:11:41 PM Jan 23, 2011 */ package org.jbox2d.dynamics.joints; import org.jbox2d.common.Settings; import org.jbox2d.common.Vec2; import org.jbox2d.dynamics.Body; /** Pulley joint definition. This requires two ground anchors, two dynamic body anchor points, and a pulley ratio. * * @author Daniel Murphy */ public class PulleyJointDef extends JointDef { /** The first ground anchor in world coordinates. This point never moves. */ public Vec2 groundAnchorA; /** The second ground anchor in world coordinates. This point never moves. */ public Vec2 groundAnchorB; /** The local anchor point relative to bodyA's origin. */ public Vec2 localAnchorA; /** The local anchor point relative to bodyB's origin. */ public Vec2 localAnchorB; /** The a reference length for the segment attached to bodyA. */ public float lengthA; /** The a reference length for the segment attached to bodyB. */ public float lengthB; /** The pulley ratio, used to simulate a block-and-tackle. */ public float ratio; public PulleyJointDef () { super(JointType.PULLEY); groundAnchorA = new Vec2(-1.0f, 1.0f); groundAnchorB = new Vec2(1.0f, 1.0f); localAnchorA = new Vec2(-1.0f, 0.0f); localAnchorB = new Vec2(1.0f, 0.0f); lengthA = 0.0f; lengthB = 0.0f; ratio = 1.0f; collideConnected = true; } /** Initialize the bodies, anchors, lengths, max lengths, and ratio using the world anchors. */ public void initialize (Body b1, Body b2, Vec2 ga1, Vec2 ga2, Vec2 anchor1, Vec2 anchor2, float r) { bodyA = b1; bodyB = b2; groundAnchorA = ga1; groundAnchorB = ga2; localAnchorA = bodyA.getLocalPoint(anchor1); localAnchorB = bodyB.getLocalPoint(anchor2); Vec2 d1 = anchor1.sub(ga1); lengthA = d1.length(); Vec2 d2 = anchor2.sub(ga2); lengthB = d2.length(); ratio = r; assert (ratio > Settings.EPSILON); } }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./backends/gdx-backend-robovm-metalangle/src/com/badlogic/gdx/backends/iosrobovm/bindings/metalangle/MGLKView.java
/* * Copyright (C) 2013-2015 RoboVM AB * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.badlogic.gdx.backends.iosrobovm.bindings.metalangle; /*<imports>*/ import org.robovm.apple.coregraphics.CGRect; import org.robovm.apple.coregraphics.CGSize; import org.robovm.apple.uikit.UIImage; import org.robovm.apple.uikit.UIView; import org.robovm.objc.ObjCRuntime; import org.robovm.objc.annotation.Method; import org.robovm.objc.annotation.NativeClass; import org.robovm.objc.annotation.Property; import org.robovm.rt.bro.annotation.ByVal; import org.robovm.rt.bro.annotation.MachineSizedSInt; import org.robovm.rt.bro.annotation.Pointer; import org.robovm.rt.bro.ptr.Ptr; /*</imports>*/ /*<javadoc>*/ /*</javadoc>*/ /*<annotations>*/@NativeClass /* </annotations> */ /* <visibility> */public/* </visibility> */ class /* <name> */ MGLKView/* </name> */ extends /* <extends> */UIView/* </extends> */ /* <implements> *//* </implements> */ { /* <ptr> */public static class MGLKViewPtr extends Ptr<MGLKView, MGLKViewPtr> { } /* </ptr> */ /* <bind> */static { ObjCRuntime.bind(MGLKView.class); }/* </bind> */ /* <constants> *//* </constants> */ /* <constructors> */ protected MGLKView () { } protected MGLKView (Handle h, long handle) { super(h, handle); } protected MGLKView (SkipInit skipInit) { super(skipInit); } @Method(selector = "initWithFrame:context:") public MGLKView (@ByVal CGRect frame, MGLContext context) { super((SkipInit)null); initObject(initWithFrameContext(frame, context)); } /* </constructors> */ /* <properties> */ @Property(selector = "context") public native MGLContext getContext (); @Property(selector = "setContext:") public native void setContext (MGLContext v); @Property(selector = "delegate") public native MGLKViewDelegate getDelegate (); @Property(selector = "setDelegate:", strongRef = true) public native void setDelegate (MGLKViewDelegate v); @Property(selector = "retainedBacking") public native boolean isRetainedBacking (); @Property(selector = "setRetainedBacking:") public native void setRetainedBacking (boolean v); @Property(selector = "drawableColorFormat") public native MGLDrawableColorFormat getDrawableColorFormat (); @Property(selector = "setDrawableColorFormat:") public native void setDrawableColorFormat (MGLDrawableColorFormat v); @Property(selector = "drawableDepthFormat") public native MGLDrawableDepthFormat getDrawableDepthFormat (); @Property(selector = "setDrawableDepthFormat:") public native void setDrawableDepthFormat (MGLDrawableDepthFormat v); @Property(selector = "drawableStencilFormat") public native MGLDrawableStencilFormat getDrawableStencilFormat (); @Property(selector = "setDrawableStencilFormat:") public native void setDrawableStencilFormat (MGLDrawableStencilFormat v); @Property(selector = "drawableMultisample") public native MGLDrawableMultisample getDrawableMultisample (); @Property(selector = "setDrawableMultisample:") public native void setDrawableMultisample (MGLDrawableMultisample v); @Property(selector = "glLayer") public native MGLLayer getGlLayer (); @Property(selector = "drawableSize") public native @ByVal CGSize getDrawableSize (); @Property(selector = "drawableWidth") public native @MachineSizedSInt long getDrawableWidth (); @Property(selector = "drawableHeight") public native @MachineSizedSInt long getDrawableHeight (); @Property(selector = "defaultOpenGLFrameBufferID") public native int getDefaultOpenGLFrameBufferID (); @Property(selector = "enableSetNeedsDisplay") public native boolean isEnableSetNeedsDisplay (); @Property(selector = "setEnableSetNeedsDisplay:") public native void setEnableSetNeedsDisplay (boolean v); @Property(selector = "snapshot") public native UIImage getSnapshot (); /* </properties> */ /* <members> *//* </members> */ /* <methods> */ @Method(selector = "initWithFrame:context:") protected native @Pointer long initWithFrameContext (@ByVal CGRect frame, MGLContext context); @Method(selector = "display") public native void display (); @Method(selector = "bindDrawable") public native void bindDrawable (); /* </methods> */ }
/* * Copyright (C) 2013-2015 RoboVM AB * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package com.badlogic.gdx.backends.iosrobovm.bindings.metalangle; /*<imports>*/ import org.robovm.apple.coregraphics.CGRect; import org.robovm.apple.coregraphics.CGSize; import org.robovm.apple.uikit.UIImage; import org.robovm.apple.uikit.UIView; import org.robovm.objc.ObjCRuntime; import org.robovm.objc.annotation.Method; import org.robovm.objc.annotation.NativeClass; import org.robovm.objc.annotation.Property; import org.robovm.rt.bro.annotation.ByVal; import org.robovm.rt.bro.annotation.MachineSizedSInt; import org.robovm.rt.bro.annotation.Pointer; import org.robovm.rt.bro.ptr.Ptr; /*</imports>*/ /*<javadoc>*/ /*</javadoc>*/ /*<annotations>*/@NativeClass /* </annotations> */ /* <visibility> */public/* </visibility> */ class /* <name> */ MGLKView/* </name> */ extends /* <extends> */UIView/* </extends> */ /* <implements> *//* </implements> */ { /* <ptr> */public static class MGLKViewPtr extends Ptr<MGLKView, MGLKViewPtr> { } /* </ptr> */ /* <bind> */static { ObjCRuntime.bind(MGLKView.class); }/* </bind> */ /* <constants> *//* </constants> */ /* <constructors> */ protected MGLKView () { } protected MGLKView (Handle h, long handle) { super(h, handle); } protected MGLKView (SkipInit skipInit) { super(skipInit); } @Method(selector = "initWithFrame:context:") public MGLKView (@ByVal CGRect frame, MGLContext context) { super((SkipInit)null); initObject(initWithFrameContext(frame, context)); } /* </constructors> */ /* <properties> */ @Property(selector = "context") public native MGLContext getContext (); @Property(selector = "setContext:") public native void setContext (MGLContext v); @Property(selector = "delegate") public native MGLKViewDelegate getDelegate (); @Property(selector = "setDelegate:", strongRef = true) public native void setDelegate (MGLKViewDelegate v); @Property(selector = "retainedBacking") public native boolean isRetainedBacking (); @Property(selector = "setRetainedBacking:") public native void setRetainedBacking (boolean v); @Property(selector = "drawableColorFormat") public native MGLDrawableColorFormat getDrawableColorFormat (); @Property(selector = "setDrawableColorFormat:") public native void setDrawableColorFormat (MGLDrawableColorFormat v); @Property(selector = "drawableDepthFormat") public native MGLDrawableDepthFormat getDrawableDepthFormat (); @Property(selector = "setDrawableDepthFormat:") public native void setDrawableDepthFormat (MGLDrawableDepthFormat v); @Property(selector = "drawableStencilFormat") public native MGLDrawableStencilFormat getDrawableStencilFormat (); @Property(selector = "setDrawableStencilFormat:") public native void setDrawableStencilFormat (MGLDrawableStencilFormat v); @Property(selector = "drawableMultisample") public native MGLDrawableMultisample getDrawableMultisample (); @Property(selector = "setDrawableMultisample:") public native void setDrawableMultisample (MGLDrawableMultisample v); @Property(selector = "glLayer") public native MGLLayer getGlLayer (); @Property(selector = "drawableSize") public native @ByVal CGSize getDrawableSize (); @Property(selector = "drawableWidth") public native @MachineSizedSInt long getDrawableWidth (); @Property(selector = "drawableHeight") public native @MachineSizedSInt long getDrawableHeight (); @Property(selector = "defaultOpenGLFrameBufferID") public native int getDefaultOpenGLFrameBufferID (); @Property(selector = "enableSetNeedsDisplay") public native boolean isEnableSetNeedsDisplay (); @Property(selector = "setEnableSetNeedsDisplay:") public native void setEnableSetNeedsDisplay (boolean v); @Property(selector = "snapshot") public native UIImage getSnapshot (); /* </properties> */ /* <members> *//* </members> */ /* <methods> */ @Method(selector = "initWithFrame:context:") protected native @Pointer long initWithFrameContext (@ByVal CGRect frame, MGLContext context); @Method(selector = "display") public native void display (); @Method(selector = "bindDrawable") public native void bindDrawable (); /* </methods> */ }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./extensions/gdx-bullet/jni/swig-src/collision/com/badlogic/gdx/physics/bullet/collision/eEpaStatus.java
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.collision; public final class eEpaStatus { public final static int eEpaValid = 0; public final static int eEpaTouching = eEpaValid + 1; public final static int eEpaDegenerated = eEpaTouching + 1; public final static int eEpaNonConvex = eEpaDegenerated + 1; public final static int eEpaInvalidHull = eEpaNonConvex + 1; public final static int eEpaOutOfFaces = eEpaInvalidHull + 1; public final static int eEpaOutOfVertices = eEpaOutOfFaces + 1; public final static int eEpaAccuraryReached = eEpaOutOfVertices + 1; public final static int eEpaFallBack = eEpaAccuraryReached + 1; public final static int eEpaFailed = eEpaFallBack + 1; }
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.collision; public final class eEpaStatus { public final static int eEpaValid = 0; public final static int eEpaTouching = eEpaValid + 1; public final static int eEpaDegenerated = eEpaTouching + 1; public final static int eEpaNonConvex = eEpaDegenerated + 1; public final static int eEpaInvalidHull = eEpaNonConvex + 1; public final static int eEpaOutOfFaces = eEpaInvalidHull + 1; public final static int eEpaOutOfVertices = eEpaOutOfFaces + 1; public final static int eEpaAccuraryReached = eEpaOutOfVertices + 1; public final static int eEpaFallBack = eEpaAccuraryReached + 1; public final static int eEpaFailed = eEpaFallBack + 1; }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./gdx/src/com/badlogic/gdx/Gdx.java
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.GL30; import com.badlogic.gdx.graphics.GL31; import com.badlogic.gdx.graphics.GL32; /** Environment class holding references to the {@link Application}, {@link Graphics}, {@link Audio}, {@link Files} and * {@link Input} instances. The references are held in public static fields which allows static access to all sub systems. Do not * use Graphics in a thread that is not the rendering thread. * <p> * This is normally a design faux pas but in this case is better than the alternatives. * @author mzechner */ public class Gdx { public static Application app; public static Graphics graphics; public static Audio audio; public static Input input; public static Files files; public static Net net; public static GL20 gl; public static GL20 gl20; public static GL30 gl30; public static GL31 gl31; public static GL32 gl32; }
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.GL30; import com.badlogic.gdx.graphics.GL31; import com.badlogic.gdx.graphics.GL32; /** Environment class holding references to the {@link Application}, {@link Graphics}, {@link Audio}, {@link Files} and * {@link Input} instances. The references are held in public static fields which allows static access to all sub systems. Do not * use Graphics in a thread that is not the rendering thread. * <p> * This is normally a design faux pas but in this case is better than the alternatives. * @author mzechner */ public class Gdx { public static Application app; public static Graphics graphics; public static Audio audio; public static Input input; public static Files files; public static Net net; public static GL20 gl; public static GL20 gl20; public static GL30 gl30; public static GL31 gl31; public static GL32 gl32; }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./gdx/src/com/badlogic/gdx/graphics/g3d/utils/RenderContext.java
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.graphics.g3d.utils; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.GL20; /** Manages OpenGL state and tries to reduce state changes. Uses a {@link TextureBinder} to reduce texture binds as well. Call * {@link #begin()} to setup the context, call {@link #end()} to undo all state changes. Use the setters to change state, use * {@link #textureBinder} to bind textures. * @author badlogic, Xoppa */ public class RenderContext { /** used to bind textures **/ public final TextureBinder textureBinder; private boolean blending; private int blendSFactor; private int blendDFactor; private int depthFunc; private float depthRangeNear; private float depthRangeFar; private boolean depthMask; private int cullFace; public RenderContext (TextureBinder textures) { this.textureBinder = textures; } /** Sets up the render context, must be matched with a call to {@link #end()}. */ public void begin () { Gdx.gl.glDisable(GL20.GL_DEPTH_TEST); depthFunc = 0; Gdx.gl.glDepthMask(true); depthMask = true; Gdx.gl.glDisable(GL20.GL_BLEND); blending = false; Gdx.gl.glDisable(GL20.GL_CULL_FACE); cullFace = blendSFactor = blendDFactor = 0; textureBinder.begin(); } /** Resets all changed OpenGL states to their defaults. */ public void end () { if (depthFunc != 0) Gdx.gl.glDisable(GL20.GL_DEPTH_TEST); if (!depthMask) Gdx.gl.glDepthMask(true); if (blending) Gdx.gl.glDisable(GL20.GL_BLEND); if (cullFace > 0) Gdx.gl.glDisable(GL20.GL_CULL_FACE); textureBinder.end(); } public void setDepthMask (final boolean depthMask) { if (this.depthMask != depthMask) Gdx.gl.glDepthMask(this.depthMask = depthMask); } public void setDepthTest (final int depthFunction) { setDepthTest(depthFunction, 0f, 1f); } public void setDepthTest (final int depthFunction, final float depthRangeNear, final float depthRangeFar) { final boolean wasEnabled = depthFunc != 0; final boolean enabled = depthFunction != 0; if (depthFunc != depthFunction) { depthFunc = depthFunction; if (enabled) { Gdx.gl.glEnable(GL20.GL_DEPTH_TEST); Gdx.gl.glDepthFunc(depthFunction); } else Gdx.gl.glDisable(GL20.GL_DEPTH_TEST); } if (enabled) { if (!wasEnabled || depthFunc != depthFunction) Gdx.gl.glDepthFunc(depthFunc = depthFunction); if (!wasEnabled || this.depthRangeNear != depthRangeNear || this.depthRangeFar != depthRangeFar) Gdx.gl.glDepthRangef(this.depthRangeNear = depthRangeNear, this.depthRangeFar = depthRangeFar); } } public void setBlending (final boolean enabled, final int sFactor, final int dFactor) { if (enabled != blending) { blending = enabled; if (enabled) Gdx.gl.glEnable(GL20.GL_BLEND); else Gdx.gl.glDisable(GL20.GL_BLEND); } if (enabled && (blendSFactor != sFactor || blendDFactor != dFactor)) { Gdx.gl.glBlendFunc(sFactor, dFactor); blendSFactor = sFactor; blendDFactor = dFactor; } } public void setCullFace (final int face) { if (face != cullFace) { cullFace = face; if ((face == GL20.GL_FRONT) || (face == GL20.GL_BACK) || (face == GL20.GL_FRONT_AND_BACK)) { Gdx.gl.glEnable(GL20.GL_CULL_FACE); Gdx.gl.glCullFace(face); } else Gdx.gl.glDisable(GL20.GL_CULL_FACE); } } }
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.graphics.g3d.utils; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.GL20; /** Manages OpenGL state and tries to reduce state changes. Uses a {@link TextureBinder} to reduce texture binds as well. Call * {@link #begin()} to setup the context, call {@link #end()} to undo all state changes. Use the setters to change state, use * {@link #textureBinder} to bind textures. * @author badlogic, Xoppa */ public class RenderContext { /** used to bind textures **/ public final TextureBinder textureBinder; private boolean blending; private int blendSFactor; private int blendDFactor; private int depthFunc; private float depthRangeNear; private float depthRangeFar; private boolean depthMask; private int cullFace; public RenderContext (TextureBinder textures) { this.textureBinder = textures; } /** Sets up the render context, must be matched with a call to {@link #end()}. */ public void begin () { Gdx.gl.glDisable(GL20.GL_DEPTH_TEST); depthFunc = 0; Gdx.gl.glDepthMask(true); depthMask = true; Gdx.gl.glDisable(GL20.GL_BLEND); blending = false; Gdx.gl.glDisable(GL20.GL_CULL_FACE); cullFace = blendSFactor = blendDFactor = 0; textureBinder.begin(); } /** Resets all changed OpenGL states to their defaults. */ public void end () { if (depthFunc != 0) Gdx.gl.glDisable(GL20.GL_DEPTH_TEST); if (!depthMask) Gdx.gl.glDepthMask(true); if (blending) Gdx.gl.glDisable(GL20.GL_BLEND); if (cullFace > 0) Gdx.gl.glDisable(GL20.GL_CULL_FACE); textureBinder.end(); } public void setDepthMask (final boolean depthMask) { if (this.depthMask != depthMask) Gdx.gl.glDepthMask(this.depthMask = depthMask); } public void setDepthTest (final int depthFunction) { setDepthTest(depthFunction, 0f, 1f); } public void setDepthTest (final int depthFunction, final float depthRangeNear, final float depthRangeFar) { final boolean wasEnabled = depthFunc != 0; final boolean enabled = depthFunction != 0; if (depthFunc != depthFunction) { depthFunc = depthFunction; if (enabled) { Gdx.gl.glEnable(GL20.GL_DEPTH_TEST); Gdx.gl.glDepthFunc(depthFunction); } else Gdx.gl.glDisable(GL20.GL_DEPTH_TEST); } if (enabled) { if (!wasEnabled || depthFunc != depthFunction) Gdx.gl.glDepthFunc(depthFunc = depthFunction); if (!wasEnabled || this.depthRangeNear != depthRangeNear || this.depthRangeFar != depthRangeFar) Gdx.gl.glDepthRangef(this.depthRangeNear = depthRangeNear, this.depthRangeFar = depthRangeFar); } } public void setBlending (final boolean enabled, final int sFactor, final int dFactor) { if (enabled != blending) { blending = enabled; if (enabled) Gdx.gl.glEnable(GL20.GL_BLEND); else Gdx.gl.glDisable(GL20.GL_BLEND); } if (enabled && (blendSFactor != sFactor || blendDFactor != dFactor)) { Gdx.gl.glBlendFunc(sFactor, dFactor); blendSFactor = sFactor; blendDFactor = dFactor; } } public void setCullFace (final int face) { if (face != cullFace) { cullFace = face; if ((face == GL20.GL_FRONT) || (face == GL20.GL_BACK) || (face == GL20.GL_FRONT_AND_BACK)) { Gdx.gl.glEnable(GL20.GL_CULL_FACE); Gdx.gl.glCullFace(face); } else Gdx.gl.glDisable(GL20.GL_CULL_FACE); } } }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./extensions/gdx-bullet/jni/swig-src/collision/com/badlogic/gdx/physics/bullet/collision/btTriangleShapeEx.java
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.collision; import com.badlogic.gdx.physics.bullet.linearmath.*; import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.math.Matrix4; public class btTriangleShapeEx extends btTriangleShape { private long swigCPtr; protected btTriangleShapeEx (final String className, long cPtr, boolean cMemoryOwn) { super(className, CollisionJNI.btTriangleShapeEx_SWIGUpcast(cPtr), cMemoryOwn); swigCPtr = cPtr; } /** Construct a new btTriangleShapeEx, normally you should not need this constructor it's intended for low-level usage. */ public btTriangleShapeEx (long cPtr, boolean cMemoryOwn) { this("btTriangleShapeEx", cPtr, cMemoryOwn); construct(); } @Override protected void reset (long cPtr, boolean cMemoryOwn) { if (!destroyed) destroy(); super.reset(CollisionJNI.btTriangleShapeEx_SWIGUpcast(swigCPtr = cPtr), cMemoryOwn); } public static long getCPtr (btTriangleShapeEx obj) { return (obj == null) ? 0 : obj.swigCPtr; } @Override protected void finalize () throws Throwable { if (!destroyed) destroy(); super.finalize(); } @Override protected synchronized void delete () { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; CollisionJNI.delete_btTriangleShapeEx(swigCPtr); } swigCPtr = 0; } super.delete(); } public btTriangleShapeEx () { this(CollisionJNI.new_btTriangleShapeEx__SWIG_0(), true); } public btTriangleShapeEx (Vector3 p0, Vector3 p1, Vector3 p2) { this(CollisionJNI.new_btTriangleShapeEx__SWIG_1(p0, p1, p2), true); } public btTriangleShapeEx (btTriangleShapeEx other) { this(CollisionJNI.new_btTriangleShapeEx__SWIG_2(btTriangleShapeEx.getCPtr(other), other), true); } public void applyTransform (Matrix4 t) { CollisionJNI.btTriangleShapeEx_applyTransform(swigCPtr, this, t); } public void buildTriPlane (btVector4 plane) { CollisionJNI.btTriangleShapeEx_buildTriPlane(swigCPtr, this, btVector4.getCPtr(plane), plane); } public boolean overlap_test_conservative (btTriangleShapeEx other) { return CollisionJNI.btTriangleShapeEx_overlap_test_conservative(swigCPtr, this, btTriangleShapeEx.getCPtr(other), other); } }
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.collision; import com.badlogic.gdx.physics.bullet.linearmath.*; import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.math.Matrix4; public class btTriangleShapeEx extends btTriangleShape { private long swigCPtr; protected btTriangleShapeEx (final String className, long cPtr, boolean cMemoryOwn) { super(className, CollisionJNI.btTriangleShapeEx_SWIGUpcast(cPtr), cMemoryOwn); swigCPtr = cPtr; } /** Construct a new btTriangleShapeEx, normally you should not need this constructor it's intended for low-level usage. */ public btTriangleShapeEx (long cPtr, boolean cMemoryOwn) { this("btTriangleShapeEx", cPtr, cMemoryOwn); construct(); } @Override protected void reset (long cPtr, boolean cMemoryOwn) { if (!destroyed) destroy(); super.reset(CollisionJNI.btTriangleShapeEx_SWIGUpcast(swigCPtr = cPtr), cMemoryOwn); } public static long getCPtr (btTriangleShapeEx obj) { return (obj == null) ? 0 : obj.swigCPtr; } @Override protected void finalize () throws Throwable { if (!destroyed) destroy(); super.finalize(); } @Override protected synchronized void delete () { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; CollisionJNI.delete_btTriangleShapeEx(swigCPtr); } swigCPtr = 0; } super.delete(); } public btTriangleShapeEx () { this(CollisionJNI.new_btTriangleShapeEx__SWIG_0(), true); } public btTriangleShapeEx (Vector3 p0, Vector3 p1, Vector3 p2) { this(CollisionJNI.new_btTriangleShapeEx__SWIG_1(p0, p1, p2), true); } public btTriangleShapeEx (btTriangleShapeEx other) { this(CollisionJNI.new_btTriangleShapeEx__SWIG_2(btTriangleShapeEx.getCPtr(other), other), true); } public void applyTransform (Matrix4 t) { CollisionJNI.btTriangleShapeEx_applyTransform(swigCPtr, this, t); } public void buildTriPlane (btVector4 plane) { CollisionJNI.btTriangleShapeEx_buildTriPlane(swigCPtr, this, btVector4.getCPtr(plane), plane); } public boolean overlap_test_conservative (btTriangleShapeEx other) { return CollisionJNI.btTriangleShapeEx_overlap_test_conservative(swigCPtr, this, btTriangleShapeEx.getCPtr(other), other); } }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./extensions/gdx-freetype/src/com/badlogic/gdx/graphics/g2d/freetype/FreetypeFontLoader.java
package com.badlogic.gdx.graphics.g2d.freetype; import com.badlogic.gdx.assets.AssetDescriptor; import com.badlogic.gdx.assets.AssetLoaderParameters; import com.badlogic.gdx.assets.AssetManager; import com.badlogic.gdx.assets.loaders.AsynchronousAssetLoader; import com.badlogic.gdx.assets.loaders.FileHandleResolver; import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter; import com.badlogic.gdx.utils.Array; /** Creates {@link BitmapFont} instances from FreeType font files. Requires a {@link FreeTypeFontLoaderParameter} to be passed to * {@link AssetManager#load(String, Class, AssetLoaderParameters)} which specifies the name of the TTF file as well the parameters * used to generate the BitmapFont (size, characters, etc.) */ public class FreetypeFontLoader extends AsynchronousAssetLoader<BitmapFont, FreetypeFontLoader.FreeTypeFontLoaderParameter> { public FreetypeFontLoader (FileHandleResolver resolver) { super(resolver); } public static class FreeTypeFontLoaderParameter extends AssetLoaderParameters<BitmapFont> { /** the name of the TTF file to be used to load the font **/ public String fontFileName; /** the parameters used to generate the font, e.g. size, characters, etc. **/ public FreeTypeFontParameter fontParameters = new FreeTypeFontParameter(); } @Override public void loadAsync (AssetManager manager, String fileName, FileHandle file, FreeTypeFontLoaderParameter parameter) { if (parameter == null) throw new RuntimeException("FreetypeFontParameter must be set in AssetManager#load to point at a TTF file!"); } @Override public BitmapFont loadSync (AssetManager manager, String fileName, FileHandle file, FreeTypeFontLoaderParameter parameter) { if (parameter == null) throw new RuntimeException("FreetypeFontParameter must be set in AssetManager#load to point at a TTF file!"); FreeTypeFontGenerator generator = manager.get(parameter.fontFileName + ".gen", FreeTypeFontGenerator.class); BitmapFont font = generator.generateFont(parameter.fontParameters); return font; } @Override public Array<AssetDescriptor> getDependencies (String fileName, FileHandle file, FreeTypeFontLoaderParameter parameter) { Array<AssetDescriptor> deps = new Array<AssetDescriptor>(); deps.add(new AssetDescriptor<FreeTypeFontGenerator>(parameter.fontFileName + ".gen", FreeTypeFontGenerator.class)); return deps; } }
package com.badlogic.gdx.graphics.g2d.freetype; import com.badlogic.gdx.assets.AssetDescriptor; import com.badlogic.gdx.assets.AssetLoaderParameters; import com.badlogic.gdx.assets.AssetManager; import com.badlogic.gdx.assets.loaders.AsynchronousAssetLoader; import com.badlogic.gdx.assets.loaders.FileHandleResolver; import com.badlogic.gdx.files.FileHandle; import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.freetype.FreeTypeFontGenerator.FreeTypeFontParameter; import com.badlogic.gdx.utils.Array; /** Creates {@link BitmapFont} instances from FreeType font files. Requires a {@link FreeTypeFontLoaderParameter} to be passed to * {@link AssetManager#load(String, Class, AssetLoaderParameters)} which specifies the name of the TTF file as well the parameters * used to generate the BitmapFont (size, characters, etc.) */ public class FreetypeFontLoader extends AsynchronousAssetLoader<BitmapFont, FreetypeFontLoader.FreeTypeFontLoaderParameter> { public FreetypeFontLoader (FileHandleResolver resolver) { super(resolver); } public static class FreeTypeFontLoaderParameter extends AssetLoaderParameters<BitmapFont> { /** the name of the TTF file to be used to load the font **/ public String fontFileName; /** the parameters used to generate the font, e.g. size, characters, etc. **/ public FreeTypeFontParameter fontParameters = new FreeTypeFontParameter(); } @Override public void loadAsync (AssetManager manager, String fileName, FileHandle file, FreeTypeFontLoaderParameter parameter) { if (parameter == null) throw new RuntimeException("FreetypeFontParameter must be set in AssetManager#load to point at a TTF file!"); } @Override public BitmapFont loadSync (AssetManager manager, String fileName, FileHandle file, FreeTypeFontLoaderParameter parameter) { if (parameter == null) throw new RuntimeException("FreetypeFontParameter must be set in AssetManager#load to point at a TTF file!"); FreeTypeFontGenerator generator = manager.get(parameter.fontFileName + ".gen", FreeTypeFontGenerator.class); BitmapFont font = generator.generateFont(parameter.fontParameters); return font; } @Override public Array<AssetDescriptor> getDependencies (String fileName, FileHandle file, FreeTypeFontLoaderParameter parameter) { Array<AssetDescriptor> deps = new Array<AssetDescriptor>(); deps.add(new AssetDescriptor<FreeTypeFontGenerator>(parameter.fontFileName + ".gen", FreeTypeFontGenerator.class)); return deps; } }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./gdx/src/com/badlogic/gdx/maps/tiled/renderers/BatchTiledMapRenderer.java
/******************************************************************************* * Copyright 2013 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.maps.tiled.renderers; import static com.badlogic.gdx.graphics.g2d.Batch.C1; import static com.badlogic.gdx.graphics.g2d.Batch.C2; import static com.badlogic.gdx.graphics.g2d.Batch.C3; import static com.badlogic.gdx.graphics.g2d.Batch.C4; import static com.badlogic.gdx.graphics.g2d.Batch.U1; import static com.badlogic.gdx.graphics.g2d.Batch.U2; import static com.badlogic.gdx.graphics.g2d.Batch.U3; import static com.badlogic.gdx.graphics.g2d.Batch.U4; import static com.badlogic.gdx.graphics.g2d.Batch.V1; import static com.badlogic.gdx.graphics.g2d.Batch.V2; import static com.badlogic.gdx.graphics.g2d.Batch.V3; import static com.badlogic.gdx.graphics.g2d.Batch.V4; import static com.badlogic.gdx.graphics.g2d.Batch.X1; import static com.badlogic.gdx.graphics.g2d.Batch.X2; import static com.badlogic.gdx.graphics.g2d.Batch.X3; import static com.badlogic.gdx.graphics.g2d.Batch.X4; import static com.badlogic.gdx.graphics.g2d.Batch.Y1; import static com.badlogic.gdx.graphics.g2d.Batch.Y2; import static com.badlogic.gdx.graphics.g2d.Batch.Y3; import static com.badlogic.gdx.graphics.g2d.Batch.Y4; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.OrthographicCamera; import com.badlogic.gdx.graphics.g2d.Batch; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.maps.MapGroupLayer; import com.badlogic.gdx.maps.MapLayer; import com.badlogic.gdx.maps.MapLayers; import com.badlogic.gdx.maps.MapObject; import com.badlogic.gdx.maps.tiled.TiledMap; import com.badlogic.gdx.maps.tiled.TiledMapImageLayer; import com.badlogic.gdx.maps.tiled.TiledMapRenderer; import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; import com.badlogic.gdx.maps.tiled.tiles.AnimatedTiledMapTile; import com.badlogic.gdx.math.Matrix4; import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.utils.Disposable; public abstract class BatchTiledMapRenderer implements TiledMapRenderer, Disposable { static protected final int NUM_VERTICES = 20; protected TiledMap map; protected float unitScale; protected Batch batch; protected Rectangle viewBounds; protected Rectangle imageBounds = new Rectangle(); protected boolean ownsBatch; protected float vertices[] = new float[NUM_VERTICES]; public TiledMap getMap () { return map; } public void setMap (TiledMap map) { this.map = map; } public float getUnitScale () { return unitScale; } public Batch getBatch () { return batch; } public Rectangle getViewBounds () { return viewBounds; } public BatchTiledMapRenderer (TiledMap map) { this(map, 1.0f); } public BatchTiledMapRenderer (TiledMap map, float unitScale) { this.map = map; this.unitScale = unitScale; this.viewBounds = new Rectangle(); this.batch = new SpriteBatch(); this.ownsBatch = true; } public BatchTiledMapRenderer (TiledMap map, Batch batch) { this(map, 1.0f, batch); } public BatchTiledMapRenderer (TiledMap map, float unitScale, Batch batch) { this.map = map; this.unitScale = unitScale; this.viewBounds = new Rectangle(); this.batch = batch; this.ownsBatch = false; } @Override public void setView (OrthographicCamera camera) { batch.setProjectionMatrix(camera.combined); float width = camera.viewportWidth * camera.zoom; float height = camera.viewportHeight * camera.zoom; float w = width * Math.abs(camera.up.y) + height * Math.abs(camera.up.x); float h = height * Math.abs(camera.up.y) + width * Math.abs(camera.up.x); viewBounds.set(camera.position.x - w / 2, camera.position.y - h / 2, w, h); } @Override public void setView (Matrix4 projection, float x, float y, float width, float height) { batch.setProjectionMatrix(projection); viewBounds.set(x, y, width, height); } @Override public void render () { beginRender(); for (MapLayer layer : map.getLayers()) { renderMapLayer(layer); } endRender(); } @Override public void render (int[] layers) { beginRender(); for (int layerIdx : layers) { MapLayer layer = map.getLayers().get(layerIdx); renderMapLayer(layer); } endRender(); } protected void renderMapLayer (MapLayer layer) { if (!layer.isVisible()) return; if (layer instanceof MapGroupLayer) { MapLayers childLayers = ((MapGroupLayer)layer).getLayers(); for (int i = 0; i < childLayers.size(); i++) { MapLayer childLayer = childLayers.get(i); if (!childLayer.isVisible()) continue; renderMapLayer(childLayer); } } else { if (layer instanceof TiledMapTileLayer) { renderTileLayer((TiledMapTileLayer)layer); } else if (layer instanceof TiledMapImageLayer) { renderImageLayer((TiledMapImageLayer)layer); } else { renderObjects(layer); } } } @Override public void renderObjects (MapLayer layer) { for (MapObject object : layer.getObjects()) { renderObject(object); } } @Override public void renderObject (MapObject object) { } @Override public void renderImageLayer (TiledMapImageLayer layer) { final Color batchColor = batch.getColor(); final float color = Color.toFloatBits(batchColor.r, batchColor.g, batchColor.b, batchColor.a * layer.getOpacity()); final float[] vertices = this.vertices; TextureRegion region = layer.getTextureRegion(); if (region == null) { return; } final float x = layer.getX(); final float y = layer.getY(); final float x1 = x * unitScale - viewBounds.x * (layer.getParallaxX() - 1); final float y1 = y * unitScale - viewBounds.y * (layer.getParallaxY() - 1); final float x2 = x1 + region.getRegionWidth() * unitScale; final float y2 = y1 + region.getRegionHeight() * unitScale; imageBounds.set(x1, y1, x2 - x1, y2 - y1); if (viewBounds.contains(imageBounds) || viewBounds.overlaps(imageBounds)) { final float u1 = region.getU(); final float v1 = region.getV2(); final float u2 = region.getU2(); final float v2 = region.getV(); vertices[X1] = x1; vertices[Y1] = y1; vertices[C1] = color; vertices[U1] = u1; vertices[V1] = v1; vertices[X2] = x1; vertices[Y2] = y2; vertices[C2] = color; vertices[U2] = u1; vertices[V2] = v2; vertices[X3] = x2; vertices[Y3] = y2; vertices[C3] = color; vertices[U3] = u2; vertices[V3] = v2; vertices[X4] = x2; vertices[Y4] = y1; vertices[C4] = color; vertices[U4] = u2; vertices[V4] = v1; batch.draw(region.getTexture(), vertices, 0, NUM_VERTICES); } } /** Called before the rendering of all layers starts. */ protected void beginRender () { AnimatedTiledMapTile.updateAnimationBaseTime(); batch.begin(); } /** Called after the rendering of all layers ended. */ protected void endRender () { batch.end(); } @Override public void dispose () { if (ownsBatch) { batch.dispose(); } } }
/******************************************************************************* * Copyright 2013 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.maps.tiled.renderers; import static com.badlogic.gdx.graphics.g2d.Batch.C1; import static com.badlogic.gdx.graphics.g2d.Batch.C2; import static com.badlogic.gdx.graphics.g2d.Batch.C3; import static com.badlogic.gdx.graphics.g2d.Batch.C4; import static com.badlogic.gdx.graphics.g2d.Batch.U1; import static com.badlogic.gdx.graphics.g2d.Batch.U2; import static com.badlogic.gdx.graphics.g2d.Batch.U3; import static com.badlogic.gdx.graphics.g2d.Batch.U4; import static com.badlogic.gdx.graphics.g2d.Batch.V1; import static com.badlogic.gdx.graphics.g2d.Batch.V2; import static com.badlogic.gdx.graphics.g2d.Batch.V3; import static com.badlogic.gdx.graphics.g2d.Batch.V4; import static com.badlogic.gdx.graphics.g2d.Batch.X1; import static com.badlogic.gdx.graphics.g2d.Batch.X2; import static com.badlogic.gdx.graphics.g2d.Batch.X3; import static com.badlogic.gdx.graphics.g2d.Batch.X4; import static com.badlogic.gdx.graphics.g2d.Batch.Y1; import static com.badlogic.gdx.graphics.g2d.Batch.Y2; import static com.badlogic.gdx.graphics.g2d.Batch.Y3; import static com.badlogic.gdx.graphics.g2d.Batch.Y4; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.OrthographicCamera; import com.badlogic.gdx.graphics.g2d.Batch; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.maps.MapGroupLayer; import com.badlogic.gdx.maps.MapLayer; import com.badlogic.gdx.maps.MapLayers; import com.badlogic.gdx.maps.MapObject; import com.badlogic.gdx.maps.tiled.TiledMap; import com.badlogic.gdx.maps.tiled.TiledMapImageLayer; import com.badlogic.gdx.maps.tiled.TiledMapRenderer; import com.badlogic.gdx.maps.tiled.TiledMapTileLayer; import com.badlogic.gdx.maps.tiled.tiles.AnimatedTiledMapTile; import com.badlogic.gdx.math.Matrix4; import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.utils.Disposable; public abstract class BatchTiledMapRenderer implements TiledMapRenderer, Disposable { static protected final int NUM_VERTICES = 20; protected TiledMap map; protected float unitScale; protected Batch batch; protected Rectangle viewBounds; protected Rectangle imageBounds = new Rectangle(); protected boolean ownsBatch; protected float vertices[] = new float[NUM_VERTICES]; public TiledMap getMap () { return map; } public void setMap (TiledMap map) { this.map = map; } public float getUnitScale () { return unitScale; } public Batch getBatch () { return batch; } public Rectangle getViewBounds () { return viewBounds; } public BatchTiledMapRenderer (TiledMap map) { this(map, 1.0f); } public BatchTiledMapRenderer (TiledMap map, float unitScale) { this.map = map; this.unitScale = unitScale; this.viewBounds = new Rectangle(); this.batch = new SpriteBatch(); this.ownsBatch = true; } public BatchTiledMapRenderer (TiledMap map, Batch batch) { this(map, 1.0f, batch); } public BatchTiledMapRenderer (TiledMap map, float unitScale, Batch batch) { this.map = map; this.unitScale = unitScale; this.viewBounds = new Rectangle(); this.batch = batch; this.ownsBatch = false; } @Override public void setView (OrthographicCamera camera) { batch.setProjectionMatrix(camera.combined); float width = camera.viewportWidth * camera.zoom; float height = camera.viewportHeight * camera.zoom; float w = width * Math.abs(camera.up.y) + height * Math.abs(camera.up.x); float h = height * Math.abs(camera.up.y) + width * Math.abs(camera.up.x); viewBounds.set(camera.position.x - w / 2, camera.position.y - h / 2, w, h); } @Override public void setView (Matrix4 projection, float x, float y, float width, float height) { batch.setProjectionMatrix(projection); viewBounds.set(x, y, width, height); } @Override public void render () { beginRender(); for (MapLayer layer : map.getLayers()) { renderMapLayer(layer); } endRender(); } @Override public void render (int[] layers) { beginRender(); for (int layerIdx : layers) { MapLayer layer = map.getLayers().get(layerIdx); renderMapLayer(layer); } endRender(); } protected void renderMapLayer (MapLayer layer) { if (!layer.isVisible()) return; if (layer instanceof MapGroupLayer) { MapLayers childLayers = ((MapGroupLayer)layer).getLayers(); for (int i = 0; i < childLayers.size(); i++) { MapLayer childLayer = childLayers.get(i); if (!childLayer.isVisible()) continue; renderMapLayer(childLayer); } } else { if (layer instanceof TiledMapTileLayer) { renderTileLayer((TiledMapTileLayer)layer); } else if (layer instanceof TiledMapImageLayer) { renderImageLayer((TiledMapImageLayer)layer); } else { renderObjects(layer); } } } @Override public void renderObjects (MapLayer layer) { for (MapObject object : layer.getObjects()) { renderObject(object); } } @Override public void renderObject (MapObject object) { } @Override public void renderImageLayer (TiledMapImageLayer layer) { final Color batchColor = batch.getColor(); final float color = Color.toFloatBits(batchColor.r, batchColor.g, batchColor.b, batchColor.a * layer.getOpacity()); final float[] vertices = this.vertices; TextureRegion region = layer.getTextureRegion(); if (region == null) { return; } final float x = layer.getX(); final float y = layer.getY(); final float x1 = x * unitScale - viewBounds.x * (layer.getParallaxX() - 1); final float y1 = y * unitScale - viewBounds.y * (layer.getParallaxY() - 1); final float x2 = x1 + region.getRegionWidth() * unitScale; final float y2 = y1 + region.getRegionHeight() * unitScale; imageBounds.set(x1, y1, x2 - x1, y2 - y1); if (viewBounds.contains(imageBounds) || viewBounds.overlaps(imageBounds)) { final float u1 = region.getU(); final float v1 = region.getV2(); final float u2 = region.getU2(); final float v2 = region.getV(); vertices[X1] = x1; vertices[Y1] = y1; vertices[C1] = color; vertices[U1] = u1; vertices[V1] = v1; vertices[X2] = x1; vertices[Y2] = y2; vertices[C2] = color; vertices[U2] = u1; vertices[V2] = v2; vertices[X3] = x2; vertices[Y3] = y2; vertices[C3] = color; vertices[U3] = u2; vertices[V3] = v2; vertices[X4] = x2; vertices[Y4] = y1; vertices[C4] = color; vertices[U4] = u2; vertices[V4] = v1; batch.draw(region.getTexture(), vertices, 0, NUM_VERTICES); } } /** Called before the rendering of all layers starts. */ protected void beginRender () { AnimatedTiledMapTile.updateAnimationBaseTime(); batch.begin(); } /** Called after the rendering of all layers ended. */ protected void endRender () { batch.end(); } @Override public void dispose () { if (ownsBatch) { batch.dispose(); } } }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./extensions/gdx-box2d/gdx-box2d-gwt/src/com/badlogic/gdx/physics/box2d/gwt/emu/org/jbox2d/common/OBBViewportTransform.java
/******************************************************************************* * Copyright (c) 2013, Daniel Murphy * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. ******************************************************************************/ package org.jbox2d.common; /** Orientated bounding box viewport transform * * @author Daniel Murphy */ public class OBBViewportTransform implements IViewportTransform { public static class OBB { public final Mat22 R = new Mat22(); public final Vec2 center = new Vec2(); public final Vec2 extents = new Vec2(); } protected final OBB box = new OBB(); private boolean yFlip = false; private final Mat22 yFlipMat = new Mat22(1, 0, 0, -1); public OBBViewportTransform () { box.R.setIdentity(); } public void set (OBBViewportTransform vpt) { box.center.set(vpt.box.center); box.extents.set(vpt.box.extents); box.R.set(vpt.box.R); yFlip = vpt.yFlip; } public void setCamera (float x, float y, float scale) { box.center.set(x, y); Mat22.createScaleTransform(scale, box.R); } public Vec2 getExtents () { return box.extents; } @Override public Mat22 getMat22Representation () { return box.R; } public void setExtents (Vec2 argExtents) { box.extents.set(argExtents); } public void setExtents (float halfWidth, float halfHeight) { box.extents.set(halfWidth, halfHeight); } public Vec2 getCenter () { return box.center; } public void setCenter (Vec2 argPos) { box.center.set(argPos); } public void setCenter (float x, float y) { box.center.set(x, y); } /** Gets the transform of the viewport, transforms around the center. Not a copy. */ public Mat22 getTransform () { return box.R; } /** Sets the transform of the viewport. Transforms about the center. */ public void setTransform (Mat22 transform) { box.R.set(transform); } /** Multiplies the obb transform by the given transform */ @Override public void mulByTransform (Mat22 transform) { box.R.mulLocal(transform); } public boolean isYFlip () { return yFlip; } public void setYFlip (boolean yFlip) { this.yFlip = yFlip; } private final Mat22 inv = new Mat22(); public void getScreenVectorToWorld (Vec2 screen, Vec2 world) { box.R.invertToOut(inv); inv.mulToOut(screen, world); if (yFlip) { yFlipMat.mulToOut(world, world); } } public void getWorldVectorToScreen (Vec2 world, Vec2 screen) { box.R.mulToOut(world, screen); if (yFlip) { yFlipMat.mulToOut(screen, screen); } } public void getWorldToScreen (Vec2 world, Vec2 screen) { screen.x = world.x - box.center.x; screen.y = world.y - box.center.y; box.R.mulToOut(screen, screen); if (yFlip) { yFlipMat.mulToOut(screen, screen); } screen.x += box.extents.x; screen.y += box.extents.y; } private final Mat22 inv2 = new Mat22(); public void getScreenToWorld (Vec2 screen, Vec2 world) { world.x = screen.x - box.extents.x; world.y = screen.y - box.extents.y; if (yFlip) { yFlipMat.mulToOut(world, world); } box.R.invertToOut(inv2); inv2.mulToOut(world, world); world.x += box.center.x; world.y += box.center.y; } }
/******************************************************************************* * Copyright (c) 2013, Daniel Murphy * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. ******************************************************************************/ package org.jbox2d.common; /** Orientated bounding box viewport transform * * @author Daniel Murphy */ public class OBBViewportTransform implements IViewportTransform { public static class OBB { public final Mat22 R = new Mat22(); public final Vec2 center = new Vec2(); public final Vec2 extents = new Vec2(); } protected final OBB box = new OBB(); private boolean yFlip = false; private final Mat22 yFlipMat = new Mat22(1, 0, 0, -1); public OBBViewportTransform () { box.R.setIdentity(); } public void set (OBBViewportTransform vpt) { box.center.set(vpt.box.center); box.extents.set(vpt.box.extents); box.R.set(vpt.box.R); yFlip = vpt.yFlip; } public void setCamera (float x, float y, float scale) { box.center.set(x, y); Mat22.createScaleTransform(scale, box.R); } public Vec2 getExtents () { return box.extents; } @Override public Mat22 getMat22Representation () { return box.R; } public void setExtents (Vec2 argExtents) { box.extents.set(argExtents); } public void setExtents (float halfWidth, float halfHeight) { box.extents.set(halfWidth, halfHeight); } public Vec2 getCenter () { return box.center; } public void setCenter (Vec2 argPos) { box.center.set(argPos); } public void setCenter (float x, float y) { box.center.set(x, y); } /** Gets the transform of the viewport, transforms around the center. Not a copy. */ public Mat22 getTransform () { return box.R; } /** Sets the transform of the viewport. Transforms about the center. */ public void setTransform (Mat22 transform) { box.R.set(transform); } /** Multiplies the obb transform by the given transform */ @Override public void mulByTransform (Mat22 transform) { box.R.mulLocal(transform); } public boolean isYFlip () { return yFlip; } public void setYFlip (boolean yFlip) { this.yFlip = yFlip; } private final Mat22 inv = new Mat22(); public void getScreenVectorToWorld (Vec2 screen, Vec2 world) { box.R.invertToOut(inv); inv.mulToOut(screen, world); if (yFlip) { yFlipMat.mulToOut(world, world); } } public void getWorldVectorToScreen (Vec2 world, Vec2 screen) { box.R.mulToOut(world, screen); if (yFlip) { yFlipMat.mulToOut(screen, screen); } } public void getWorldToScreen (Vec2 world, Vec2 screen) { screen.x = world.x - box.center.x; screen.y = world.y - box.center.y; box.R.mulToOut(screen, screen); if (yFlip) { yFlipMat.mulToOut(screen, screen); } screen.x += box.extents.x; screen.y += box.extents.y; } private final Mat22 inv2 = new Mat22(); public void getScreenToWorld (Vec2 screen, Vec2 world) { world.x = screen.x - box.extents.x; world.y = screen.y - box.extents.y; if (yFlip) { yFlipMat.mulToOut(world, world); } box.R.invertToOut(inv2); inv2.mulToOut(world, world); world.x += box.center.x; world.y += box.center.y; } }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./extensions/gdx-bullet/jni/swig-src/collision/com/badlogic/gdx/physics/bullet/collision/btTetrahedronShapeEx.java
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.collision; import com.badlogic.gdx.physics.bullet.linearmath.*; import com.badlogic.gdx.math.Vector3; public class btTetrahedronShapeEx extends btBU_Simplex1to4 { private long swigCPtr; protected btTetrahedronShapeEx (final String className, long cPtr, boolean cMemoryOwn) { super(className, CollisionJNI.btTetrahedronShapeEx_SWIGUpcast(cPtr), cMemoryOwn); swigCPtr = cPtr; } /** Construct a new btTetrahedronShapeEx, normally you should not need this constructor it's intended for low-level usage. */ public btTetrahedronShapeEx (long cPtr, boolean cMemoryOwn) { this("btTetrahedronShapeEx", cPtr, cMemoryOwn); construct(); } @Override protected void reset (long cPtr, boolean cMemoryOwn) { if (!destroyed) destroy(); super.reset(CollisionJNI.btTetrahedronShapeEx_SWIGUpcast(swigCPtr = cPtr), cMemoryOwn); } public static long getCPtr (btTetrahedronShapeEx obj) { return (obj == null) ? 0 : obj.swigCPtr; } @Override protected void finalize () throws Throwable { if (!destroyed) destroy(); super.finalize(); } @Override protected synchronized void delete () { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; CollisionJNI.delete_btTetrahedronShapeEx(swigCPtr); } swigCPtr = 0; } super.delete(); } public btTetrahedronShapeEx () { this(CollisionJNI.new_btTetrahedronShapeEx(), true); } public void setVertices (Vector3 v0, Vector3 v1, Vector3 v2, Vector3 v3) { CollisionJNI.btTetrahedronShapeEx_setVertices(swigCPtr, this, v0, v1, v2, v3); } }
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.collision; import com.badlogic.gdx.physics.bullet.linearmath.*; import com.badlogic.gdx.math.Vector3; public class btTetrahedronShapeEx extends btBU_Simplex1to4 { private long swigCPtr; protected btTetrahedronShapeEx (final String className, long cPtr, boolean cMemoryOwn) { super(className, CollisionJNI.btTetrahedronShapeEx_SWIGUpcast(cPtr), cMemoryOwn); swigCPtr = cPtr; } /** Construct a new btTetrahedronShapeEx, normally you should not need this constructor it's intended for low-level usage. */ public btTetrahedronShapeEx (long cPtr, boolean cMemoryOwn) { this("btTetrahedronShapeEx", cPtr, cMemoryOwn); construct(); } @Override protected void reset (long cPtr, boolean cMemoryOwn) { if (!destroyed) destroy(); super.reset(CollisionJNI.btTetrahedronShapeEx_SWIGUpcast(swigCPtr = cPtr), cMemoryOwn); } public static long getCPtr (btTetrahedronShapeEx obj) { return (obj == null) ? 0 : obj.swigCPtr; } @Override protected void finalize () throws Throwable { if (!destroyed) destroy(); super.finalize(); } @Override protected synchronized void delete () { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; CollisionJNI.delete_btTetrahedronShapeEx(swigCPtr); } swigCPtr = 0; } super.delete(); } public btTetrahedronShapeEx () { this(CollisionJNI.new_btTetrahedronShapeEx(), true); } public void setVertices (Vector3 v0, Vector3 v1, Vector3 v2, Vector3 v3) { CollisionJNI.btTetrahedronShapeEx_setVertices(swigCPtr, this, v0, v1, v2, v3); } }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./backends/gdx-backend-headless/src/com/badlogic/gdx/backends/headless/HeadlessNativesLoader.java
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.backends.headless; import com.badlogic.gdx.utils.GdxNativesLoader; public class HeadlessNativesLoader { public static void load () { GdxNativesLoader.load(); } }
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.backends.headless; import com.badlogic.gdx.utils.GdxNativesLoader; public class HeadlessNativesLoader { public static void load () { GdxNativesLoader.load(); } }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./extensions/gdx-box2d/gdx-box2d/jni/Box2D/Dynamics/Contacts/b2PolygonContact.h
/* * Copyright (c) 2006-2009 Erin Catto http://www.box2d.org * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages * arising from the use of this software. * Permission is granted to anyone to use this software for any purpose, * including commercial applications, and to alter it and redistribute it * freely, subject to the following restrictions: * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software * in a product, an acknowledgment in the product documentation would be * appreciated but is not required. * 2. Altered source versions must be plainly marked as such, and must not be * misrepresented as being the original software. * 3. This notice may not be removed or altered from any source distribution. */ #ifndef B2_POLYGON_CONTACT_H #define B2_POLYGON_CONTACT_H #include <Box2D/Dynamics/Contacts/b2Contact.h> class b2BlockAllocator; class b2PolygonContact : public b2Contact { public: static b2Contact* Create( b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator); static void Destroy(b2Contact* contact, b2BlockAllocator* allocator); b2PolygonContact(b2Fixture* fixtureA, b2Fixture* fixtureB); ~b2PolygonContact() {} void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB); }; #endif
/* * Copyright (c) 2006-2009 Erin Catto http://www.box2d.org * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages * arising from the use of this software. * Permission is granted to anyone to use this software for any purpose, * including commercial applications, and to alter it and redistribute it * freely, subject to the following restrictions: * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software * in a product, an acknowledgment in the product documentation would be * appreciated but is not required. * 2. Altered source versions must be plainly marked as such, and must not be * misrepresented as being the original software. * 3. This notice may not be removed or altered from any source distribution. */ #ifndef B2_POLYGON_CONTACT_H #define B2_POLYGON_CONTACT_H #include <Box2D/Dynamics/Contacts/b2Contact.h> class b2BlockAllocator; class b2PolygonContact : public b2Contact { public: static b2Contact* Create( b2Fixture* fixtureA, int32 indexA, b2Fixture* fixtureB, int32 indexB, b2BlockAllocator* allocator); static void Destroy(b2Contact* contact, b2BlockAllocator* allocator); b2PolygonContact(b2Fixture* fixtureA, b2Fixture* fixtureB); ~b2PolygonContact() {} void Evaluate(b2Manifold* manifold, const b2Transform& xfA, const b2Transform& xfB); }; #endif
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./extensions/gdx-bullet/jni/src/bullet/BulletCollision/CollisionShapes/btOptimizedBvh.h
/* Bullet Continuous Collision Detection and Physics Library Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ ///Contains contributions from Disney Studio's #ifndef BT_OPTIMIZED_BVH_H #define BT_OPTIMIZED_BVH_H #include "BulletCollision/BroadphaseCollision/btQuantizedBvh.h" class btStridingMeshInterface; ///The btOptimizedBvh extends the btQuantizedBvh to create AABB tree for triangle meshes, through the btStridingMeshInterface. ATTRIBUTE_ALIGNED16(class) btOptimizedBvh : public btQuantizedBvh { public: BT_DECLARE_ALIGNED_ALLOCATOR(); protected: public: btOptimizedBvh(); virtual ~btOptimizedBvh(); void build(btStridingMeshInterface* triangles,bool useQuantizedAabbCompression, const btVector3& bvhAabbMin, const btVector3& bvhAabbMax); void refit(btStridingMeshInterface* triangles,const btVector3& aabbMin,const btVector3& aabbMax); void refitPartial(btStridingMeshInterface* triangles,const btVector3& aabbMin, const btVector3& aabbMax); void updateBvhNodes(btStridingMeshInterface* meshInterface,int firstNode,int endNode,int index); /// Data buffer MUST be 16 byte aligned virtual bool serializeInPlace(void *o_alignedDataBuffer, unsigned i_dataBufferSize, bool i_swapEndian) const { return btQuantizedBvh::serialize(o_alignedDataBuffer,i_dataBufferSize,i_swapEndian); } ///deSerializeInPlace loads and initializes a BVH from a buffer in memory 'in place' static btOptimizedBvh *deSerializeInPlace(void *i_alignedDataBuffer, unsigned int i_dataBufferSize, bool i_swapEndian); }; #endif //BT_OPTIMIZED_BVH_H
/* Bullet Continuous Collision Detection and Physics Library Copyright (c) 2003-2009 Erwin Coumans http://bulletphysics.org This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ ///Contains contributions from Disney Studio's #ifndef BT_OPTIMIZED_BVH_H #define BT_OPTIMIZED_BVH_H #include "BulletCollision/BroadphaseCollision/btQuantizedBvh.h" class btStridingMeshInterface; ///The btOptimizedBvh extends the btQuantizedBvh to create AABB tree for triangle meshes, through the btStridingMeshInterface. ATTRIBUTE_ALIGNED16(class) btOptimizedBvh : public btQuantizedBvh { public: BT_DECLARE_ALIGNED_ALLOCATOR(); protected: public: btOptimizedBvh(); virtual ~btOptimizedBvh(); void build(btStridingMeshInterface* triangles,bool useQuantizedAabbCompression, const btVector3& bvhAabbMin, const btVector3& bvhAabbMax); void refit(btStridingMeshInterface* triangles,const btVector3& aabbMin,const btVector3& aabbMax); void refitPartial(btStridingMeshInterface* triangles,const btVector3& aabbMin, const btVector3& aabbMax); void updateBvhNodes(btStridingMeshInterface* meshInterface,int firstNode,int endNode,int index); /// Data buffer MUST be 16 byte aligned virtual bool serializeInPlace(void *o_alignedDataBuffer, unsigned i_dataBufferSize, bool i_swapEndian) const { return btQuantizedBvh::serialize(o_alignedDataBuffer,i_dataBufferSize,i_swapEndian); } ///deSerializeInPlace loads and initializes a BVH from a buffer in memory 'in place' static btOptimizedBvh *deSerializeInPlace(void *i_alignedDataBuffer, unsigned int i_dataBufferSize, bool i_swapEndian); }; #endif //BT_OPTIMIZED_BVH_H
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./backends/gdx-backends-gwt/src/com/badlogic/gdx/backends/gwt/emu/com/badlogic/gdx/scenes/scene2d/utils/UIUtils.java
package com.badlogic.gdx.scenes.scene2d.utils; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Input.Buttons; import com.badlogic.gdx.Input.Keys; import com.google.gwt.user.client.Window.Navigator; public class UIUtils { static public boolean isAndroid = Navigator.getPlatform().contains("Android"); static public boolean isMac = Navigator.getPlatform().contains("Mac"); static public boolean isWindows = Navigator.getPlatform().contains("Win"); static public boolean isLinux = Navigator.getPlatform().contains("Linux") || Navigator.getPlatform().contains("FreeBSD"); static public boolean isIos = Navigator.getPlatform().contains("iPhone") || Navigator.getPlatform().contains("iPod") || Navigator.getPlatform().contains("iPad"); static public boolean left () { return Gdx.input.isButtonPressed(Buttons.LEFT); } static public boolean left (int button) { return button == Buttons.LEFT; } static public boolean right () { return Gdx.input.isButtonPressed(Buttons.RIGHT); } static public boolean right (int button) { return button == Buttons.RIGHT; } static public boolean middle () { return Gdx.input.isButtonPressed(Buttons.MIDDLE); } static public boolean middle (int button) { return button == Buttons.MIDDLE; } static public boolean shift () { return Gdx.input.isKeyPressed(Keys.SHIFT_LEFT) || Gdx.input.isKeyPressed(Keys.SHIFT_RIGHT); } static public boolean shift (int keycode) { return keycode == Keys.SHIFT_LEFT || keycode == Keys.SHIFT_RIGHT; } static public boolean ctrl () { if (isMac) return Gdx.input.isKeyPressed(Keys.SYM); else return Gdx.input.isKeyPressed(Keys.CONTROL_LEFT) || Gdx.input.isKeyPressed(Keys.CONTROL_RIGHT); } static public boolean ctrl (int keycode) { if (isMac) return keycode == Keys.SYM; else return keycode == Keys.CONTROL_LEFT || keycode == Keys.CONTROL_RIGHT; } static public boolean alt () { return Gdx.input.isKeyPressed(Keys.ALT_LEFT) || Gdx.input.isKeyPressed(Keys.ALT_RIGHT); } static public boolean alt (int keycode) { return keycode == Keys.ALT_LEFT || keycode == Keys.ALT_RIGHT; } }
package com.badlogic.gdx.scenes.scene2d.utils; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Input.Buttons; import com.badlogic.gdx.Input.Keys; import com.google.gwt.user.client.Window.Navigator; public class UIUtils { static public boolean isAndroid = Navigator.getPlatform().contains("Android"); static public boolean isMac = Navigator.getPlatform().contains("Mac"); static public boolean isWindows = Navigator.getPlatform().contains("Win"); static public boolean isLinux = Navigator.getPlatform().contains("Linux") || Navigator.getPlatform().contains("FreeBSD"); static public boolean isIos = Navigator.getPlatform().contains("iPhone") || Navigator.getPlatform().contains("iPod") || Navigator.getPlatform().contains("iPad"); static public boolean left () { return Gdx.input.isButtonPressed(Buttons.LEFT); } static public boolean left (int button) { return button == Buttons.LEFT; } static public boolean right () { return Gdx.input.isButtonPressed(Buttons.RIGHT); } static public boolean right (int button) { return button == Buttons.RIGHT; } static public boolean middle () { return Gdx.input.isButtonPressed(Buttons.MIDDLE); } static public boolean middle (int button) { return button == Buttons.MIDDLE; } static public boolean shift () { return Gdx.input.isKeyPressed(Keys.SHIFT_LEFT) || Gdx.input.isKeyPressed(Keys.SHIFT_RIGHT); } static public boolean shift (int keycode) { return keycode == Keys.SHIFT_LEFT || keycode == Keys.SHIFT_RIGHT; } static public boolean ctrl () { if (isMac) return Gdx.input.isKeyPressed(Keys.SYM); else return Gdx.input.isKeyPressed(Keys.CONTROL_LEFT) || Gdx.input.isKeyPressed(Keys.CONTROL_RIGHT); } static public boolean ctrl (int keycode) { if (isMac) return keycode == Keys.SYM; else return keycode == Keys.CONTROL_LEFT || keycode == Keys.CONTROL_RIGHT; } static public boolean alt () { return Gdx.input.isKeyPressed(Keys.ALT_LEFT) || Gdx.input.isKeyPressed(Keys.ALT_RIGHT); } static public boolean alt (int keycode) { return keycode == Keys.ALT_LEFT || keycode == Keys.ALT_RIGHT; } }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./gdx/src/com/badlogic/gdx/utils/SortedIntList.java
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.utils; /** A sorted double linked list which uses ints for indexing * * @param <E> */ public class SortedIntList<E> implements Iterable<SortedIntList.Node<E>> { private NodePool<E> nodePool = new NodePool<E>(); // avoid allocating nodes private transient Iterator iterator; int size = 0; Node<E> first; /** Creates an ascending list */ public SortedIntList () { } /** Inserts an element into the list at the given index * * @param index Index of the element * @param value Element to insert * @return Element replaced by newly inserted element, null if nothing was replaced */ public @Null E insert (int index, E value) { if (first != null) { Node<E> c = first; // iterate to the right until we can't move any further because the next number is bigger than index while (c.n != null && c.n.index <= index) { c = c.n; } // add one to the right if (index > c.index) { c.n = nodePool.obtain(c, c.n, value, index); if (c.n.n != null) { c.n.n.p = c.n; } size++; } // the new element is smaller than every other element else if (index < c.index) { Node<E> newFirst = nodePool.obtain(null, first, value, index); first.p = newFirst; first = newFirst; size++; } // that element already exists so swap the value else { c.value = value; } } else { first = nodePool.obtain(null, null, value, index); size++; } return null; } /** Retrieves an element at a given index * * @param index Index of the element to retrieve * @return Matching element, null otherwise */ public E get (int index) { E match = null; if (first != null) { Node<E> c = first; while (c.n != null && c.index < index) { c = c.n; } if (c.index == index) { match = c.value; } } return match; } /** Clears list */ public void clear () { for (; first != null; first = first.n) { nodePool.free(first); } size = 0; } /** @return size of list equal to elements contained in it */ public int size () { return size; } /** Returns true if the list has one or more items. */ public boolean notEmpty () { return size > 0; } /** Returns true if the list is empty. */ public boolean isEmpty () { return size == 0; } /** Returns an iterator to traverse the list. * <p> * If {@link Collections#allocateIterators} is false, the same iterator instance is returned each time this method is called. * Use the {@link Iterator} constructor for nested or multithreaded iteration. */ public java.util.Iterator<Node<E>> iterator () { if (Collections.allocateIterators) return new Iterator(); if (iterator == null) return iterator = new Iterator(); return iterator.reset(); } public class Iterator implements java.util.Iterator<Node<E>> { private Node<E> position; private Node<E> previousPosition; public Iterator () { reset(); } @Override public boolean hasNext () { return position != null; } @Override public Node<E> next () { previousPosition = position; position = position.n; return previousPosition; } @Override public void remove () { // the contract specifies to remove the last returned element, if nothing was returned yet assumably do nothing if (previousPosition != null) { // if we are at the second element set it as the first element if (previousPosition == first) { first = position; } // else remove last returned element by changing the chain else { previousPosition.p.n = position; if (position != null) { position.p = previousPosition.p; } } size--; } } public Iterator reset () { position = first; previousPosition = null; return this; } } public static class Node<E> { /** Node previous to this */ protected Node<E> p; /** Node next to this */ protected Node<E> n; /** Value held */ public E value; /** Index value in list */ public int index; } static class NodePool<E> extends Pool<Node<E>> { @Override protected Node<E> newObject () { return new Node<E>(); } public Node<E> obtain (Node<E> p, Node<E> n, E value, int index) { Node<E> newNode = super.obtain(); newNode.p = p; newNode.n = n; newNode.value = value; newNode.index = index; return newNode; } } }
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.utils; /** A sorted double linked list which uses ints for indexing * * @param <E> */ public class SortedIntList<E> implements Iterable<SortedIntList.Node<E>> { private NodePool<E> nodePool = new NodePool<E>(); // avoid allocating nodes private transient Iterator iterator; int size = 0; Node<E> first; /** Creates an ascending list */ public SortedIntList () { } /** Inserts an element into the list at the given index * * @param index Index of the element * @param value Element to insert * @return Element replaced by newly inserted element, null if nothing was replaced */ public @Null E insert (int index, E value) { if (first != null) { Node<E> c = first; // iterate to the right until we can't move any further because the next number is bigger than index while (c.n != null && c.n.index <= index) { c = c.n; } // add one to the right if (index > c.index) { c.n = nodePool.obtain(c, c.n, value, index); if (c.n.n != null) { c.n.n.p = c.n; } size++; } // the new element is smaller than every other element else if (index < c.index) { Node<E> newFirst = nodePool.obtain(null, first, value, index); first.p = newFirst; first = newFirst; size++; } // that element already exists so swap the value else { c.value = value; } } else { first = nodePool.obtain(null, null, value, index); size++; } return null; } /** Retrieves an element at a given index * * @param index Index of the element to retrieve * @return Matching element, null otherwise */ public E get (int index) { E match = null; if (first != null) { Node<E> c = first; while (c.n != null && c.index < index) { c = c.n; } if (c.index == index) { match = c.value; } } return match; } /** Clears list */ public void clear () { for (; first != null; first = first.n) { nodePool.free(first); } size = 0; } /** @return size of list equal to elements contained in it */ public int size () { return size; } /** Returns true if the list has one or more items. */ public boolean notEmpty () { return size > 0; } /** Returns true if the list is empty. */ public boolean isEmpty () { return size == 0; } /** Returns an iterator to traverse the list. * <p> * If {@link Collections#allocateIterators} is false, the same iterator instance is returned each time this method is called. * Use the {@link Iterator} constructor for nested or multithreaded iteration. */ public java.util.Iterator<Node<E>> iterator () { if (Collections.allocateIterators) return new Iterator(); if (iterator == null) return iterator = new Iterator(); return iterator.reset(); } public class Iterator implements java.util.Iterator<Node<E>> { private Node<E> position; private Node<E> previousPosition; public Iterator () { reset(); } @Override public boolean hasNext () { return position != null; } @Override public Node<E> next () { previousPosition = position; position = position.n; return previousPosition; } @Override public void remove () { // the contract specifies to remove the last returned element, if nothing was returned yet assumably do nothing if (previousPosition != null) { // if we are at the second element set it as the first element if (previousPosition == first) { first = position; } // else remove last returned element by changing the chain else { previousPosition.p.n = position; if (position != null) { position.p = previousPosition.p; } } size--; } } public Iterator reset () { position = first; previousPosition = null; return this; } } public static class Node<E> { /** Node previous to this */ protected Node<E> p; /** Node next to this */ protected Node<E> n; /** Value held */ public E value; /** Index value in list */ public int index; } static class NodePool<E> extends Pool<Node<E>> { @Override protected Node<E> newObject () { return new Node<E>(); } public Node<E> obtain (Node<E> p, Node<E> n, E value, int index) { Node<E> newNode = super.obtain(); newNode.p = p; newNode.n = n; newNode.value = value; newNode.index = index; return newNode; } } }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./gdx/src/com/badlogic/gdx/assets/loaders/resolvers/ClasspathFileHandleResolver.java
/******************************************************************************* * Copyright 2015 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.assets.loaders.resolvers; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.assets.loaders.FileHandleResolver; import com.badlogic.gdx.files.FileHandle; public class ClasspathFileHandleResolver implements FileHandleResolver { @Override public FileHandle resolve (String fileName) { return Gdx.files.classpath(fileName); } }
/******************************************************************************* * Copyright 2015 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.assets.loaders.resolvers; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.assets.loaders.FileHandleResolver; import com.badlogic.gdx.files.FileHandle; public class ClasspathFileHandleResolver implements FileHandleResolver { @Override public FileHandle resolve (String fileName) { return Gdx.files.classpath(fileName); } }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./extensions/gdx-bullet/jni/swig-src/collision/com/badlogic/gdx/physics/bullet/collision/btSubSimplexClosestResult.java
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.collision; import com.badlogic.gdx.physics.bullet.BulletBase; import com.badlogic.gdx.physics.bullet.linearmath.*; public class btSubSimplexClosestResult extends BulletBase { private long swigCPtr; protected btSubSimplexClosestResult (final String className, long cPtr, boolean cMemoryOwn) { super(className, cPtr, cMemoryOwn); swigCPtr = cPtr; } /** Construct a new btSubSimplexClosestResult, normally you should not need this constructor it's intended for low-level * usage. */ public btSubSimplexClosestResult (long cPtr, boolean cMemoryOwn) { this("btSubSimplexClosestResult", cPtr, cMemoryOwn); construct(); } @Override protected void reset (long cPtr, boolean cMemoryOwn) { if (!destroyed) destroy(); super.reset(swigCPtr = cPtr, cMemoryOwn); } public static long getCPtr (btSubSimplexClosestResult obj) { return (obj == null) ? 0 : obj.swigCPtr; } @Override protected void finalize () throws Throwable { if (!destroyed) destroy(); super.finalize(); } @Override protected synchronized void delete () { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; CollisionJNI.delete_btSubSimplexClosestResult(swigCPtr); } swigCPtr = 0; } super.delete(); } public void setClosestPointOnSimplex (btVector3 value) { CollisionJNI.btSubSimplexClosestResult_closestPointOnSimplex_set(swigCPtr, this, btVector3.getCPtr(value), value); } public btVector3 getClosestPointOnSimplex () { long cPtr = CollisionJNI.btSubSimplexClosestResult_closestPointOnSimplex_get(swigCPtr, this); return (cPtr == 0) ? null : new btVector3(cPtr, false); } public void setUsedVertices (btUsageBitfield value) { CollisionJNI.btSubSimplexClosestResult_usedVertices_set(swigCPtr, this, btUsageBitfield.getCPtr(value), value); } public btUsageBitfield getUsedVertices () { long cPtr = CollisionJNI.btSubSimplexClosestResult_usedVertices_get(swigCPtr, this); return (cPtr == 0) ? null : new btUsageBitfield(cPtr, false); } public void setBarycentricCoords (float[] value) { CollisionJNI.btSubSimplexClosestResult_barycentricCoords_set(swigCPtr, this, value); } public float[] getBarycentricCoords () { return CollisionJNI.btSubSimplexClosestResult_barycentricCoords_get(swigCPtr, this); } public void setDegenerate (boolean value) { CollisionJNI.btSubSimplexClosestResult_degenerate_set(swigCPtr, this, value); } public boolean getDegenerate () { return CollisionJNI.btSubSimplexClosestResult_degenerate_get(swigCPtr, this); } public void reset () { CollisionJNI.btSubSimplexClosestResult_reset(swigCPtr, this); } public boolean isValid () { return CollisionJNI.btSubSimplexClosestResult_isValid(swigCPtr, this); } public void setBarycentricCoordinates (float a, float b, float c, float d) { CollisionJNI.btSubSimplexClosestResult_setBarycentricCoordinates__SWIG_0(swigCPtr, this, a, b, c, d); } public void setBarycentricCoordinates (float a, float b, float c) { CollisionJNI.btSubSimplexClosestResult_setBarycentricCoordinates__SWIG_1(swigCPtr, this, a, b, c); } public void setBarycentricCoordinates (float a, float b) { CollisionJNI.btSubSimplexClosestResult_setBarycentricCoordinates__SWIG_2(swigCPtr, this, a, b); } public void setBarycentricCoordinates (float a) { CollisionJNI.btSubSimplexClosestResult_setBarycentricCoordinates__SWIG_3(swigCPtr, this, a); } public void setBarycentricCoordinates () { CollisionJNI.btSubSimplexClosestResult_setBarycentricCoordinates__SWIG_4(swigCPtr, this); } public btSubSimplexClosestResult () { this(CollisionJNI.new_btSubSimplexClosestResult(), true); } }
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.collision; import com.badlogic.gdx.physics.bullet.BulletBase; import com.badlogic.gdx.physics.bullet.linearmath.*; public class btSubSimplexClosestResult extends BulletBase { private long swigCPtr; protected btSubSimplexClosestResult (final String className, long cPtr, boolean cMemoryOwn) { super(className, cPtr, cMemoryOwn); swigCPtr = cPtr; } /** Construct a new btSubSimplexClosestResult, normally you should not need this constructor it's intended for low-level * usage. */ public btSubSimplexClosestResult (long cPtr, boolean cMemoryOwn) { this("btSubSimplexClosestResult", cPtr, cMemoryOwn); construct(); } @Override protected void reset (long cPtr, boolean cMemoryOwn) { if (!destroyed) destroy(); super.reset(swigCPtr = cPtr, cMemoryOwn); } public static long getCPtr (btSubSimplexClosestResult obj) { return (obj == null) ? 0 : obj.swigCPtr; } @Override protected void finalize () throws Throwable { if (!destroyed) destroy(); super.finalize(); } @Override protected synchronized void delete () { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; CollisionJNI.delete_btSubSimplexClosestResult(swigCPtr); } swigCPtr = 0; } super.delete(); } public void setClosestPointOnSimplex (btVector3 value) { CollisionJNI.btSubSimplexClosestResult_closestPointOnSimplex_set(swigCPtr, this, btVector3.getCPtr(value), value); } public btVector3 getClosestPointOnSimplex () { long cPtr = CollisionJNI.btSubSimplexClosestResult_closestPointOnSimplex_get(swigCPtr, this); return (cPtr == 0) ? null : new btVector3(cPtr, false); } public void setUsedVertices (btUsageBitfield value) { CollisionJNI.btSubSimplexClosestResult_usedVertices_set(swigCPtr, this, btUsageBitfield.getCPtr(value), value); } public btUsageBitfield getUsedVertices () { long cPtr = CollisionJNI.btSubSimplexClosestResult_usedVertices_get(swigCPtr, this); return (cPtr == 0) ? null : new btUsageBitfield(cPtr, false); } public void setBarycentricCoords (float[] value) { CollisionJNI.btSubSimplexClosestResult_barycentricCoords_set(swigCPtr, this, value); } public float[] getBarycentricCoords () { return CollisionJNI.btSubSimplexClosestResult_barycentricCoords_get(swigCPtr, this); } public void setDegenerate (boolean value) { CollisionJNI.btSubSimplexClosestResult_degenerate_set(swigCPtr, this, value); } public boolean getDegenerate () { return CollisionJNI.btSubSimplexClosestResult_degenerate_get(swigCPtr, this); } public void reset () { CollisionJNI.btSubSimplexClosestResult_reset(swigCPtr, this); } public boolean isValid () { return CollisionJNI.btSubSimplexClosestResult_isValid(swigCPtr, this); } public void setBarycentricCoordinates (float a, float b, float c, float d) { CollisionJNI.btSubSimplexClosestResult_setBarycentricCoordinates__SWIG_0(swigCPtr, this, a, b, c, d); } public void setBarycentricCoordinates (float a, float b, float c) { CollisionJNI.btSubSimplexClosestResult_setBarycentricCoordinates__SWIG_1(swigCPtr, this, a, b, c); } public void setBarycentricCoordinates (float a, float b) { CollisionJNI.btSubSimplexClosestResult_setBarycentricCoordinates__SWIG_2(swigCPtr, this, a, b); } public void setBarycentricCoordinates (float a) { CollisionJNI.btSubSimplexClosestResult_setBarycentricCoordinates__SWIG_3(swigCPtr, this, a); } public void setBarycentricCoordinates () { CollisionJNI.btSubSimplexClosestResult_setBarycentricCoordinates__SWIG_4(swigCPtr, this); } public btSubSimplexClosestResult () { this(CollisionJNI.new_btSubSimplexClosestResult(), true); } }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./gdx/src/com/badlogic/gdx/utils/PerformanceCounter.java
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.utils; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.math.FloatCounter; import com.badlogic.gdx.math.MathUtils; /** Class to keep track of the time and load (percentage of total time) a specific task takes. Call {@link #start()} just before * starting the task and {@link #stop()} right after. You can do this multiple times if required. Every render or update call * {@link #tick()} to update the values. The {@link #time} {@link FloatCounter} provides access to the minimum, maximum, average, * total and current time (in seconds) the task takes. Likewise for the {@link #load} value, which is the percentage of the total * time. * @author xoppa */ public class PerformanceCounter { private final static float nano2seconds = MathUtils.nanoToSec; private long startTime = 0L; private long lastTick = 0L; /** The time value of this counter (seconds) */ public final FloatCounter time; /** The load value of this counter */ public final FloatCounter load; /** The name of this counter */ public final String name; /** The current value in seconds, you can manually increase this using your own timing mechanism if needed, if you do so, you * also need to update {@link #valid}. */ public float current = 0f; /** Flag to indicate that the current value is valid, you need to set this to true if using your own timing mechanism */ public boolean valid = false; public PerformanceCounter (final String name) { this(name, 5); } public PerformanceCounter (final String name, final int windowSize) { this.name = name; this.time = new FloatCounter(windowSize); this.load = new FloatCounter(1); } /** Updates the time and load counters and resets the time. Call {@link #start()} to begin a new count. The values are only * valid after at least two calls to this method. */ public void tick () { final long t = TimeUtils.nanoTime(); if (lastTick > 0L) tick((t - lastTick) * nano2seconds); lastTick = t; } /** Updates the time and load counters and resets the time. Call {@link #start()} to begin a new count. * @param delta The time since the last call to this method */ public void tick (final float delta) { if (!valid) { Gdx.app.error("PerformanceCounter", "Invalid data, check if you called PerformanceCounter#stop()"); return; } time.put(current); final float currentLoad = delta == 0f ? 0f : current / delta; load.put((delta > 1f) ? currentLoad : delta * currentLoad + (1f - delta) * load.latest); current = 0f; valid = false; } /** Start counting, call this method just before performing the task you want to keep track of. Call {@link #stop()} when * done. */ public void start () { startTime = TimeUtils.nanoTime(); valid = false; } /** Stop counting, call this method right after you performed the task you want to keep track of. Call {@link #start()} again * when you perform more of that task. */ public void stop () { if (startTime > 0L) { current += (TimeUtils.nanoTime() - startTime) * nano2seconds; startTime = 0L; valid = true; } } /** Resets this performance counter to its defaults values. */ public void reset () { time.reset(); load.reset(); startTime = 0L; lastTick = 0L; current = 0f; valid = false; } /** {@inheritDoc} */ @Override public String toString () { final StringBuilder sb = new StringBuilder(); return toString(sb).toString(); } /** Creates a string in the form of "name [time: value, load: value]" */ public StringBuilder toString (final StringBuilder sb) { sb.append(name).append(": [time: ").append(time.value).append(", load: ").append(load.value).append("]"); return sb; } }
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.utils; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.math.FloatCounter; import com.badlogic.gdx.math.MathUtils; /** Class to keep track of the time and load (percentage of total time) a specific task takes. Call {@link #start()} just before * starting the task and {@link #stop()} right after. You can do this multiple times if required. Every render or update call * {@link #tick()} to update the values. The {@link #time} {@link FloatCounter} provides access to the minimum, maximum, average, * total and current time (in seconds) the task takes. Likewise for the {@link #load} value, which is the percentage of the total * time. * @author xoppa */ public class PerformanceCounter { private final static float nano2seconds = MathUtils.nanoToSec; private long startTime = 0L; private long lastTick = 0L; /** The time value of this counter (seconds) */ public final FloatCounter time; /** The load value of this counter */ public final FloatCounter load; /** The name of this counter */ public final String name; /** The current value in seconds, you can manually increase this using your own timing mechanism if needed, if you do so, you * also need to update {@link #valid}. */ public float current = 0f; /** Flag to indicate that the current value is valid, you need to set this to true if using your own timing mechanism */ public boolean valid = false; public PerformanceCounter (final String name) { this(name, 5); } public PerformanceCounter (final String name, final int windowSize) { this.name = name; this.time = new FloatCounter(windowSize); this.load = new FloatCounter(1); } /** Updates the time and load counters and resets the time. Call {@link #start()} to begin a new count. The values are only * valid after at least two calls to this method. */ public void tick () { final long t = TimeUtils.nanoTime(); if (lastTick > 0L) tick((t - lastTick) * nano2seconds); lastTick = t; } /** Updates the time and load counters and resets the time. Call {@link #start()} to begin a new count. * @param delta The time since the last call to this method */ public void tick (final float delta) { if (!valid) { Gdx.app.error("PerformanceCounter", "Invalid data, check if you called PerformanceCounter#stop()"); return; } time.put(current); final float currentLoad = delta == 0f ? 0f : current / delta; load.put((delta > 1f) ? currentLoad : delta * currentLoad + (1f - delta) * load.latest); current = 0f; valid = false; } /** Start counting, call this method just before performing the task you want to keep track of. Call {@link #stop()} when * done. */ public void start () { startTime = TimeUtils.nanoTime(); valid = false; } /** Stop counting, call this method right after you performed the task you want to keep track of. Call {@link #start()} again * when you perform more of that task. */ public void stop () { if (startTime > 0L) { current += (TimeUtils.nanoTime() - startTime) * nano2seconds; startTime = 0L; valid = true; } } /** Resets this performance counter to its defaults values. */ public void reset () { time.reset(); load.reset(); startTime = 0L; lastTick = 0L; current = 0f; valid = false; } /** {@inheritDoc} */ @Override public String toString () { final StringBuilder sb = new StringBuilder(); return toString(sb).toString(); } /** Creates a string in the form of "name [time: value, load: value]" */ public StringBuilder toString (final StringBuilder sb) { sb.append(name).append(": [time: ").append(time.value).append(", load: ").append(load.value).append("]"); return sb; } }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./extensions/gdx-box2d/gdx-box2d-gwt/src/com/badlogic/gdx/physics/box2d/gwt/emu/org/jbox2d/dynamics/joints/Jacobian.java
/******************************************************************************* * Copyright (c) 2013, Daniel Murphy * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. ******************************************************************************/ package org.jbox2d.dynamics.joints; import org.jbox2d.common.Vec2; public class Jacobian { public final Vec2 linearA = new Vec2(); public float angularA; public float angularB; }
/******************************************************************************* * Copyright (c) 2013, Daniel Murphy * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. ******************************************************************************/ package org.jbox2d.dynamics.joints; import org.jbox2d.common.Vec2; public class Jacobian { public final Vec2 linearA = new Vec2(); public float angularA; public float angularB; }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./extensions/gdx-bullet/jni/swig-src/dynamics/com/badlogic/gdx/physics/bullet/dynamics/btPoint2PointConstraintDoubleData2.java
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.dynamics; import com.badlogic.gdx.physics.bullet.BulletBase; import com.badlogic.gdx.physics.bullet.linearmath.*; import com.badlogic.gdx.physics.bullet.collision.*; public class btPoint2PointConstraintDoubleData2 extends BulletBase { private long swigCPtr; protected btPoint2PointConstraintDoubleData2 (final String className, long cPtr, boolean cMemoryOwn) { super(className, cPtr, cMemoryOwn); swigCPtr = cPtr; } /** Construct a new btPoint2PointConstraintDoubleData2, normally you should not need this constructor it's intended for * low-level usage. */ public btPoint2PointConstraintDoubleData2 (long cPtr, boolean cMemoryOwn) { this("btPoint2PointConstraintDoubleData2", cPtr, cMemoryOwn); construct(); } @Override protected void reset (long cPtr, boolean cMemoryOwn) { if (!destroyed) destroy(); super.reset(swigCPtr = cPtr, cMemoryOwn); } public static long getCPtr (btPoint2PointConstraintDoubleData2 obj) { return (obj == null) ? 0 : obj.swigCPtr; } @Override protected void finalize () throws Throwable { if (!destroyed) destroy(); super.finalize(); } @Override protected synchronized void delete () { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; DynamicsJNI.delete_btPoint2PointConstraintDoubleData2(swigCPtr); } swigCPtr = 0; } super.delete(); } public void setTypeConstraintData (btTypedConstraintDoubleData value) { DynamicsJNI.btPoint2PointConstraintDoubleData2_typeConstraintData_set(swigCPtr, this, btTypedConstraintDoubleData.getCPtr(value), value); } public btTypedConstraintDoubleData getTypeConstraintData () { long cPtr = DynamicsJNI.btPoint2PointConstraintDoubleData2_typeConstraintData_get(swigCPtr, this); return (cPtr == 0) ? null : new btTypedConstraintDoubleData(cPtr, false); } public void setPivotInA (btVector3DoubleData value) { DynamicsJNI.btPoint2PointConstraintDoubleData2_pivotInA_set(swigCPtr, this, btVector3DoubleData.getCPtr(value), value); } public btVector3DoubleData getPivotInA () { long cPtr = DynamicsJNI.btPoint2PointConstraintDoubleData2_pivotInA_get(swigCPtr, this); return (cPtr == 0) ? null : new btVector3DoubleData(cPtr, false); } public void setPivotInB (btVector3DoubleData value) { DynamicsJNI.btPoint2PointConstraintDoubleData2_pivotInB_set(swigCPtr, this, btVector3DoubleData.getCPtr(value), value); } public btVector3DoubleData getPivotInB () { long cPtr = DynamicsJNI.btPoint2PointConstraintDoubleData2_pivotInB_get(swigCPtr, this); return (cPtr == 0) ? null : new btVector3DoubleData(cPtr, false); } public btPoint2PointConstraintDoubleData2 () { this(DynamicsJNI.new_btPoint2PointConstraintDoubleData2(), true); } }
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.dynamics; import com.badlogic.gdx.physics.bullet.BulletBase; import com.badlogic.gdx.physics.bullet.linearmath.*; import com.badlogic.gdx.physics.bullet.collision.*; public class btPoint2PointConstraintDoubleData2 extends BulletBase { private long swigCPtr; protected btPoint2PointConstraintDoubleData2 (final String className, long cPtr, boolean cMemoryOwn) { super(className, cPtr, cMemoryOwn); swigCPtr = cPtr; } /** Construct a new btPoint2PointConstraintDoubleData2, normally you should not need this constructor it's intended for * low-level usage. */ public btPoint2PointConstraintDoubleData2 (long cPtr, boolean cMemoryOwn) { this("btPoint2PointConstraintDoubleData2", cPtr, cMemoryOwn); construct(); } @Override protected void reset (long cPtr, boolean cMemoryOwn) { if (!destroyed) destroy(); super.reset(swigCPtr = cPtr, cMemoryOwn); } public static long getCPtr (btPoint2PointConstraintDoubleData2 obj) { return (obj == null) ? 0 : obj.swigCPtr; } @Override protected void finalize () throws Throwable { if (!destroyed) destroy(); super.finalize(); } @Override protected synchronized void delete () { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; DynamicsJNI.delete_btPoint2PointConstraintDoubleData2(swigCPtr); } swigCPtr = 0; } super.delete(); } public void setTypeConstraintData (btTypedConstraintDoubleData value) { DynamicsJNI.btPoint2PointConstraintDoubleData2_typeConstraintData_set(swigCPtr, this, btTypedConstraintDoubleData.getCPtr(value), value); } public btTypedConstraintDoubleData getTypeConstraintData () { long cPtr = DynamicsJNI.btPoint2PointConstraintDoubleData2_typeConstraintData_get(swigCPtr, this); return (cPtr == 0) ? null : new btTypedConstraintDoubleData(cPtr, false); } public void setPivotInA (btVector3DoubleData value) { DynamicsJNI.btPoint2PointConstraintDoubleData2_pivotInA_set(swigCPtr, this, btVector3DoubleData.getCPtr(value), value); } public btVector3DoubleData getPivotInA () { long cPtr = DynamicsJNI.btPoint2PointConstraintDoubleData2_pivotInA_get(swigCPtr, this); return (cPtr == 0) ? null : new btVector3DoubleData(cPtr, false); } public void setPivotInB (btVector3DoubleData value) { DynamicsJNI.btPoint2PointConstraintDoubleData2_pivotInB_set(swigCPtr, this, btVector3DoubleData.getCPtr(value), value); } public btVector3DoubleData getPivotInB () { long cPtr = DynamicsJNI.btPoint2PointConstraintDoubleData2_pivotInB_get(swigCPtr, this); return (cPtr == 0) ? null : new btVector3DoubleData(cPtr, false); } public btPoint2PointConstraintDoubleData2 () { this(DynamicsJNI.new_btPoint2PointConstraintDoubleData2(), true); } }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./extensions/gdx-tools/assets/uiskin.atlas
uiskin.png format: RGBA8888 filter: Nearest,Nearest repeat: none default rotate: false xy: 1, 50 size: 254, 77 orig: 254, 77 offset: 0, 0 index: -1 default-window rotate: false xy: 1, 20 size: 27, 29 split: 4, 3, 20, 3 orig: 27, 29 offset: 0, 0 index: -1 default-select rotate: false xy: 29, 29 size: 27, 20 split: 4, 14, 4, 4 orig: 27, 20 offset: 0, 0 index: -1 default-round-large rotate: false xy: 57, 29 size: 20, 20 split: 5, 5, 5, 4 orig: 20, 20 offset: 0, 0 index: -1 default-scroll rotate: false xy: 78, 29 size: 20, 20 split: 2, 2, 2, 2 orig: 20, 20 offset: 0, 0 index: -1 default-slider-knob rotate: false xy: 1, 1 size: 9, 18 orig: 9, 18 offset: 0, 0 index: -1 default-round-down rotate: false xy: 99, 29 size: 12, 20 split: 5, 5, 5, 4 orig: 12, 20 offset: 0, 0 index: -1 default-round rotate: false xy: 112, 29 size: 12, 20 split: 5, 5, 5, 4 pad: 4, 4, 1, 1 orig: 12, 20 offset: 0, 0 index: -1 check-off rotate: false xy: 11, 5 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 textfield rotate: false xy: 11, 5 size: 14, 14 split: 3, 3, 3, 3 orig: 14, 14 offset: 0, 0 index: -1 check-on rotate: false xy: 125, 35 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 tree-minus rotate: false xy: 140, 35 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 tree-plus rotate: false xy: 155, 35 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 default-slider rotate: false xy: 29, 20 size: 8, 8 split: 2, 2, 2, 2 orig: 8, 8 offset: 0, 0 index: -1 default-pane rotate: false xy: 11, 1 size: 5, 3 split: 1, 1, 1, 1 orig: 5, 3 offset: 0, 0 index: -1 default-rect-pad rotate: false xy: 11, 1 size: 5, 3 split: 1, 1, 1, 1 orig: 5, 3 offset: 0, 0 index: -1 default-splitpane rotate: false xy: 17, 1 size: 5, 3 split: 0, 5, 0, 0 orig: 5, 3 offset: 0, 0 index: -1 cursor rotate: false xy: 23, 1 size: 3, 3 split: 1, 1, 1, 1 orig: 3, 3 offset: 0, 0 index: -1 default-splitpane-vertical rotate: false xy: 125, 29 size: 3, 5 split: 0, 0, 0, 5 orig: 3, 5 offset: 0, 0 index: -1 default-rect-down rotate: false xy: 170, 46 size: 3, 3 split: 1, 1, 1, 1 orig: 3, 3 offset: 0, 0 index: -1 default-rect rotate: false xy: 38, 25 size: 3, 3 split: 1, 1, 1, 1 orig: 3, 3 offset: 0, 0 index: -1 default-select-selection rotate: false xy: 26, 16 size: 3, 3 split: 1, 1, 1, 1 orig: 3, 3 offset: 0, 0 index: -1 default-pane-noborder rotate: false xy: 129, 33 size: 1, 1 split: 0, 0, 0, 0 orig: 1, 1 offset: 0, 0 index: -1 selection rotate: false xy: 170, 44 size: 1, 1 orig: 1, 1 offset: 0, 0 index: -1 white rotate: false xy: 174, 48 size: 1, 1 orig: 1, 1 offset: 0, 0 index: -1
uiskin.png format: RGBA8888 filter: Nearest,Nearest repeat: none default rotate: false xy: 1, 50 size: 254, 77 orig: 254, 77 offset: 0, 0 index: -1 default-window rotate: false xy: 1, 20 size: 27, 29 split: 4, 3, 20, 3 orig: 27, 29 offset: 0, 0 index: -1 default-select rotate: false xy: 29, 29 size: 27, 20 split: 4, 14, 4, 4 orig: 27, 20 offset: 0, 0 index: -1 default-round-large rotate: false xy: 57, 29 size: 20, 20 split: 5, 5, 5, 4 orig: 20, 20 offset: 0, 0 index: -1 default-scroll rotate: false xy: 78, 29 size: 20, 20 split: 2, 2, 2, 2 orig: 20, 20 offset: 0, 0 index: -1 default-slider-knob rotate: false xy: 1, 1 size: 9, 18 orig: 9, 18 offset: 0, 0 index: -1 default-round-down rotate: false xy: 99, 29 size: 12, 20 split: 5, 5, 5, 4 orig: 12, 20 offset: 0, 0 index: -1 default-round rotate: false xy: 112, 29 size: 12, 20 split: 5, 5, 5, 4 pad: 4, 4, 1, 1 orig: 12, 20 offset: 0, 0 index: -1 check-off rotate: false xy: 11, 5 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 textfield rotate: false xy: 11, 5 size: 14, 14 split: 3, 3, 3, 3 orig: 14, 14 offset: 0, 0 index: -1 check-on rotate: false xy: 125, 35 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 tree-minus rotate: false xy: 140, 35 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 tree-plus rotate: false xy: 155, 35 size: 14, 14 orig: 14, 14 offset: 0, 0 index: -1 default-slider rotate: false xy: 29, 20 size: 8, 8 split: 2, 2, 2, 2 orig: 8, 8 offset: 0, 0 index: -1 default-pane rotate: false xy: 11, 1 size: 5, 3 split: 1, 1, 1, 1 orig: 5, 3 offset: 0, 0 index: -1 default-rect-pad rotate: false xy: 11, 1 size: 5, 3 split: 1, 1, 1, 1 orig: 5, 3 offset: 0, 0 index: -1 default-splitpane rotate: false xy: 17, 1 size: 5, 3 split: 0, 5, 0, 0 orig: 5, 3 offset: 0, 0 index: -1 cursor rotate: false xy: 23, 1 size: 3, 3 split: 1, 1, 1, 1 orig: 3, 3 offset: 0, 0 index: -1 default-splitpane-vertical rotate: false xy: 125, 29 size: 3, 5 split: 0, 0, 0, 5 orig: 3, 5 offset: 0, 0 index: -1 default-rect-down rotate: false xy: 170, 46 size: 3, 3 split: 1, 1, 1, 1 orig: 3, 3 offset: 0, 0 index: -1 default-rect rotate: false xy: 38, 25 size: 3, 3 split: 1, 1, 1, 1 orig: 3, 3 offset: 0, 0 index: -1 default-select-selection rotate: false xy: 26, 16 size: 3, 3 split: 1, 1, 1, 1 orig: 3, 3 offset: 0, 0 index: -1 default-pane-noborder rotate: false xy: 129, 33 size: 1, 1 split: 0, 0, 0, 0 orig: 1, 1 offset: 0, 0 index: -1 selection rotate: false xy: 170, 44 size: 1, 1 orig: 1, 1 offset: 0, 0 index: -1 white rotate: false xy: 174, 48 size: 1, 1 orig: 1, 1 offset: 0, 0 index: -1
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./extensions/gdx-setup/res/com/badlogic/gdx/setup/resources/android/res/drawable-xxhdpi/ic_launcher.png
PNG  IHDRF pHYs B(x9iTXtXML:com.adobe.xmp<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?> <x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.5-c021 79.154911, 2013/10/29-11:47:16 "> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <rdf:Description rdf:about="" xmlns:xmp="http://ns.adobe.com/xap/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/" xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/" xmlns:stEvt="http://ns.adobe.com/xap/1.0/sType/ResourceEvent#" xmlns:tiff="http://ns.adobe.com/tiff/1.0/" xmlns:exif="http://ns.adobe.com/exif/1.0/"> <xmp:CreatorTool>Adobe Photoshop CC (Windows)</xmp:CreatorTool> <xmp:CreateDate>2016-09-25T17:02:36+02:00</xmp:CreateDate> <xmp:ModifyDate>2016-09-25T17:05:32+02:00</xmp:ModifyDate> <xmp:MetadataDate>2016-09-25T17:05:32+02:00</xmp:MetadataDate> <dc:format>image/png</dc:format> <photoshop:ColorMode>3</photoshop:ColorMode> <xmpMM:InstanceID>xmp.iid:a2d98162-0e2a-9c43-a3bf-5aa4cc08926b</xmpMM:InstanceID> <xmpMM:DocumentID>xmp.did:6e14fb71-c5c4-5640-89a0-e90c5757af36</xmpMM:DocumentID> <xmpMM:OriginalDocumentID>xmp.did:6e14fb71-c5c4-5640-89a0-e90c5757af36</xmpMM:OriginalDocumentID> <xmpMM:History> <rdf:Seq> <rdf:li rdf:parseType="Resource"> <stEvt:action>created</stEvt:action> <stEvt:instanceID>xmp.iid:6e14fb71-c5c4-5640-89a0-e90c5757af36</stEvt:instanceID> <stEvt:when>2016-09-25T17:02:36+02:00</stEvt:when> <stEvt:softwareAgent>Adobe Photoshop CC (Windows)</stEvt:softwareAgent> </rdf:li> <rdf:li rdf:parseType="Resource"> <stEvt:action>saved</stEvt:action> <stEvt:instanceID>xmp.iid:a2d98162-0e2a-9c43-a3bf-5aa4cc08926b</stEvt:instanceID> <stEvt:when>2016-09-25T17:05:32+02:00</stEvt:when> <stEvt:softwareAgent>Adobe Photoshop CC (Windows)</stEvt:softwareAgent> <stEvt:changed>/</stEvt:changed> </rdf:li> </rdf:Seq> </xmpMM:History> <tiff:Orientation>1</tiff:Orientation> <tiff:XResolution>900000/10000</tiff:XResolution> <tiff:YResolution>900000/10000</tiff:YResolution> <tiff:ResolutionUnit>2</tiff:ResolutionUnit> <exif:ColorSpace>65535</exif:ColorSpace> <exif:PixelXDimension>144</exif:PixelXDimension> <exif:PixelYDimension>144</exif:PixelYDimension> </rdf:Description> </rdf:RDF> </x:xmpmeta> <?xpacket end="w"?>8_ m cHRMz%u0`:o_FIDATx{p}?{/Y%Yے -3ph %!-C0rv04%SbN0aL@ H2Cl6,zӝ仓ط羿YM)E"e"q>Д헵, pI?[V x Nz^&8ꀧ]xgg2}8_y <@ #x ƘM +a pf'$>BG6a%.B42]V"w{!G7*!*u$BܠL B>\K<Y!O*tP _4'('JkBD AD AHHAD AD AHHD AD AD AHHD AD AHHAD AD AH \v6Mp8ihX,Fqq10x0~`rn"'ylKqq/><Ac@6Z-q( xJD4JڔB4;eujcZ49'}<1R c9?3ى9o.Yxq@7ofڵI b1n^xa˗/_Ohܹ8p 9CώmD?#v$fS j=?LWqkV`6D=@ , n< /"Pw'8u & %J|M7\>K2cT4>eJBo'z'/qҶoii!l iM kmm^MXQG1 7KOVU6N6)?q7(y_gozXWUU"i`t?Jلݛ;v;ja23h&j & 3FIm>/}QQ)~BP'%|ZG/_D`ۨ`(y4B?z L\!ZZr+xg+(ujkpLHhl BwߛUi_Z=w441)~B@5fO~G<#ӝy4e|uLj֊uc$<ް,ۙq ({v7nljJf"5w=O>Fh=s(m"f9SЪ5)5:_=mmm)EW_=)+btN3fmג)IӧO\5oZ?s\G9[&*>vggPv/X^&M"ܹtoyʘcGiVH/Y F̑'0Ny&E 0x>.Ӄ֊&Z[ե?S&i<<az"/UHa;垿i}Y &=w=OnNDGh-UMGb N3^yιq e6IjCawwo'\`Wddݦ ^;h7׋tr=ќuoy'7;wԠz{R!ì?Lp gR2mڵ\.hEq5׌ݎv؁ضiB!.r-ZLtհs.\,JEE HB ^7n2M~3L]%x.BDRt)N&zѩN4% k-"= *GC1̆ i&U ˲M۾dɒZjUnFvܙ29V*@>|=e+P @7\y,JKOЧNu;K >˭@s/Xn<ՂQ^bT _/!mQ+9L@Q^^모q_y޽{28{QY /zad.[Ow\:s7ѡJ/oQw;VWz Ȩkds,52)5!k.5oG"ؽΟT4l:ip/!%lf_su`0Hii/̱c@e1**/WU5؝Ci4]ϝs7-~cZ񫘭ЋAvOPiet=t~.s)0ٳGgg'> <L~ok֬SA=,J٩j9I݃^\Q^AПa䜽>}mh4etZEmo}tל9(Mhs_TTcܹ3~CEmeh#V7?Za!?̲<\f_Z>TغݨH橖1ф=k~T<<^Ssȑg` MxC=}7=cot2Rh.ݾuB39%="p[lɸu]Pp/#g~iT =uC2 dAo9,9F{2!kkP(FUu<fC=Ѯ3n@xR"\mt?ׄ555xbn7===ݻ7~^ziI2˱O@ tʉGǝMehV{ÇLF4Fc .# C.Άa`wv**~@ESqϞ!ԠC3޴0 ){~7mKo%~19y<ΧgV9;F|c e#}<d)Y:OK3 f\O7`h"_̜&<R'6V o9eX`*y3d9=mboĨH7ܚLlmۖ|oFl^ :J9f' ,ػq)N ҂kUJi[VL̐ynDKojl58#7[,FYk3rYWWW>HdٰaR[ 'c2bcA$h FtJ(-MK9FP>&Y"Jځkl'!uK sr{^P`^M51P*+ztvohrr|%@@eeeڒ֒\.ר=J)," rerJnQUE~NmDXҚkY)m ( ޵ | ѧc~I-/;q͹ЉtzcEiKZC|+% .KZV ȫ?(/'ruNk5T7U4&sQ}&l&PX[`>ȩR6z04zZT?A>C{rHF $/L $ "  $@$@  "  " @$@$"  "  " @$@$"  "  $@$@  "  "  $@$@@AM'g" pI<)':pP x_ R8)`X9KESsү~'1r*#ѿޓY^3 FȂ@3΅5K%6YX:(Hv%F(<p7HE82i؝O2}8zg_H [L8v+ K8o[϶s _ |48xh?<? XIENDB`
PNG  IHDRF pHYs B(x9iTXtXML:com.adobe.xmp<?xpacket begin="" id="W5M0MpCehiHzreSzNTczkc9d"?> <x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 5.5-c021 79.154911, 2013/10/29-11:47:16 "> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"> <rdf:Description rdf:about="" xmlns:xmp="http://ns.adobe.com/xap/1.0/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/" xmlns:xmpMM="http://ns.adobe.com/xap/1.0/mm/" xmlns:stEvt="http://ns.adobe.com/xap/1.0/sType/ResourceEvent#" xmlns:tiff="http://ns.adobe.com/tiff/1.0/" xmlns:exif="http://ns.adobe.com/exif/1.0/"> <xmp:CreatorTool>Adobe Photoshop CC (Windows)</xmp:CreatorTool> <xmp:CreateDate>2016-09-25T17:02:36+02:00</xmp:CreateDate> <xmp:ModifyDate>2016-09-25T17:05:32+02:00</xmp:ModifyDate> <xmp:MetadataDate>2016-09-25T17:05:32+02:00</xmp:MetadataDate> <dc:format>image/png</dc:format> <photoshop:ColorMode>3</photoshop:ColorMode> <xmpMM:InstanceID>xmp.iid:a2d98162-0e2a-9c43-a3bf-5aa4cc08926b</xmpMM:InstanceID> <xmpMM:DocumentID>xmp.did:6e14fb71-c5c4-5640-89a0-e90c5757af36</xmpMM:DocumentID> <xmpMM:OriginalDocumentID>xmp.did:6e14fb71-c5c4-5640-89a0-e90c5757af36</xmpMM:OriginalDocumentID> <xmpMM:History> <rdf:Seq> <rdf:li rdf:parseType="Resource"> <stEvt:action>created</stEvt:action> <stEvt:instanceID>xmp.iid:6e14fb71-c5c4-5640-89a0-e90c5757af36</stEvt:instanceID> <stEvt:when>2016-09-25T17:02:36+02:00</stEvt:when> <stEvt:softwareAgent>Adobe Photoshop CC (Windows)</stEvt:softwareAgent> </rdf:li> <rdf:li rdf:parseType="Resource"> <stEvt:action>saved</stEvt:action> <stEvt:instanceID>xmp.iid:a2d98162-0e2a-9c43-a3bf-5aa4cc08926b</stEvt:instanceID> <stEvt:when>2016-09-25T17:05:32+02:00</stEvt:when> <stEvt:softwareAgent>Adobe Photoshop CC (Windows)</stEvt:softwareAgent> <stEvt:changed>/</stEvt:changed> </rdf:li> </rdf:Seq> </xmpMM:History> <tiff:Orientation>1</tiff:Orientation> <tiff:XResolution>900000/10000</tiff:XResolution> <tiff:YResolution>900000/10000</tiff:YResolution> <tiff:ResolutionUnit>2</tiff:ResolutionUnit> <exif:ColorSpace>65535</exif:ColorSpace> <exif:PixelXDimension>144</exif:PixelXDimension> <exif:PixelYDimension>144</exif:PixelYDimension> </rdf:Description> </rdf:RDF> </x:xmpmeta> <?xpacket end="w"?>8_ m cHRMz%u0`:o_FIDATx{p}?{/Y%Yے -3ph %!-C0rv04%SbN0aL@ H2Cl6,zӝ仓ط羿YM)E"e"q>Д헵, pI?[V x Nz^&8ꀧ]xgg2}8_y <@ #x ƘM +a pf'$>BG6a%.B42]V"w{!G7*!*u$BܠL B>\K<Y!O*tP _4'('JkBD AD AHHAD AD AHHD AD AD AHHD AD AHHAD AD AH \v6Mp8ihX,Fqq10x0~`rn"'ylKqq/><Ac@6Z-q( xJD4JڔB4;eujcZ49'}<1R c9?3ى9o.Yxq@7ofڵI b1n^xa˗/_Ohܹ8p 9CώmD?#v$fS j=?LWqkV`6D=@ , n< /"Pw'8u & %J|M7\>K2cT4>eJBo'z'/qҶoii!l iM kmm^MXQG1 7KOVU6N6)?q7(y_gozXWUU"i`t?Jلݛ;v;ja23h&j & 3FIm>/}QQ)~BP'%|ZG/_D`ۨ`(y4B?z L\!ZZr+xg+(ujkpLHhl BwߛUi_Z=w441)~B@5fO~G<#ӝy4e|uLj֊uc$<ް,ۙq ({v7nljJf"5w=O>Fh=s(m"f9SЪ5)5:_=mmm)EW_=)+btN3fmג)IӧO\5oZ?s\G9[&*>vggPv/X^&M"ܹtoyʘcGiVH/Y F̑'0Ny&E 0x>.Ӄ֊&Z[ե?S&i<<az"/UHa;垿i}Y &=w=OnNDGh-UMGb N3^yιq e6IjCawwo'\`Wddݦ ^;h7׋tr=ќuoy'7;wԠz{R!ì?Lp gR2mڵ\.hEq5׌ݎv؁ضiB!.r-ZLtհs.\,JEE HB ^7n2M~3L]%x.BDRt)N&zѩN4% k-"= *GC1̆ i&U ˲M۾dɒZjUnFvܙ29V*@>|=e+P @7\y,JKOЧNu;K >˭@s/Xn<ՂQ^bT _/!mQ+9L@Q^^모q_y޽{28{QY /zad.[Ow\:s7ѡJ/oQw;VWz Ȩkds,52)5!k.5oG"ؽΟT4l:ip/!%lf_su`0Hii/̱c@e1**/WU5؝Ci4]ϝs7-~cZ񫘭ЋAvOPiet=t~.s)0ٳGgg'> <L~ok֬SA=,J٩j9I݃^\Q^AПa䜽>}mh4etZEmo}tל9(Mhs_TTcܹ3~CEmeh#V7?Za!?̲<\f_Z>TغݨH橖1ф=k~T<<^Ssȑg` MxC=}7=cot2Rh.ݾuB39%="p[lɸu]Pp/#g~iT =uC2 dAo9,9F{2!kkP(FUu<fC=Ѯ3n@xR"\mt?ׄ555xbn7===ݻ7~^ziI2˱O@ tʉGǝMehV{ÇLF4Fc .# C.Άa`wv**~@ESqϞ!ԠC3޴0 ){~7mKo%~19y<ΧgV9;F|c e#}<d)Y:OK3 f\O7`h"_̜&<R'6V o9eX`*y3d9=mboĨH7ܚLlmۖ|oFl^ :J9f' ,ػq)N ҂kUJi[VL̐ynDKojl58#7[,FYk3rYWWW>HdٰaR[ 'c2bcA$h FtJ(-MK9FP>&Y"Jځkl'!uK sr{^P`^M51P*+ztvohrr|%@@eeeڒ֒\.ר=J)," rerJnQUE~NmDXҚkY)m ( ޵ | ѧc~I-/;q͹ЉtzcEiKZC|+% .KZV ȫ?(/'ruNk5T7U4&sQ}&l&PX[`>ȩR6z04zZT?A>C{rHF $/L $ "  $@$@  "  " @$@$"  "  " @$@$"  "  $@$@  "  "  $@$@@AM'g" pI<)':pP x_ R8)`X9KESsү~'1r*#ѿޓY^3 FȂ@3΅5K%6YX:(Hv%F(<p7HE82i؝O2}8zg_H [L8v+ K8o[϶s _ |48xh?<? XIENDB`
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./extensions/gdx-bullet/jni/swig-src/collision/com/badlogic/gdx/physics/bullet/collision/btCylinderShape.java
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.collision; import com.badlogic.gdx.physics.bullet.linearmath.*; import com.badlogic.gdx.math.Vector3; public class btCylinderShape extends btConvexInternalShape { private long swigCPtr; protected btCylinderShape (final String className, long cPtr, boolean cMemoryOwn) { super(className, CollisionJNI.btCylinderShape_SWIGUpcast(cPtr), cMemoryOwn); swigCPtr = cPtr; } /** Construct a new btCylinderShape, normally you should not need this constructor it's intended for low-level usage. */ public btCylinderShape (long cPtr, boolean cMemoryOwn) { this("btCylinderShape", cPtr, cMemoryOwn); construct(); } @Override protected void reset (long cPtr, boolean cMemoryOwn) { if (!destroyed) destroy(); super.reset(CollisionJNI.btCylinderShape_SWIGUpcast(swigCPtr = cPtr), cMemoryOwn); } public static long getCPtr (btCylinderShape obj) { return (obj == null) ? 0 : obj.swigCPtr; } @Override protected void finalize () throws Throwable { if (!destroyed) destroy(); super.finalize(); } @Override protected synchronized void delete () { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; CollisionJNI.delete_btCylinderShape(swigCPtr); } swigCPtr = 0; } super.delete(); } public long operatorNew (long sizeInBytes) { return CollisionJNI.btCylinderShape_operatorNew__SWIG_0(swigCPtr, this, sizeInBytes); } public void operatorDelete (long ptr) { CollisionJNI.btCylinderShape_operatorDelete__SWIG_0(swigCPtr, this, ptr); } public long operatorNew (long arg0, long ptr) { return CollisionJNI.btCylinderShape_operatorNew__SWIG_1(swigCPtr, this, arg0, ptr); } public void operatorDelete (long arg0, long arg1) { CollisionJNI.btCylinderShape_operatorDelete__SWIG_1(swigCPtr, this, arg0, arg1); } public long operatorNewArray (long sizeInBytes) { return CollisionJNI.btCylinderShape_operatorNewArray__SWIG_0(swigCPtr, this, sizeInBytes); } public void operatorDeleteArray (long ptr) { CollisionJNI.btCylinderShape_operatorDeleteArray__SWIG_0(swigCPtr, this, ptr); } public long operatorNewArray (long arg0, long ptr) { return CollisionJNI.btCylinderShape_operatorNewArray__SWIG_1(swigCPtr, this, arg0, ptr); } public void operatorDeleteArray (long arg0, long arg1) { CollisionJNI.btCylinderShape_operatorDeleteArray__SWIG_1(swigCPtr, this, arg0, arg1); } public Vector3 getHalfExtentsWithMargin () { return CollisionJNI.btCylinderShape_getHalfExtentsWithMargin(swigCPtr, this); } public Vector3 getHalfExtentsWithoutMargin () { return CollisionJNI.btCylinderShape_getHalfExtentsWithoutMargin(swigCPtr, this); } public btCylinderShape (Vector3 halfExtents) { this(CollisionJNI.new_btCylinderShape(halfExtents), true); } public int getUpAxis () { return CollisionJNI.btCylinderShape_getUpAxis(swigCPtr, this); } public float getRadius () { return CollisionJNI.btCylinderShape_getRadius(swigCPtr, this); } }
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.collision; import com.badlogic.gdx.physics.bullet.linearmath.*; import com.badlogic.gdx.math.Vector3; public class btCylinderShape extends btConvexInternalShape { private long swigCPtr; protected btCylinderShape (final String className, long cPtr, boolean cMemoryOwn) { super(className, CollisionJNI.btCylinderShape_SWIGUpcast(cPtr), cMemoryOwn); swigCPtr = cPtr; } /** Construct a new btCylinderShape, normally you should not need this constructor it's intended for low-level usage. */ public btCylinderShape (long cPtr, boolean cMemoryOwn) { this("btCylinderShape", cPtr, cMemoryOwn); construct(); } @Override protected void reset (long cPtr, boolean cMemoryOwn) { if (!destroyed) destroy(); super.reset(CollisionJNI.btCylinderShape_SWIGUpcast(swigCPtr = cPtr), cMemoryOwn); } public static long getCPtr (btCylinderShape obj) { return (obj == null) ? 0 : obj.swigCPtr; } @Override protected void finalize () throws Throwable { if (!destroyed) destroy(); super.finalize(); } @Override protected synchronized void delete () { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; CollisionJNI.delete_btCylinderShape(swigCPtr); } swigCPtr = 0; } super.delete(); } public long operatorNew (long sizeInBytes) { return CollisionJNI.btCylinderShape_operatorNew__SWIG_0(swigCPtr, this, sizeInBytes); } public void operatorDelete (long ptr) { CollisionJNI.btCylinderShape_operatorDelete__SWIG_0(swigCPtr, this, ptr); } public long operatorNew (long arg0, long ptr) { return CollisionJNI.btCylinderShape_operatorNew__SWIG_1(swigCPtr, this, arg0, ptr); } public void operatorDelete (long arg0, long arg1) { CollisionJNI.btCylinderShape_operatorDelete__SWIG_1(swigCPtr, this, arg0, arg1); } public long operatorNewArray (long sizeInBytes) { return CollisionJNI.btCylinderShape_operatorNewArray__SWIG_0(swigCPtr, this, sizeInBytes); } public void operatorDeleteArray (long ptr) { CollisionJNI.btCylinderShape_operatorDeleteArray__SWIG_0(swigCPtr, this, ptr); } public long operatorNewArray (long arg0, long ptr) { return CollisionJNI.btCylinderShape_operatorNewArray__SWIG_1(swigCPtr, this, arg0, ptr); } public void operatorDeleteArray (long arg0, long arg1) { CollisionJNI.btCylinderShape_operatorDeleteArray__SWIG_1(swigCPtr, this, arg0, arg1); } public Vector3 getHalfExtentsWithMargin () { return CollisionJNI.btCylinderShape_getHalfExtentsWithMargin(swigCPtr, this); } public Vector3 getHalfExtentsWithoutMargin () { return CollisionJNI.btCylinderShape_getHalfExtentsWithoutMargin(swigCPtr, this); } public btCylinderShape (Vector3 halfExtents) { this(CollisionJNI.new_btCylinderShape(halfExtents), true); } public int getUpAxis () { return CollisionJNI.btCylinderShape_getUpAxis(swigCPtr, this); } public float getRadius () { return CollisionJNI.btCylinderShape_getRadius(swigCPtr, this); } }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./backends/gdx-backends-gwt/src/com/badlogic/gdx/backends/gwt/theme/chrome/public/gwt/chrome/images/corner.png
PNG  IHDRCsRGBbKGD pHYs  tIME6(IDATXK#W?êChE![IXܮb1" >}* ,}jB> nY+$vH+5E:mfM׌R%d{9gfHLIi:0ʩ׆|XBV^O`g> 9S)1`H @0WCqU;,X"8q`Exx(EE˘ZEV2,kv1.RT8F_{qR-@OB=@LOQ:<bE|bƕ<"`1 !l\ XaP(.TQ@(|y1e0$@.a+_2o<s|l=e&0ܸ<ytD$_]]] 7,8T&o@Sз4: iL&cU YH2| x<>z4M;S$& 䎣x;MV൮~]חl6r.~g&w=]~ݖ~r L޻soNtjoq1]?kՔ?Bj& 06QT@HlA#]\˫iZU^{@i`\(^v7@ $G_9H'rԑZՊoU պʓH$"ݍld]Jxkڪ:h||UU;m8 E">_IẨ:p׍88~UUǤן'ݚr;0?w}>?>_ʠ<RU·%΅GnvWw@,(ֺX?goSϏ%v fo5jo9<F)NO; fH\SO?lb_@_6`P,#lHǎN<]}@u ;,4VP[mΐ `̬q1};顴1`gN7m' `T8V[f%:ז]6?+s]wD.*'@'C .X}m+y7z{NIENDB`
PNG  IHDRCsRGBbKGD pHYs  tIME6(IDATXK#W?êChE![IXܮb1" >}* ,}jB> nY+$vH+5E:mfM׌R%d{9gfHLIi:0ʩ׆|XBV^O`g> 9S)1`H @0WCqU;,X"8q`Exx(EE˘ZEV2,kv1.RT8F_{qR-@OB=@LOQ:<bE|bƕ<"`1 !l\ XaP(.TQ@(|y1e0$@.a+_2o<s|l=e&0ܸ<ytD$_]]] 7,8T&o@Sз4: iL&cU YH2| x<>z4M;S$& 䎣x;MV൮~]חl6r.~g&w=]~ݖ~r L޻soNtjoq1]?kՔ?Bj& 06QT@HlA#]\˫iZU^{@i`\(^v7@ $G_9H'rԑZՊoU պʓH$"ݍld]Jxkڪ:h||UU;m8 E">_IẨ:p׍88~UUǤן'ݚr;0?w}>?>_ʠ<RU·%΅GnvWw@,(ֺX?goSϏ%v fo5jo9<F)NO; fH\SO?lb_@_6`P,#lHǎN<]}@u ;,4VP[mΐ `̬q1};顴1`gN7m' `T8V[f%:ז]6?+s]wD.*'@'C .X}m+y7z{NIENDB`
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./extensions/gdx-bullet/jni/src/bullet/BulletCollision/NarrowPhaseCollision/btGjkPairDetector.cpp
/* Bullet Continuous Collision Detection and Physics Library Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "btGjkPairDetector.h" #include "BulletCollision/CollisionShapes/btConvexShape.h" #include "BulletCollision/NarrowPhaseCollision/btSimplexSolverInterface.h" #include "BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h" #if defined(DEBUG) || defined (_DEBUG) //#define TEST_NON_VIRTUAL 1 #include <stdio.h> //for debug printf #ifdef __SPU__ #include <spu_printf.h> #define printf spu_printf #endif //__SPU__ #endif //must be above the machine epsilon #ifdef BT_USE_DOUBLE_PRECISION #define REL_ERROR2 btScalar(1.0e-12) btScalar gGjkEpaPenetrationTolerance = 1e-7; #else #define REL_ERROR2 btScalar(1.0e-6) btScalar gGjkEpaPenetrationTolerance = 0.001; #endif //temp globals, to improve GJK/EPA/penetration calculations int gNumDeepPenetrationChecks = 0; int gNumGjkChecks = 0; btGjkPairDetector::btGjkPairDetector(const btConvexShape* objectA,const btConvexShape* objectB,btSimplexSolverInterface* simplexSolver,btConvexPenetrationDepthSolver* penetrationDepthSolver) :m_cachedSeparatingAxis(btScalar(0.),btScalar(1.),btScalar(0.)), m_penetrationDepthSolver(penetrationDepthSolver), m_simplexSolver(simplexSolver), m_minkowskiA(objectA), m_minkowskiB(objectB), m_shapeTypeA(objectA->getShapeType()), m_shapeTypeB(objectB->getShapeType()), m_marginA(objectA->getMargin()), m_marginB(objectB->getMargin()), m_ignoreMargin(false), m_lastUsedMethod(-1), m_catchDegeneracies(1), m_fixContactNormalDirection(1) { } btGjkPairDetector::btGjkPairDetector(const btConvexShape* objectA,const btConvexShape* objectB,int shapeTypeA,int shapeTypeB,btScalar marginA, btScalar marginB, btSimplexSolverInterface* simplexSolver,btConvexPenetrationDepthSolver* penetrationDepthSolver) :m_cachedSeparatingAxis(btScalar(0.),btScalar(1.),btScalar(0.)), m_penetrationDepthSolver(penetrationDepthSolver), m_simplexSolver(simplexSolver), m_minkowskiA(objectA), m_minkowskiB(objectB), m_shapeTypeA(shapeTypeA), m_shapeTypeB(shapeTypeB), m_marginA(marginA), m_marginB(marginB), m_ignoreMargin(false), m_lastUsedMethod(-1), m_catchDegeneracies(1), m_fixContactNormalDirection(1) { } void btGjkPairDetector::getClosestPoints(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw,bool swapResults) { (void)swapResults; getClosestPointsNonVirtual(input,output,debugDraw); } #ifdef __SPU__ void btGjkPairDetector::getClosestPointsNonVirtual(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw) #else void btGjkPairDetector::getClosestPointsNonVirtual(const ClosestPointInput& input, Result& output, class btIDebugDraw* debugDraw) #endif { m_cachedSeparatingDistance = 0.f; btScalar distance=btScalar(0.); btVector3 normalInB(btScalar(0.),btScalar(0.),btScalar(0.)); btVector3 pointOnA,pointOnB; btTransform localTransA = input.m_transformA; btTransform localTransB = input.m_transformB; btVector3 positionOffset=(localTransA.getOrigin() + localTransB.getOrigin()) * btScalar(0.5); localTransA.getOrigin() -= positionOffset; localTransB.getOrigin() -= positionOffset; bool check2d = m_minkowskiA->isConvex2d() && m_minkowskiB->isConvex2d(); btScalar marginA = m_marginA; btScalar marginB = m_marginB; gNumGjkChecks++; //for CCD we don't use margins if (m_ignoreMargin) { marginA = btScalar(0.); marginB = btScalar(0.); } m_curIter = 0; int gGjkMaxIter = 1000;//this is to catch invalid input, perhaps check for #NaN? m_cachedSeparatingAxis.setValue(0,1,0); bool isValid = false; bool checkSimplex = false; bool checkPenetration = true; m_degenerateSimplex = 0; m_lastUsedMethod = -1; { btScalar squaredDistance = BT_LARGE_FLOAT; btScalar delta = btScalar(0.); btScalar margin = marginA + marginB; m_simplexSolver->reset(); for ( ; ; ) //while (true) { btVector3 seperatingAxisInA = (-m_cachedSeparatingAxis)* input.m_transformA.getBasis(); btVector3 seperatingAxisInB = m_cachedSeparatingAxis* input.m_transformB.getBasis(); btVector3 pInA = m_minkowskiA->localGetSupportVertexWithoutMarginNonVirtual(seperatingAxisInA); btVector3 qInB = m_minkowskiB->localGetSupportVertexWithoutMarginNonVirtual(seperatingAxisInB); btVector3 pWorld = localTransA(pInA); btVector3 qWorld = localTransB(qInB); if (check2d) { pWorld[2] = 0.f; qWorld[2] = 0.f; } btVector3 w = pWorld - qWorld; delta = m_cachedSeparatingAxis.dot(w); // potential exit, they don't overlap if ((delta > btScalar(0.0)) && (delta * delta > squaredDistance * input.m_maximumDistanceSquared)) { m_degenerateSimplex = 10; checkSimplex=true; //checkPenetration = false; break; } //exit 0: the new point is already in the simplex, or we didn't come any closer if (m_simplexSolver->inSimplex(w)) { m_degenerateSimplex = 1; checkSimplex = true; break; } // are we getting any closer ? btScalar f0 = squaredDistance - delta; btScalar f1 = squaredDistance * REL_ERROR2; if (f0 <= f1) { if (f0 <= btScalar(0.)) { m_degenerateSimplex = 2; } else { m_degenerateSimplex = 11; } checkSimplex = true; break; } //add current vertex to simplex m_simplexSolver->addVertex(w, pWorld, qWorld); btVector3 newCachedSeparatingAxis; //calculate the closest point to the origin (update vector v) if (!m_simplexSolver->closest(newCachedSeparatingAxis)) { m_degenerateSimplex = 3; checkSimplex = true; break; } if(newCachedSeparatingAxis.length2()<REL_ERROR2) { m_cachedSeparatingAxis = newCachedSeparatingAxis; m_degenerateSimplex = 6; checkSimplex = true; break; } btScalar previousSquaredDistance = squaredDistance; squaredDistance = newCachedSeparatingAxis.length2(); #if 0 ///warning: this termination condition leads to some problems in 2d test case see Bullet/Demos/Box2dDemo if (squaredDistance>previousSquaredDistance) { m_degenerateSimplex = 7; squaredDistance = previousSquaredDistance; checkSimplex = false; break; } #endif // //redundant m_simplexSolver->compute_points(pointOnA, pointOnB); //are we getting any closer ? if (previousSquaredDistance - squaredDistance <= SIMD_EPSILON * previousSquaredDistance) { // m_simplexSolver->backup_closest(m_cachedSeparatingAxis); checkSimplex = true; m_degenerateSimplex = 12; break; } m_cachedSeparatingAxis = newCachedSeparatingAxis; //degeneracy, this is typically due to invalid/uninitialized worldtransforms for a btCollisionObject if (m_curIter++ > gGjkMaxIter) { #if defined(DEBUG) || defined (_DEBUG) printf("btGjkPairDetector maxIter exceeded:%i\n",m_curIter); printf("sepAxis=(%f,%f,%f), squaredDistance = %f, shapeTypeA=%i,shapeTypeB=%i\n", m_cachedSeparatingAxis.getX(), m_cachedSeparatingAxis.getY(), m_cachedSeparatingAxis.getZ(), squaredDistance, m_minkowskiA->getShapeType(), m_minkowskiB->getShapeType()); #endif break; } bool check = (!m_simplexSolver->fullSimplex()); //bool check = (!m_simplexSolver->fullSimplex() && squaredDistance > SIMD_EPSILON * m_simplexSolver->maxVertex()); if (!check) { //do we need this backup_closest here ? // m_simplexSolver->backup_closest(m_cachedSeparatingAxis); m_degenerateSimplex = 13; break; } } if (checkSimplex) { m_simplexSolver->compute_points(pointOnA, pointOnB); normalInB = m_cachedSeparatingAxis; btScalar lenSqr =m_cachedSeparatingAxis.length2(); //valid normal if (lenSqr < REL_ERROR2) { m_degenerateSimplex = 5; } if (lenSqr > SIMD_EPSILON*SIMD_EPSILON) { btScalar rlen = btScalar(1.) / btSqrt(lenSqr ); normalInB *= rlen; //normalize btScalar s = btSqrt(squaredDistance); btAssert(s > btScalar(0.0)); pointOnA -= m_cachedSeparatingAxis * (marginA / s); pointOnB += m_cachedSeparatingAxis * (marginB / s); distance = ((btScalar(1.)/rlen) - margin); isValid = true; m_lastUsedMethod = 1; } else { m_lastUsedMethod = 2; } } bool catchDegeneratePenetrationCase = (m_catchDegeneracies && m_penetrationDepthSolver && m_degenerateSimplex && ((distance+margin) < gGjkEpaPenetrationTolerance)); //if (checkPenetration && !isValid) if (checkPenetration && (!isValid || catchDegeneratePenetrationCase )) { //penetration case //if there is no way to handle penetrations, bail out if (m_penetrationDepthSolver) { // Penetration depth case. btVector3 tmpPointOnA,tmpPointOnB; gNumDeepPenetrationChecks++; m_cachedSeparatingAxis.setZero(); bool isValid2 = m_penetrationDepthSolver->calcPenDepth( *m_simplexSolver, m_minkowskiA,m_minkowskiB, localTransA,localTransB, m_cachedSeparatingAxis, tmpPointOnA, tmpPointOnB, debugDraw ); if (isValid2) { btVector3 tmpNormalInB = tmpPointOnB-tmpPointOnA; btScalar lenSqr = tmpNormalInB.length2(); if (lenSqr <= (SIMD_EPSILON*SIMD_EPSILON)) { tmpNormalInB = m_cachedSeparatingAxis; lenSqr = m_cachedSeparatingAxis.length2(); } if (lenSqr > (SIMD_EPSILON*SIMD_EPSILON)) { tmpNormalInB /= btSqrt(lenSqr); btScalar distance2 = -(tmpPointOnA-tmpPointOnB).length(); m_lastUsedMethod = 3; //only replace valid penetrations when the result is deeper (check) if (!isValid || (distance2 < distance)) { distance = distance2; pointOnA = tmpPointOnA; pointOnB = tmpPointOnB; normalInB = tmpNormalInB; isValid = true; } else { m_lastUsedMethod = 8; } } else { m_lastUsedMethod = 9; } } else { ///this is another degenerate case, where the initial GJK calculation reports a degenerate case ///EPA reports no penetration, and the second GJK (using the supporting vector without margin) ///reports a valid positive distance. Use the results of the second GJK instead of failing. ///thanks to Jacob.Langford for the reproduction case ///http://code.google.com/p/bullet/issues/detail?id=250 if (m_cachedSeparatingAxis.length2() > btScalar(0.)) { btScalar distance2 = (tmpPointOnA-tmpPointOnB).length()-margin; //only replace valid distances when the distance is less if (!isValid || (distance2 < distance)) { distance = distance2; pointOnA = tmpPointOnA; pointOnB = tmpPointOnB; pointOnA -= m_cachedSeparatingAxis * marginA ; pointOnB += m_cachedSeparatingAxis * marginB ; normalInB = m_cachedSeparatingAxis; normalInB.normalize(); isValid = true; m_lastUsedMethod = 6; } else { m_lastUsedMethod = 5; } } } } } } if (isValid && ((distance < 0) || (distance*distance < input.m_maximumDistanceSquared))) { m_cachedSeparatingAxis = normalInB; m_cachedSeparatingDistance = distance; { ///todo: need to track down this EPA penetration solver degeneracy ///the penetration solver reports penetration but the contact normal ///connecting the contact points is pointing in the opposite direction ///until then, detect the issue and revert the normal btScalar d1=0; { btVector3 seperatingAxisInA = (normalInB)* input.m_transformA.getBasis(); btVector3 seperatingAxisInB = -normalInB* input.m_transformB.getBasis(); btVector3 pInA = m_minkowskiA->localGetSupportVertexWithoutMarginNonVirtual(seperatingAxisInA); btVector3 qInB = m_minkowskiB->localGetSupportVertexWithoutMarginNonVirtual(seperatingAxisInB); btVector3 pWorld = localTransA(pInA); btVector3 qWorld = localTransB(qInB); btVector3 w = pWorld - qWorld; d1 = (-normalInB).dot(w); } btScalar d0 = 0.f; { btVector3 seperatingAxisInA = (-normalInB)* input.m_transformA.getBasis(); btVector3 seperatingAxisInB = normalInB* input.m_transformB.getBasis(); btVector3 pInA = m_minkowskiA->localGetSupportVertexWithoutMarginNonVirtual(seperatingAxisInA); btVector3 qInB = m_minkowskiB->localGetSupportVertexWithoutMarginNonVirtual(seperatingAxisInB); btVector3 pWorld = localTransA(pInA); btVector3 qWorld = localTransB(qInB); btVector3 w = pWorld - qWorld; d0 = normalInB.dot(w); } if (d1>d0) { m_lastUsedMethod = 10; normalInB*=-1; } } output.addContactPoint( normalInB, pointOnB+positionOffset, distance); } }
/* Bullet Continuous Collision Detection and Physics Library Copyright (c) 2003-2006 Erwin Coumans http://continuousphysics.com/Bullet/ This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. */ #include "btGjkPairDetector.h" #include "BulletCollision/CollisionShapes/btConvexShape.h" #include "BulletCollision/NarrowPhaseCollision/btSimplexSolverInterface.h" #include "BulletCollision/NarrowPhaseCollision/btConvexPenetrationDepthSolver.h" #if defined(DEBUG) || defined (_DEBUG) //#define TEST_NON_VIRTUAL 1 #include <stdio.h> //for debug printf #ifdef __SPU__ #include <spu_printf.h> #define printf spu_printf #endif //__SPU__ #endif //must be above the machine epsilon #ifdef BT_USE_DOUBLE_PRECISION #define REL_ERROR2 btScalar(1.0e-12) btScalar gGjkEpaPenetrationTolerance = 1e-7; #else #define REL_ERROR2 btScalar(1.0e-6) btScalar gGjkEpaPenetrationTolerance = 0.001; #endif //temp globals, to improve GJK/EPA/penetration calculations int gNumDeepPenetrationChecks = 0; int gNumGjkChecks = 0; btGjkPairDetector::btGjkPairDetector(const btConvexShape* objectA,const btConvexShape* objectB,btSimplexSolverInterface* simplexSolver,btConvexPenetrationDepthSolver* penetrationDepthSolver) :m_cachedSeparatingAxis(btScalar(0.),btScalar(1.),btScalar(0.)), m_penetrationDepthSolver(penetrationDepthSolver), m_simplexSolver(simplexSolver), m_minkowskiA(objectA), m_minkowskiB(objectB), m_shapeTypeA(objectA->getShapeType()), m_shapeTypeB(objectB->getShapeType()), m_marginA(objectA->getMargin()), m_marginB(objectB->getMargin()), m_ignoreMargin(false), m_lastUsedMethod(-1), m_catchDegeneracies(1), m_fixContactNormalDirection(1) { } btGjkPairDetector::btGjkPairDetector(const btConvexShape* objectA,const btConvexShape* objectB,int shapeTypeA,int shapeTypeB,btScalar marginA, btScalar marginB, btSimplexSolverInterface* simplexSolver,btConvexPenetrationDepthSolver* penetrationDepthSolver) :m_cachedSeparatingAxis(btScalar(0.),btScalar(1.),btScalar(0.)), m_penetrationDepthSolver(penetrationDepthSolver), m_simplexSolver(simplexSolver), m_minkowskiA(objectA), m_minkowskiB(objectB), m_shapeTypeA(shapeTypeA), m_shapeTypeB(shapeTypeB), m_marginA(marginA), m_marginB(marginB), m_ignoreMargin(false), m_lastUsedMethod(-1), m_catchDegeneracies(1), m_fixContactNormalDirection(1) { } void btGjkPairDetector::getClosestPoints(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw,bool swapResults) { (void)swapResults; getClosestPointsNonVirtual(input,output,debugDraw); } #ifdef __SPU__ void btGjkPairDetector::getClosestPointsNonVirtual(const ClosestPointInput& input,Result& output,class btIDebugDraw* debugDraw) #else void btGjkPairDetector::getClosestPointsNonVirtual(const ClosestPointInput& input, Result& output, class btIDebugDraw* debugDraw) #endif { m_cachedSeparatingDistance = 0.f; btScalar distance=btScalar(0.); btVector3 normalInB(btScalar(0.),btScalar(0.),btScalar(0.)); btVector3 pointOnA,pointOnB; btTransform localTransA = input.m_transformA; btTransform localTransB = input.m_transformB; btVector3 positionOffset=(localTransA.getOrigin() + localTransB.getOrigin()) * btScalar(0.5); localTransA.getOrigin() -= positionOffset; localTransB.getOrigin() -= positionOffset; bool check2d = m_minkowskiA->isConvex2d() && m_minkowskiB->isConvex2d(); btScalar marginA = m_marginA; btScalar marginB = m_marginB; gNumGjkChecks++; //for CCD we don't use margins if (m_ignoreMargin) { marginA = btScalar(0.); marginB = btScalar(0.); } m_curIter = 0; int gGjkMaxIter = 1000;//this is to catch invalid input, perhaps check for #NaN? m_cachedSeparatingAxis.setValue(0,1,0); bool isValid = false; bool checkSimplex = false; bool checkPenetration = true; m_degenerateSimplex = 0; m_lastUsedMethod = -1; { btScalar squaredDistance = BT_LARGE_FLOAT; btScalar delta = btScalar(0.); btScalar margin = marginA + marginB; m_simplexSolver->reset(); for ( ; ; ) //while (true) { btVector3 seperatingAxisInA = (-m_cachedSeparatingAxis)* input.m_transformA.getBasis(); btVector3 seperatingAxisInB = m_cachedSeparatingAxis* input.m_transformB.getBasis(); btVector3 pInA = m_minkowskiA->localGetSupportVertexWithoutMarginNonVirtual(seperatingAxisInA); btVector3 qInB = m_minkowskiB->localGetSupportVertexWithoutMarginNonVirtual(seperatingAxisInB); btVector3 pWorld = localTransA(pInA); btVector3 qWorld = localTransB(qInB); if (check2d) { pWorld[2] = 0.f; qWorld[2] = 0.f; } btVector3 w = pWorld - qWorld; delta = m_cachedSeparatingAxis.dot(w); // potential exit, they don't overlap if ((delta > btScalar(0.0)) && (delta * delta > squaredDistance * input.m_maximumDistanceSquared)) { m_degenerateSimplex = 10; checkSimplex=true; //checkPenetration = false; break; } //exit 0: the new point is already in the simplex, or we didn't come any closer if (m_simplexSolver->inSimplex(w)) { m_degenerateSimplex = 1; checkSimplex = true; break; } // are we getting any closer ? btScalar f0 = squaredDistance - delta; btScalar f1 = squaredDistance * REL_ERROR2; if (f0 <= f1) { if (f0 <= btScalar(0.)) { m_degenerateSimplex = 2; } else { m_degenerateSimplex = 11; } checkSimplex = true; break; } //add current vertex to simplex m_simplexSolver->addVertex(w, pWorld, qWorld); btVector3 newCachedSeparatingAxis; //calculate the closest point to the origin (update vector v) if (!m_simplexSolver->closest(newCachedSeparatingAxis)) { m_degenerateSimplex = 3; checkSimplex = true; break; } if(newCachedSeparatingAxis.length2()<REL_ERROR2) { m_cachedSeparatingAxis = newCachedSeparatingAxis; m_degenerateSimplex = 6; checkSimplex = true; break; } btScalar previousSquaredDistance = squaredDistance; squaredDistance = newCachedSeparatingAxis.length2(); #if 0 ///warning: this termination condition leads to some problems in 2d test case see Bullet/Demos/Box2dDemo if (squaredDistance>previousSquaredDistance) { m_degenerateSimplex = 7; squaredDistance = previousSquaredDistance; checkSimplex = false; break; } #endif // //redundant m_simplexSolver->compute_points(pointOnA, pointOnB); //are we getting any closer ? if (previousSquaredDistance - squaredDistance <= SIMD_EPSILON * previousSquaredDistance) { // m_simplexSolver->backup_closest(m_cachedSeparatingAxis); checkSimplex = true; m_degenerateSimplex = 12; break; } m_cachedSeparatingAxis = newCachedSeparatingAxis; //degeneracy, this is typically due to invalid/uninitialized worldtransforms for a btCollisionObject if (m_curIter++ > gGjkMaxIter) { #if defined(DEBUG) || defined (_DEBUG) printf("btGjkPairDetector maxIter exceeded:%i\n",m_curIter); printf("sepAxis=(%f,%f,%f), squaredDistance = %f, shapeTypeA=%i,shapeTypeB=%i\n", m_cachedSeparatingAxis.getX(), m_cachedSeparatingAxis.getY(), m_cachedSeparatingAxis.getZ(), squaredDistance, m_minkowskiA->getShapeType(), m_minkowskiB->getShapeType()); #endif break; } bool check = (!m_simplexSolver->fullSimplex()); //bool check = (!m_simplexSolver->fullSimplex() && squaredDistance > SIMD_EPSILON * m_simplexSolver->maxVertex()); if (!check) { //do we need this backup_closest here ? // m_simplexSolver->backup_closest(m_cachedSeparatingAxis); m_degenerateSimplex = 13; break; } } if (checkSimplex) { m_simplexSolver->compute_points(pointOnA, pointOnB); normalInB = m_cachedSeparatingAxis; btScalar lenSqr =m_cachedSeparatingAxis.length2(); //valid normal if (lenSqr < REL_ERROR2) { m_degenerateSimplex = 5; } if (lenSqr > SIMD_EPSILON*SIMD_EPSILON) { btScalar rlen = btScalar(1.) / btSqrt(lenSqr ); normalInB *= rlen; //normalize btScalar s = btSqrt(squaredDistance); btAssert(s > btScalar(0.0)); pointOnA -= m_cachedSeparatingAxis * (marginA / s); pointOnB += m_cachedSeparatingAxis * (marginB / s); distance = ((btScalar(1.)/rlen) - margin); isValid = true; m_lastUsedMethod = 1; } else { m_lastUsedMethod = 2; } } bool catchDegeneratePenetrationCase = (m_catchDegeneracies && m_penetrationDepthSolver && m_degenerateSimplex && ((distance+margin) < gGjkEpaPenetrationTolerance)); //if (checkPenetration && !isValid) if (checkPenetration && (!isValid || catchDegeneratePenetrationCase )) { //penetration case //if there is no way to handle penetrations, bail out if (m_penetrationDepthSolver) { // Penetration depth case. btVector3 tmpPointOnA,tmpPointOnB; gNumDeepPenetrationChecks++; m_cachedSeparatingAxis.setZero(); bool isValid2 = m_penetrationDepthSolver->calcPenDepth( *m_simplexSolver, m_minkowskiA,m_minkowskiB, localTransA,localTransB, m_cachedSeparatingAxis, tmpPointOnA, tmpPointOnB, debugDraw ); if (isValid2) { btVector3 tmpNormalInB = tmpPointOnB-tmpPointOnA; btScalar lenSqr = tmpNormalInB.length2(); if (lenSqr <= (SIMD_EPSILON*SIMD_EPSILON)) { tmpNormalInB = m_cachedSeparatingAxis; lenSqr = m_cachedSeparatingAxis.length2(); } if (lenSqr > (SIMD_EPSILON*SIMD_EPSILON)) { tmpNormalInB /= btSqrt(lenSqr); btScalar distance2 = -(tmpPointOnA-tmpPointOnB).length(); m_lastUsedMethod = 3; //only replace valid penetrations when the result is deeper (check) if (!isValid || (distance2 < distance)) { distance = distance2; pointOnA = tmpPointOnA; pointOnB = tmpPointOnB; normalInB = tmpNormalInB; isValid = true; } else { m_lastUsedMethod = 8; } } else { m_lastUsedMethod = 9; } } else { ///this is another degenerate case, where the initial GJK calculation reports a degenerate case ///EPA reports no penetration, and the second GJK (using the supporting vector without margin) ///reports a valid positive distance. Use the results of the second GJK instead of failing. ///thanks to Jacob.Langford for the reproduction case ///http://code.google.com/p/bullet/issues/detail?id=250 if (m_cachedSeparatingAxis.length2() > btScalar(0.)) { btScalar distance2 = (tmpPointOnA-tmpPointOnB).length()-margin; //only replace valid distances when the distance is less if (!isValid || (distance2 < distance)) { distance = distance2; pointOnA = tmpPointOnA; pointOnB = tmpPointOnB; pointOnA -= m_cachedSeparatingAxis * marginA ; pointOnB += m_cachedSeparatingAxis * marginB ; normalInB = m_cachedSeparatingAxis; normalInB.normalize(); isValid = true; m_lastUsedMethod = 6; } else { m_lastUsedMethod = 5; } } } } } } if (isValid && ((distance < 0) || (distance*distance < input.m_maximumDistanceSquared))) { m_cachedSeparatingAxis = normalInB; m_cachedSeparatingDistance = distance; { ///todo: need to track down this EPA penetration solver degeneracy ///the penetration solver reports penetration but the contact normal ///connecting the contact points is pointing in the opposite direction ///until then, detect the issue and revert the normal btScalar d1=0; { btVector3 seperatingAxisInA = (normalInB)* input.m_transformA.getBasis(); btVector3 seperatingAxisInB = -normalInB* input.m_transformB.getBasis(); btVector3 pInA = m_minkowskiA->localGetSupportVertexWithoutMarginNonVirtual(seperatingAxisInA); btVector3 qInB = m_minkowskiB->localGetSupportVertexWithoutMarginNonVirtual(seperatingAxisInB); btVector3 pWorld = localTransA(pInA); btVector3 qWorld = localTransB(qInB); btVector3 w = pWorld - qWorld; d1 = (-normalInB).dot(w); } btScalar d0 = 0.f; { btVector3 seperatingAxisInA = (-normalInB)* input.m_transformA.getBasis(); btVector3 seperatingAxisInB = normalInB* input.m_transformB.getBasis(); btVector3 pInA = m_minkowskiA->localGetSupportVertexWithoutMarginNonVirtual(seperatingAxisInA); btVector3 qInB = m_minkowskiB->localGetSupportVertexWithoutMarginNonVirtual(seperatingAxisInB); btVector3 pWorld = localTransA(pInA); btVector3 qWorld = localTransB(qInB); btVector3 w = pWorld - qWorld; d0 = normalInB.dot(w); } if (d1>d0) { m_lastUsedMethod = 10; normalInB*=-1; } } output.addContactPoint( normalInB, pointOnB+positionOffset, distance); } }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./extensions/gdx-box2d/gdx-box2d-gwt/src/com/badlogic/gdx/physics/box2d/gwt/emu/org/jbox2d/common/RaycastResult.java
/******************************************************************************* * Copyright (c) 2013, Daniel Murphy * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. ******************************************************************************/ package org.jbox2d.common; // updated to rev 100 public class RaycastResult { public float lambda = 0.0f; public final Vec2 normal = new Vec2(); public RaycastResult set (RaycastResult argOther) { lambda = argOther.lambda; normal.set(argOther.normal); return this; } }
/******************************************************************************* * Copyright (c) 2013, Daniel Murphy * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. ******************************************************************************/ package org.jbox2d.common; // updated to rev 100 public class RaycastResult { public float lambda = 0.0f; public final Vec2 normal = new Vec2(); public RaycastResult set (RaycastResult argOther) { lambda = argOther.lambda; normal.set(argOther.normal); return this; } }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./extensions/gdx-bullet/jni/swig-src/linearmath/com/badlogic/gdx/physics/bullet/linearmath/btDefaultSerializer.java
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.linearmath; public class btDefaultSerializer extends btSerializer { private long swigCPtr; protected btDefaultSerializer (final String className, long cPtr, boolean cMemoryOwn) { super(className, LinearMathJNI.btDefaultSerializer_SWIGUpcast(cPtr), cMemoryOwn); swigCPtr = cPtr; } /** Construct a new btDefaultSerializer, normally you should not need this constructor it's intended for low-level usage. */ public btDefaultSerializer (long cPtr, boolean cMemoryOwn) { this("btDefaultSerializer", cPtr, cMemoryOwn); construct(); } @Override protected void reset (long cPtr, boolean cMemoryOwn) { if (!destroyed) destroy(); super.reset(LinearMathJNI.btDefaultSerializer_SWIGUpcast(swigCPtr = cPtr), cMemoryOwn); } public static long getCPtr (btDefaultSerializer obj) { return (obj == null) ? 0 : obj.swigCPtr; } @Override protected void finalize () throws Throwable { if (!destroyed) destroy(); super.finalize(); } @Override protected synchronized void delete () { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; LinearMathJNI.delete_btDefaultSerializer(swigCPtr); } swigCPtr = 0; } super.delete(); } public SWIGTYPE_p_btHashMapT_btHashPtr_void_p_t getSkipPointers () { long cPtr = LinearMathJNI.btDefaultSerializer_skipPointers_get(swigCPtr, this); return (cPtr == 0) ? null : new SWIGTYPE_p_btHashMapT_btHashPtr_void_p_t(cPtr, false); } static private long SwigConstructbtDefaultSerializer (int totalSize, java.nio.ByteBuffer buffer) { assert buffer.isDirect() : "Buffer must be allocated direct."; return LinearMathJNI.new_btDefaultSerializer__SWIG_0(totalSize, buffer); } public btDefaultSerializer (int totalSize, java.nio.ByteBuffer buffer) { this(btDefaultSerializer.SwigConstructbtDefaultSerializer(totalSize, buffer), true); } public btDefaultSerializer (int totalSize) { this(LinearMathJNI.new_btDefaultSerializer__SWIG_1(totalSize), true); } public btDefaultSerializer () { this(LinearMathJNI.new_btDefaultSerializer__SWIG_2(), true); } public static int getMemoryDnaSizeInBytes () { return LinearMathJNI.btDefaultSerializer_getMemoryDnaSizeInBytes(); } public static String getMemoryDna () { return LinearMathJNI.btDefaultSerializer_getMemoryDna(); } public void insertHeader () { LinearMathJNI.btDefaultSerializer_insertHeader(swigCPtr, this); } public void writeHeader (java.nio.ByteBuffer buffer) { assert buffer.isDirect() : "Buffer must be allocated direct."; { LinearMathJNI.btDefaultSerializer_writeHeader(swigCPtr, this, buffer); } } public java.nio.ByteBuffer internalAlloc (long size) { return LinearMathJNI.btDefaultSerializer_internalAlloc(swigCPtr, this, size); } }
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.linearmath; public class btDefaultSerializer extends btSerializer { private long swigCPtr; protected btDefaultSerializer (final String className, long cPtr, boolean cMemoryOwn) { super(className, LinearMathJNI.btDefaultSerializer_SWIGUpcast(cPtr), cMemoryOwn); swigCPtr = cPtr; } /** Construct a new btDefaultSerializer, normally you should not need this constructor it's intended for low-level usage. */ public btDefaultSerializer (long cPtr, boolean cMemoryOwn) { this("btDefaultSerializer", cPtr, cMemoryOwn); construct(); } @Override protected void reset (long cPtr, boolean cMemoryOwn) { if (!destroyed) destroy(); super.reset(LinearMathJNI.btDefaultSerializer_SWIGUpcast(swigCPtr = cPtr), cMemoryOwn); } public static long getCPtr (btDefaultSerializer obj) { return (obj == null) ? 0 : obj.swigCPtr; } @Override protected void finalize () throws Throwable { if (!destroyed) destroy(); super.finalize(); } @Override protected synchronized void delete () { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; LinearMathJNI.delete_btDefaultSerializer(swigCPtr); } swigCPtr = 0; } super.delete(); } public SWIGTYPE_p_btHashMapT_btHashPtr_void_p_t getSkipPointers () { long cPtr = LinearMathJNI.btDefaultSerializer_skipPointers_get(swigCPtr, this); return (cPtr == 0) ? null : new SWIGTYPE_p_btHashMapT_btHashPtr_void_p_t(cPtr, false); } static private long SwigConstructbtDefaultSerializer (int totalSize, java.nio.ByteBuffer buffer) { assert buffer.isDirect() : "Buffer must be allocated direct."; return LinearMathJNI.new_btDefaultSerializer__SWIG_0(totalSize, buffer); } public btDefaultSerializer (int totalSize, java.nio.ByteBuffer buffer) { this(btDefaultSerializer.SwigConstructbtDefaultSerializer(totalSize, buffer), true); } public btDefaultSerializer (int totalSize) { this(LinearMathJNI.new_btDefaultSerializer__SWIG_1(totalSize), true); } public btDefaultSerializer () { this(LinearMathJNI.new_btDefaultSerializer__SWIG_2(), true); } public static int getMemoryDnaSizeInBytes () { return LinearMathJNI.btDefaultSerializer_getMemoryDnaSizeInBytes(); } public static String getMemoryDna () { return LinearMathJNI.btDefaultSerializer_getMemoryDna(); } public void insertHeader () { LinearMathJNI.btDefaultSerializer_insertHeader(swigCPtr, this); } public void writeHeader (java.nio.ByteBuffer buffer) { assert buffer.isDirect() : "Buffer must be allocated direct."; { LinearMathJNI.btDefaultSerializer_writeHeader(swigCPtr, this, buffer); } } public java.nio.ByteBuffer internalAlloc (long size) { return LinearMathJNI.btDefaultSerializer_internalAlloc(swigCPtr, this, size); } }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./extensions/gdx-bullet/jni/swig-src/softbody/com/badlogic/gdx/physics/bullet/softbody/SWIGTYPE_p_btAlignedObjectArrayT_int_t.java
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.softbody; public class SWIGTYPE_p_btAlignedObjectArrayT_int_t { private transient long swigCPtr; protected SWIGTYPE_p_btAlignedObjectArrayT_int_t (long cPtr, @SuppressWarnings("unused") boolean futureUse) { swigCPtr = cPtr; } protected SWIGTYPE_p_btAlignedObjectArrayT_int_t () { swigCPtr = 0; } protected static long getCPtr (SWIGTYPE_p_btAlignedObjectArrayT_int_t obj) { return (obj == null) ? 0 : obj.swigCPtr; } }
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.softbody; public class SWIGTYPE_p_btAlignedObjectArrayT_int_t { private transient long swigCPtr; protected SWIGTYPE_p_btAlignedObjectArrayT_int_t (long cPtr, @SuppressWarnings("unused") boolean futureUse) { swigCPtr = cPtr; } protected SWIGTYPE_p_btAlignedObjectArrayT_int_t () { swigCPtr = 0; } protected static long getCPtr (SWIGTYPE_p_btAlignedObjectArrayT_int_t obj) { return (obj == null) ? 0 : obj.swigCPtr; } }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./extensions/gdx-box2d/gdx-box2d/jni/Box2D/Dynamics/Joints/b2PulleyJoint.cpp
/* * Copyright (c) 2007 Erin Catto http://www.box2d.org * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages * arising from the use of this software. * Permission is granted to anyone to use this software for any purpose, * including commercial applications, and to alter it and redistribute it * freely, subject to the following restrictions: * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software * in a product, an acknowledgment in the product documentation would be * appreciated but is not required. * 2. Altered source versions must be plainly marked as such, and must not be * misrepresented as being the original software. * 3. This notice may not be removed or altered from any source distribution. */ #include <Box2D/Dynamics/Joints/b2PulleyJoint.h> #include <Box2D/Dynamics/b2Body.h> #include <Box2D/Dynamics/b2TimeStep.h> // Pulley: // length1 = norm(p1 - s1) // length2 = norm(p2 - s2) // C0 = (length1 + ratio * length2)_initial // C = C0 - (length1 + ratio * length2) // u1 = (p1 - s1) / norm(p1 - s1) // u2 = (p2 - s2) / norm(p2 - s2) // Cdot = -dot(u1, v1 + cross(w1, r1)) - ratio * dot(u2, v2 + cross(w2, r2)) // J = -[u1 cross(r1, u1) ratio * u2 ratio * cross(r2, u2)] // K = J * invM * JT // = invMass1 + invI1 * cross(r1, u1)^2 + ratio^2 * (invMass2 + invI2 * cross(r2, u2)^2) void b2PulleyJointDef::Initialize(b2Body* bA, b2Body* bB, const b2Vec2& groundA, const b2Vec2& groundB, const b2Vec2& anchorA, const b2Vec2& anchorB, float32 r) { bodyA = bA; bodyB = bB; groundAnchorA = groundA; groundAnchorB = groundB; localAnchorA = bodyA->GetLocalPoint(anchorA); localAnchorB = bodyB->GetLocalPoint(anchorB); b2Vec2 dA = anchorA - groundA; lengthA = dA.Length(); b2Vec2 dB = anchorB - groundB; lengthB = dB.Length(); ratio = r; b2Assert(ratio > b2_epsilon); } b2PulleyJoint::b2PulleyJoint(const b2PulleyJointDef* def) : b2Joint(def) { m_groundAnchorA = def->groundAnchorA; m_groundAnchorB = def->groundAnchorB; m_localAnchorA = def->localAnchorA; m_localAnchorB = def->localAnchorB; m_lengthA = def->lengthA; m_lengthB = def->lengthB; b2Assert(def->ratio != 0.0f); m_ratio = def->ratio; m_constant = def->lengthA + m_ratio * def->lengthB; m_impulse = 0.0f; } void b2PulleyJoint::InitVelocityConstraints(const b2SolverData& data) { m_indexA = m_bodyA->m_islandIndex; m_indexB = m_bodyB->m_islandIndex; m_localCenterA = m_bodyA->m_sweep.localCenter; m_localCenterB = m_bodyB->m_sweep.localCenter; m_invMassA = m_bodyA->m_invMass; m_invMassB = m_bodyB->m_invMass; m_invIA = m_bodyA->m_invI; m_invIB = m_bodyB->m_invI; b2Vec2 cA = data.positions[m_indexA].c; float32 aA = data.positions[m_indexA].a; b2Vec2 vA = data.velocities[m_indexA].v; float32 wA = data.velocities[m_indexA].w; b2Vec2 cB = data.positions[m_indexB].c; float32 aB = data.positions[m_indexB].a; b2Vec2 vB = data.velocities[m_indexB].v; float32 wB = data.velocities[m_indexB].w; b2Rot qA(aA), qB(aB); m_rA = b2Mul(qA, m_localAnchorA - m_localCenterA); m_rB = b2Mul(qB, m_localAnchorB - m_localCenterB); // Get the pulley axes. m_uA = cA + m_rA - m_groundAnchorA; m_uB = cB + m_rB - m_groundAnchorB; float32 lengthA = m_uA.Length(); float32 lengthB = m_uB.Length(); if (lengthA > 10.0f * b2_linearSlop) { m_uA *= 1.0f / lengthA; } else { m_uA.SetZero(); } if (lengthB > 10.0f * b2_linearSlop) { m_uB *= 1.0f / lengthB; } else { m_uB.SetZero(); } // Compute effective mass. float32 ruA = b2Cross(m_rA, m_uA); float32 ruB = b2Cross(m_rB, m_uB); float32 mA = m_invMassA + m_invIA * ruA * ruA; float32 mB = m_invMassB + m_invIB * ruB * ruB; m_mass = mA + m_ratio * m_ratio * mB; if (m_mass > 0.0f) { m_mass = 1.0f / m_mass; } if (data.step.warmStarting) { // Scale impulses to support variable time steps. m_impulse *= data.step.dtRatio; // Warm starting. b2Vec2 PA = -(m_impulse) * m_uA; b2Vec2 PB = (-m_ratio * m_impulse) * m_uB; vA += m_invMassA * PA; wA += m_invIA * b2Cross(m_rA, PA); vB += m_invMassB * PB; wB += m_invIB * b2Cross(m_rB, PB); } else { m_impulse = 0.0f; } data.velocities[m_indexA].v = vA; data.velocities[m_indexA].w = wA; data.velocities[m_indexB].v = vB; data.velocities[m_indexB].w = wB; } void b2PulleyJoint::SolveVelocityConstraints(const b2SolverData& data) { b2Vec2 vA = data.velocities[m_indexA].v; float32 wA = data.velocities[m_indexA].w; b2Vec2 vB = data.velocities[m_indexB].v; float32 wB = data.velocities[m_indexB].w; b2Vec2 vpA = vA + b2Cross(wA, m_rA); b2Vec2 vpB = vB + b2Cross(wB, m_rB); float32 Cdot = -b2Dot(m_uA, vpA) - m_ratio * b2Dot(m_uB, vpB); float32 impulse = -m_mass * Cdot; m_impulse += impulse; b2Vec2 PA = -impulse * m_uA; b2Vec2 PB = -m_ratio * impulse * m_uB; vA += m_invMassA * PA; wA += m_invIA * b2Cross(m_rA, PA); vB += m_invMassB * PB; wB += m_invIB * b2Cross(m_rB, PB); data.velocities[m_indexA].v = vA; data.velocities[m_indexA].w = wA; data.velocities[m_indexB].v = vB; data.velocities[m_indexB].w = wB; } bool b2PulleyJoint::SolvePositionConstraints(const b2SolverData& data) { b2Vec2 cA = data.positions[m_indexA].c; float32 aA = data.positions[m_indexA].a; b2Vec2 cB = data.positions[m_indexB].c; float32 aB = data.positions[m_indexB].a; b2Rot qA(aA), qB(aB); b2Vec2 rA = b2Mul(qA, m_localAnchorA - m_localCenterA); b2Vec2 rB = b2Mul(qB, m_localAnchorB - m_localCenterB); // Get the pulley axes. b2Vec2 uA = cA + rA - m_groundAnchorA; b2Vec2 uB = cB + rB - m_groundAnchorB; float32 lengthA = uA.Length(); float32 lengthB = uB.Length(); if (lengthA > 10.0f * b2_linearSlop) { uA *= 1.0f / lengthA; } else { uA.SetZero(); } if (lengthB > 10.0f * b2_linearSlop) { uB *= 1.0f / lengthB; } else { uB.SetZero(); } // Compute effective mass. float32 ruA = b2Cross(rA, uA); float32 ruB = b2Cross(rB, uB); float32 mA = m_invMassA + m_invIA * ruA * ruA; float32 mB = m_invMassB + m_invIB * ruB * ruB; float32 mass = mA + m_ratio * m_ratio * mB; if (mass > 0.0f) { mass = 1.0f / mass; } float32 C = m_constant - lengthA - m_ratio * lengthB; float32 linearError = b2Abs(C); float32 impulse = -mass * C; b2Vec2 PA = -impulse * uA; b2Vec2 PB = -m_ratio * impulse * uB; cA += m_invMassA * PA; aA += m_invIA * b2Cross(rA, PA); cB += m_invMassB * PB; aB += m_invIB * b2Cross(rB, PB); data.positions[m_indexA].c = cA; data.positions[m_indexA].a = aA; data.positions[m_indexB].c = cB; data.positions[m_indexB].a = aB; return linearError < b2_linearSlop; } b2Vec2 b2PulleyJoint::GetAnchorA() const { return m_bodyA->GetWorldPoint(m_localAnchorA); } b2Vec2 b2PulleyJoint::GetAnchorB() const { return m_bodyB->GetWorldPoint(m_localAnchorB); } b2Vec2 b2PulleyJoint::GetReactionForce(float32 inv_dt) const { b2Vec2 P = m_impulse * m_uB; return inv_dt * P; } float32 b2PulleyJoint::GetReactionTorque(float32 inv_dt) const { B2_NOT_USED(inv_dt); return 0.0f; } b2Vec2 b2PulleyJoint::GetGroundAnchorA() const { return m_groundAnchorA; } b2Vec2 b2PulleyJoint::GetGroundAnchorB() const { return m_groundAnchorB; } float32 b2PulleyJoint::GetLengthA() const { return m_lengthA; } float32 b2PulleyJoint::GetLengthB() const { return m_lengthB; } float32 b2PulleyJoint::GetRatio() const { return m_ratio; } float32 b2PulleyJoint::GetCurrentLengthA() const { b2Vec2 p = m_bodyA->GetWorldPoint(m_localAnchorA); b2Vec2 s = m_groundAnchorA; b2Vec2 d = p - s; return d.Length(); } float32 b2PulleyJoint::GetCurrentLengthB() const { b2Vec2 p = m_bodyB->GetWorldPoint(m_localAnchorB); b2Vec2 s = m_groundAnchorB; b2Vec2 d = p - s; return d.Length(); } void b2PulleyJoint::Dump() { int32 indexA = m_bodyA->m_islandIndex; int32 indexB = m_bodyB->m_islandIndex; b2Log(" b2PulleyJointDef jd;\n"); b2Log(" jd.bodyA = bodies[%d];\n", indexA); b2Log(" jd.bodyB = bodies[%d];\n", indexB); b2Log(" jd.collideConnected = bool(%d);\n", m_collideConnected); b2Log(" jd.groundAnchorA.Set(%.15lef, %.15lef);\n", m_groundAnchorA.x, m_groundAnchorA.y); b2Log(" jd.groundAnchorB.Set(%.15lef, %.15lef);\n", m_groundAnchorB.x, m_groundAnchorB.y); b2Log(" jd.localAnchorA.Set(%.15lef, %.15lef);\n", m_localAnchorA.x, m_localAnchorA.y); b2Log(" jd.localAnchorB.Set(%.15lef, %.15lef);\n", m_localAnchorB.x, m_localAnchorB.y); b2Log(" jd.lengthA = %.15lef;\n", m_lengthA); b2Log(" jd.lengthB = %.15lef;\n", m_lengthB); b2Log(" jd.ratio = %.15lef;\n", m_ratio); b2Log(" joints[%d] = m_world->CreateJoint(&jd);\n", m_index); } void b2PulleyJoint::ShiftOrigin(const b2Vec2& newOrigin) { m_groundAnchorA -= newOrigin; m_groundAnchorB -= newOrigin; }
/* * Copyright (c) 2007 Erin Catto http://www.box2d.org * * This software is provided 'as-is', without any express or implied * warranty. In no event will the authors be held liable for any damages * arising from the use of this software. * Permission is granted to anyone to use this software for any purpose, * including commercial applications, and to alter it and redistribute it * freely, subject to the following restrictions: * 1. The origin of this software must not be misrepresented; you must not * claim that you wrote the original software. If you use this software * in a product, an acknowledgment in the product documentation would be * appreciated but is not required. * 2. Altered source versions must be plainly marked as such, and must not be * misrepresented as being the original software. * 3. This notice may not be removed or altered from any source distribution. */ #include <Box2D/Dynamics/Joints/b2PulleyJoint.h> #include <Box2D/Dynamics/b2Body.h> #include <Box2D/Dynamics/b2TimeStep.h> // Pulley: // length1 = norm(p1 - s1) // length2 = norm(p2 - s2) // C0 = (length1 + ratio * length2)_initial // C = C0 - (length1 + ratio * length2) // u1 = (p1 - s1) / norm(p1 - s1) // u2 = (p2 - s2) / norm(p2 - s2) // Cdot = -dot(u1, v1 + cross(w1, r1)) - ratio * dot(u2, v2 + cross(w2, r2)) // J = -[u1 cross(r1, u1) ratio * u2 ratio * cross(r2, u2)] // K = J * invM * JT // = invMass1 + invI1 * cross(r1, u1)^2 + ratio^2 * (invMass2 + invI2 * cross(r2, u2)^2) void b2PulleyJointDef::Initialize(b2Body* bA, b2Body* bB, const b2Vec2& groundA, const b2Vec2& groundB, const b2Vec2& anchorA, const b2Vec2& anchorB, float32 r) { bodyA = bA; bodyB = bB; groundAnchorA = groundA; groundAnchorB = groundB; localAnchorA = bodyA->GetLocalPoint(anchorA); localAnchorB = bodyB->GetLocalPoint(anchorB); b2Vec2 dA = anchorA - groundA; lengthA = dA.Length(); b2Vec2 dB = anchorB - groundB; lengthB = dB.Length(); ratio = r; b2Assert(ratio > b2_epsilon); } b2PulleyJoint::b2PulleyJoint(const b2PulleyJointDef* def) : b2Joint(def) { m_groundAnchorA = def->groundAnchorA; m_groundAnchorB = def->groundAnchorB; m_localAnchorA = def->localAnchorA; m_localAnchorB = def->localAnchorB; m_lengthA = def->lengthA; m_lengthB = def->lengthB; b2Assert(def->ratio != 0.0f); m_ratio = def->ratio; m_constant = def->lengthA + m_ratio * def->lengthB; m_impulse = 0.0f; } void b2PulleyJoint::InitVelocityConstraints(const b2SolverData& data) { m_indexA = m_bodyA->m_islandIndex; m_indexB = m_bodyB->m_islandIndex; m_localCenterA = m_bodyA->m_sweep.localCenter; m_localCenterB = m_bodyB->m_sweep.localCenter; m_invMassA = m_bodyA->m_invMass; m_invMassB = m_bodyB->m_invMass; m_invIA = m_bodyA->m_invI; m_invIB = m_bodyB->m_invI; b2Vec2 cA = data.positions[m_indexA].c; float32 aA = data.positions[m_indexA].a; b2Vec2 vA = data.velocities[m_indexA].v; float32 wA = data.velocities[m_indexA].w; b2Vec2 cB = data.positions[m_indexB].c; float32 aB = data.positions[m_indexB].a; b2Vec2 vB = data.velocities[m_indexB].v; float32 wB = data.velocities[m_indexB].w; b2Rot qA(aA), qB(aB); m_rA = b2Mul(qA, m_localAnchorA - m_localCenterA); m_rB = b2Mul(qB, m_localAnchorB - m_localCenterB); // Get the pulley axes. m_uA = cA + m_rA - m_groundAnchorA; m_uB = cB + m_rB - m_groundAnchorB; float32 lengthA = m_uA.Length(); float32 lengthB = m_uB.Length(); if (lengthA > 10.0f * b2_linearSlop) { m_uA *= 1.0f / lengthA; } else { m_uA.SetZero(); } if (lengthB > 10.0f * b2_linearSlop) { m_uB *= 1.0f / lengthB; } else { m_uB.SetZero(); } // Compute effective mass. float32 ruA = b2Cross(m_rA, m_uA); float32 ruB = b2Cross(m_rB, m_uB); float32 mA = m_invMassA + m_invIA * ruA * ruA; float32 mB = m_invMassB + m_invIB * ruB * ruB; m_mass = mA + m_ratio * m_ratio * mB; if (m_mass > 0.0f) { m_mass = 1.0f / m_mass; } if (data.step.warmStarting) { // Scale impulses to support variable time steps. m_impulse *= data.step.dtRatio; // Warm starting. b2Vec2 PA = -(m_impulse) * m_uA; b2Vec2 PB = (-m_ratio * m_impulse) * m_uB; vA += m_invMassA * PA; wA += m_invIA * b2Cross(m_rA, PA); vB += m_invMassB * PB; wB += m_invIB * b2Cross(m_rB, PB); } else { m_impulse = 0.0f; } data.velocities[m_indexA].v = vA; data.velocities[m_indexA].w = wA; data.velocities[m_indexB].v = vB; data.velocities[m_indexB].w = wB; } void b2PulleyJoint::SolveVelocityConstraints(const b2SolverData& data) { b2Vec2 vA = data.velocities[m_indexA].v; float32 wA = data.velocities[m_indexA].w; b2Vec2 vB = data.velocities[m_indexB].v; float32 wB = data.velocities[m_indexB].w; b2Vec2 vpA = vA + b2Cross(wA, m_rA); b2Vec2 vpB = vB + b2Cross(wB, m_rB); float32 Cdot = -b2Dot(m_uA, vpA) - m_ratio * b2Dot(m_uB, vpB); float32 impulse = -m_mass * Cdot; m_impulse += impulse; b2Vec2 PA = -impulse * m_uA; b2Vec2 PB = -m_ratio * impulse * m_uB; vA += m_invMassA * PA; wA += m_invIA * b2Cross(m_rA, PA); vB += m_invMassB * PB; wB += m_invIB * b2Cross(m_rB, PB); data.velocities[m_indexA].v = vA; data.velocities[m_indexA].w = wA; data.velocities[m_indexB].v = vB; data.velocities[m_indexB].w = wB; } bool b2PulleyJoint::SolvePositionConstraints(const b2SolverData& data) { b2Vec2 cA = data.positions[m_indexA].c; float32 aA = data.positions[m_indexA].a; b2Vec2 cB = data.positions[m_indexB].c; float32 aB = data.positions[m_indexB].a; b2Rot qA(aA), qB(aB); b2Vec2 rA = b2Mul(qA, m_localAnchorA - m_localCenterA); b2Vec2 rB = b2Mul(qB, m_localAnchorB - m_localCenterB); // Get the pulley axes. b2Vec2 uA = cA + rA - m_groundAnchorA; b2Vec2 uB = cB + rB - m_groundAnchorB; float32 lengthA = uA.Length(); float32 lengthB = uB.Length(); if (lengthA > 10.0f * b2_linearSlop) { uA *= 1.0f / lengthA; } else { uA.SetZero(); } if (lengthB > 10.0f * b2_linearSlop) { uB *= 1.0f / lengthB; } else { uB.SetZero(); } // Compute effective mass. float32 ruA = b2Cross(rA, uA); float32 ruB = b2Cross(rB, uB); float32 mA = m_invMassA + m_invIA * ruA * ruA; float32 mB = m_invMassB + m_invIB * ruB * ruB; float32 mass = mA + m_ratio * m_ratio * mB; if (mass > 0.0f) { mass = 1.0f / mass; } float32 C = m_constant - lengthA - m_ratio * lengthB; float32 linearError = b2Abs(C); float32 impulse = -mass * C; b2Vec2 PA = -impulse * uA; b2Vec2 PB = -m_ratio * impulse * uB; cA += m_invMassA * PA; aA += m_invIA * b2Cross(rA, PA); cB += m_invMassB * PB; aB += m_invIB * b2Cross(rB, PB); data.positions[m_indexA].c = cA; data.positions[m_indexA].a = aA; data.positions[m_indexB].c = cB; data.positions[m_indexB].a = aB; return linearError < b2_linearSlop; } b2Vec2 b2PulleyJoint::GetAnchorA() const { return m_bodyA->GetWorldPoint(m_localAnchorA); } b2Vec2 b2PulleyJoint::GetAnchorB() const { return m_bodyB->GetWorldPoint(m_localAnchorB); } b2Vec2 b2PulleyJoint::GetReactionForce(float32 inv_dt) const { b2Vec2 P = m_impulse * m_uB; return inv_dt * P; } float32 b2PulleyJoint::GetReactionTorque(float32 inv_dt) const { B2_NOT_USED(inv_dt); return 0.0f; } b2Vec2 b2PulleyJoint::GetGroundAnchorA() const { return m_groundAnchorA; } b2Vec2 b2PulleyJoint::GetGroundAnchorB() const { return m_groundAnchorB; } float32 b2PulleyJoint::GetLengthA() const { return m_lengthA; } float32 b2PulleyJoint::GetLengthB() const { return m_lengthB; } float32 b2PulleyJoint::GetRatio() const { return m_ratio; } float32 b2PulleyJoint::GetCurrentLengthA() const { b2Vec2 p = m_bodyA->GetWorldPoint(m_localAnchorA); b2Vec2 s = m_groundAnchorA; b2Vec2 d = p - s; return d.Length(); } float32 b2PulleyJoint::GetCurrentLengthB() const { b2Vec2 p = m_bodyB->GetWorldPoint(m_localAnchorB); b2Vec2 s = m_groundAnchorB; b2Vec2 d = p - s; return d.Length(); } void b2PulleyJoint::Dump() { int32 indexA = m_bodyA->m_islandIndex; int32 indexB = m_bodyB->m_islandIndex; b2Log(" b2PulleyJointDef jd;\n"); b2Log(" jd.bodyA = bodies[%d];\n", indexA); b2Log(" jd.bodyB = bodies[%d];\n", indexB); b2Log(" jd.collideConnected = bool(%d);\n", m_collideConnected); b2Log(" jd.groundAnchorA.Set(%.15lef, %.15lef);\n", m_groundAnchorA.x, m_groundAnchorA.y); b2Log(" jd.groundAnchorB.Set(%.15lef, %.15lef);\n", m_groundAnchorB.x, m_groundAnchorB.y); b2Log(" jd.localAnchorA.Set(%.15lef, %.15lef);\n", m_localAnchorA.x, m_localAnchorA.y); b2Log(" jd.localAnchorB.Set(%.15lef, %.15lef);\n", m_localAnchorB.x, m_localAnchorB.y); b2Log(" jd.lengthA = %.15lef;\n", m_lengthA); b2Log(" jd.lengthB = %.15lef;\n", m_lengthB); b2Log(" jd.ratio = %.15lef;\n", m_ratio); b2Log(" joints[%d] = m_world->CreateJoint(&jd);\n", m_index); } void b2PulleyJoint::ShiftOrigin(const b2Vec2& newOrigin) { m_groundAnchorA -= newOrigin; m_groundAnchorB -= newOrigin; }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./extensions/gdx-bullet/jni/swig-src/dynamics/com/badlogic/gdx/physics/bullet/dynamics/btDynamicsWorldDoubleData.java
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.dynamics; import com.badlogic.gdx.physics.bullet.BulletBase; import com.badlogic.gdx.physics.bullet.linearmath.*; import com.badlogic.gdx.physics.bullet.collision.*; public class btDynamicsWorldDoubleData extends BulletBase { private long swigCPtr; protected btDynamicsWorldDoubleData (final String className, long cPtr, boolean cMemoryOwn) { super(className, cPtr, cMemoryOwn); swigCPtr = cPtr; } /** Construct a new btDynamicsWorldDoubleData, normally you should not need this constructor it's intended for low-level * usage. */ public btDynamicsWorldDoubleData (long cPtr, boolean cMemoryOwn) { this("btDynamicsWorldDoubleData", cPtr, cMemoryOwn); construct(); } @Override protected void reset (long cPtr, boolean cMemoryOwn) { if (!destroyed) destroy(); super.reset(swigCPtr = cPtr, cMemoryOwn); } public static long getCPtr (btDynamicsWorldDoubleData obj) { return (obj == null) ? 0 : obj.swigCPtr; } @Override protected void finalize () throws Throwable { if (!destroyed) destroy(); super.finalize(); } @Override protected synchronized void delete () { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; DynamicsJNI.delete_btDynamicsWorldDoubleData(swigCPtr); } swigCPtr = 0; } super.delete(); } public void setSolverInfo (btContactSolverInfoDoubleData value) { DynamicsJNI.btDynamicsWorldDoubleData_solverInfo_set(swigCPtr, this, btContactSolverInfoDoubleData.getCPtr(value), value); } public btContactSolverInfoDoubleData getSolverInfo () { long cPtr = DynamicsJNI.btDynamicsWorldDoubleData_solverInfo_get(swigCPtr, this); return (cPtr == 0) ? null : new btContactSolverInfoDoubleData(cPtr, false); } public void setGravity (btVector3DoubleData value) { DynamicsJNI.btDynamicsWorldDoubleData_gravity_set(swigCPtr, this, btVector3DoubleData.getCPtr(value), value); } public btVector3DoubleData getGravity () { long cPtr = DynamicsJNI.btDynamicsWorldDoubleData_gravity_get(swigCPtr, this); return (cPtr == 0) ? null : new btVector3DoubleData(cPtr, false); } public btDynamicsWorldDoubleData () { this(DynamicsJNI.new_btDynamicsWorldDoubleData(), true); } }
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.dynamics; import com.badlogic.gdx.physics.bullet.BulletBase; import com.badlogic.gdx.physics.bullet.linearmath.*; import com.badlogic.gdx.physics.bullet.collision.*; public class btDynamicsWorldDoubleData extends BulletBase { private long swigCPtr; protected btDynamicsWorldDoubleData (final String className, long cPtr, boolean cMemoryOwn) { super(className, cPtr, cMemoryOwn); swigCPtr = cPtr; } /** Construct a new btDynamicsWorldDoubleData, normally you should not need this constructor it's intended for low-level * usage. */ public btDynamicsWorldDoubleData (long cPtr, boolean cMemoryOwn) { this("btDynamicsWorldDoubleData", cPtr, cMemoryOwn); construct(); } @Override protected void reset (long cPtr, boolean cMemoryOwn) { if (!destroyed) destroy(); super.reset(swigCPtr = cPtr, cMemoryOwn); } public static long getCPtr (btDynamicsWorldDoubleData obj) { return (obj == null) ? 0 : obj.swigCPtr; } @Override protected void finalize () throws Throwable { if (!destroyed) destroy(); super.finalize(); } @Override protected synchronized void delete () { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; DynamicsJNI.delete_btDynamicsWorldDoubleData(swigCPtr); } swigCPtr = 0; } super.delete(); } public void setSolverInfo (btContactSolverInfoDoubleData value) { DynamicsJNI.btDynamicsWorldDoubleData_solverInfo_set(swigCPtr, this, btContactSolverInfoDoubleData.getCPtr(value), value); } public btContactSolverInfoDoubleData getSolverInfo () { long cPtr = DynamicsJNI.btDynamicsWorldDoubleData_solverInfo_get(swigCPtr, this); return (cPtr == 0) ? null : new btContactSolverInfoDoubleData(cPtr, false); } public void setGravity (btVector3DoubleData value) { DynamicsJNI.btDynamicsWorldDoubleData_gravity_set(swigCPtr, this, btVector3DoubleData.getCPtr(value), value); } public btVector3DoubleData getGravity () { long cPtr = DynamicsJNI.btDynamicsWorldDoubleData_gravity_get(swigCPtr, this); return (cPtr == 0) ? null : new btVector3DoubleData(cPtr, false); } public btDynamicsWorldDoubleData () { this(DynamicsJNI.new_btDynamicsWorldDoubleData(), true); } }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./extensions/gdx-box2d/gdx-box2d/res/com/badlogic/gdx/physics/box2d.gwt.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit trunk//EN" "http://www.gwtproject.org/doctype/2.8.0/gwt-module.dtd"> <module> <source path="box2d"> </source> </module>
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit trunk//EN" "http://www.gwtproject.org/doctype/2.8.0/gwt-module.dtd"> <module> <source path="box2d"> </source> </module>
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./extensions/gdx-bullet/jni/swig-src/collision/com/badlogic/gdx/physics/bullet/collision/ePLANE_INTERSECTION_TYPE.java
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.collision; public final class ePLANE_INTERSECTION_TYPE { public final static int G_BACK_PLANE = 0; public final static int G_COLLIDE_PLANE = G_BACK_PLANE + 1; public final static int G_FRONT_PLANE = G_COLLIDE_PLANE + 1; }
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.collision; public final class ePLANE_INTERSECTION_TYPE { public final static int G_BACK_PLANE = 0; public final static int G_COLLIDE_PLANE = G_BACK_PLANE + 1; public final static int G_FRONT_PLANE = G_COLLIDE_PLANE + 1; }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./tests/gdx-tests/src/com/badlogic/gdx/tests/SoundTest.java
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.tests; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.audio.Sound; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.scenes.scene2d.ui.Label; import com.badlogic.gdx.scenes.scene2d.ui.SelectBox; import com.badlogic.gdx.scenes.scene2d.ui.Skin; import com.badlogic.gdx.scenes.scene2d.ui.Slider; import com.badlogic.gdx.scenes.scene2d.ui.Table; import com.badlogic.gdx.scenes.scene2d.ui.TextButton; import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent; import com.badlogic.gdx.tests.utils.GdxTest; import com.badlogic.gdx.utils.Align; import com.badlogic.gdx.utils.viewport.FitViewport; public class SoundTest extends GdxTest { private static final String[] FILENAMES = {"shotgun.ogg", "bubblepop.ogg", "bubblepop-stereo-left-only.wav"}; Sound sound; float volume = 0.5f; long soundId = 0; Stage ui; Skin skin; @Override public void create () { skin = new Skin(Gdx.files.internal("data/uiskin.json")); ui = new Stage(new FitViewport(640, 400)); final SelectBox<String> soundSelector = new SelectBox<String>(skin); soundSelector.setItems(FILENAMES); setSound(soundSelector.getSelected()); TextButton play = new TextButton("Play", skin); TextButton stop = new TextButton("Stop", skin); TextButton loop = new TextButton("Loop", skin); final Slider pitch = new Slider(0.1f, 4, 0.1f, false, skin); pitch.setValue(1); final Label pitchValue = new Label("1.0", skin); final Slider volume = new Slider(0.1f, 1, 0.1f, false, skin); volume.setValue(1); final Label volumeValue = new Label("1.0", skin); Table table = new Table(); final Slider pan = new Slider(-1f, 1f, 0.1f, false, skin); pan.setValue(0); final Label panValue = new Label("0.0", skin); table.setFillParent(true); table.align(Align.center | Align.top); table.add(soundSelector).colspan(3).row(); table.columnDefaults(0).expandX().right().uniformX(); table.columnDefaults(2).expandX().left().uniformX(); table.add(play); table.add(loop).left(); table.add(stop).left(); table.row(); table.add(new Label("Pitch", skin)); table.add(pitch); table.add(pitchValue); table.row(); table.add(new Label("Volume", skin)); table.add(volume); table.add(volumeValue); table.row(); table.add(new Label("Pan", skin)); table.add(pan); table.add(panValue); ui.addActor(table); soundSelector.addListener(new ChangeListener() { @Override public void changed (ChangeEvent event, Actor actor) { setSound(soundSelector.getSelected()); } }); play.addListener(new ClickListener() { public void clicked (InputEvent event, float x, float y) { soundId = sound.play(volume.getValue()); sound.setPitch(soundId, pitch.getValue()); sound.setPan(soundId, pan.getValue(), volume.getValue()); } }); loop.addListener(new ClickListener() { public void clicked (InputEvent event, float x, float y) { if (soundId == 0) { soundId = sound.loop(volume.getValue()); sound.setPitch(soundId, pitch.getValue()); sound.setPan(soundId, pan.getValue(), volume.getValue()); } else { sound.setLooping(soundId, true); } } }); stop.addListener(new ClickListener() { public void clicked (InputEvent event, float x, float y) { sound.stop(soundId); soundId = 0; } }); pitch.addListener(new ChangeListener() { public void changed (ChangeEvent event, Actor actor) { sound.setPitch(soundId, pitch.getValue()); pitchValue.setText("" + pitch.getValue()); } }); volume.addListener(new ChangeListener() { public void changed (ChangeEvent event, Actor actor) { sound.setVolume(soundId, volume.getValue()); volumeValue.setText("" + volume.getValue()); } }); pan.addListener(new ChangeListener() { public void changed (ChangeEvent event, Actor actor) { sound.setPan(soundId, pan.getValue(), volume.getValue()); panValue.setText("" + pan.getValue()); } }); Gdx.input.setInputProcessor(ui); } protected void setSound (String fileName) { if (sound != null) sound.dispose(); sound = Gdx.audio.newSound(Gdx.files.internal("data").child(fileName)); } @Override public void resize (int width, int height) { ui.getViewport().update(width, height, true); } @Override public void render () { Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); ui.act(Gdx.graphics.getDeltaTime()); ui.draw(); } @Override public void dispose () { ui.dispose(); skin.dispose(); sound.dispose(); } }
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.tests; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.audio.Sound; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.Stage; import com.badlogic.gdx.scenes.scene2d.ui.Label; import com.badlogic.gdx.scenes.scene2d.ui.SelectBox; import com.badlogic.gdx.scenes.scene2d.ui.Skin; import com.badlogic.gdx.scenes.scene2d.ui.Slider; import com.badlogic.gdx.scenes.scene2d.ui.Table; import com.badlogic.gdx.scenes.scene2d.ui.TextButton; import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener; import com.badlogic.gdx.scenes.scene2d.utils.ClickListener; import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent; import com.badlogic.gdx.tests.utils.GdxTest; import com.badlogic.gdx.utils.Align; import com.badlogic.gdx.utils.viewport.FitViewport; public class SoundTest extends GdxTest { private static final String[] FILENAMES = {"shotgun.ogg", "bubblepop.ogg", "bubblepop-stereo-left-only.wav"}; Sound sound; float volume = 0.5f; long soundId = 0; Stage ui; Skin skin; @Override public void create () { skin = new Skin(Gdx.files.internal("data/uiskin.json")); ui = new Stage(new FitViewport(640, 400)); final SelectBox<String> soundSelector = new SelectBox<String>(skin); soundSelector.setItems(FILENAMES); setSound(soundSelector.getSelected()); TextButton play = new TextButton("Play", skin); TextButton stop = new TextButton("Stop", skin); TextButton loop = new TextButton("Loop", skin); final Slider pitch = new Slider(0.1f, 4, 0.1f, false, skin); pitch.setValue(1); final Label pitchValue = new Label("1.0", skin); final Slider volume = new Slider(0.1f, 1, 0.1f, false, skin); volume.setValue(1); final Label volumeValue = new Label("1.0", skin); Table table = new Table(); final Slider pan = new Slider(-1f, 1f, 0.1f, false, skin); pan.setValue(0); final Label panValue = new Label("0.0", skin); table.setFillParent(true); table.align(Align.center | Align.top); table.add(soundSelector).colspan(3).row(); table.columnDefaults(0).expandX().right().uniformX(); table.columnDefaults(2).expandX().left().uniformX(); table.add(play); table.add(loop).left(); table.add(stop).left(); table.row(); table.add(new Label("Pitch", skin)); table.add(pitch); table.add(pitchValue); table.row(); table.add(new Label("Volume", skin)); table.add(volume); table.add(volumeValue); table.row(); table.add(new Label("Pan", skin)); table.add(pan); table.add(panValue); ui.addActor(table); soundSelector.addListener(new ChangeListener() { @Override public void changed (ChangeEvent event, Actor actor) { setSound(soundSelector.getSelected()); } }); play.addListener(new ClickListener() { public void clicked (InputEvent event, float x, float y) { soundId = sound.play(volume.getValue()); sound.setPitch(soundId, pitch.getValue()); sound.setPan(soundId, pan.getValue(), volume.getValue()); } }); loop.addListener(new ClickListener() { public void clicked (InputEvent event, float x, float y) { if (soundId == 0) { soundId = sound.loop(volume.getValue()); sound.setPitch(soundId, pitch.getValue()); sound.setPan(soundId, pan.getValue(), volume.getValue()); } else { sound.setLooping(soundId, true); } } }); stop.addListener(new ClickListener() { public void clicked (InputEvent event, float x, float y) { sound.stop(soundId); soundId = 0; } }); pitch.addListener(new ChangeListener() { public void changed (ChangeEvent event, Actor actor) { sound.setPitch(soundId, pitch.getValue()); pitchValue.setText("" + pitch.getValue()); } }); volume.addListener(new ChangeListener() { public void changed (ChangeEvent event, Actor actor) { sound.setVolume(soundId, volume.getValue()); volumeValue.setText("" + volume.getValue()); } }); pan.addListener(new ChangeListener() { public void changed (ChangeEvent event, Actor actor) { sound.setPan(soundId, pan.getValue(), volume.getValue()); panValue.setText("" + pan.getValue()); } }); Gdx.input.setInputProcessor(ui); } protected void setSound (String fileName) { if (sound != null) sound.dispose(); sound = Gdx.audio.newSound(Gdx.files.internal("data").child(fileName)); } @Override public void resize (int width, int height) { ui.getViewport().update(width, height, true); } @Override public void render () { Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); ui.act(Gdx.graphics.getDeltaTime()); ui.draw(); } @Override public void dispose () { ui.dispose(); skin.dispose(); sound.dispose(); } }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./tests/gdx-tests/src/com/badlogic/gdx/tests/g3d/Animation3DTest.java
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.tests.g3d; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Input.Keys; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.VertexAttributes.Usage; import com.badlogic.gdx.graphics.g3d.Environment; import com.badlogic.gdx.graphics.g3d.Material; import com.badlogic.gdx.graphics.g3d.Model; import com.badlogic.gdx.graphics.g3d.ModelBatch; import com.badlogic.gdx.graphics.g3d.ModelInstance; import com.badlogic.gdx.graphics.g3d.attributes.BlendingAttribute; import com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute; import com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute; import com.badlogic.gdx.graphics.g3d.environment.DirectionalShadowLight; import com.badlogic.gdx.graphics.g3d.model.Animation; import com.badlogic.gdx.graphics.g3d.model.Node; import com.badlogic.gdx.graphics.g3d.utils.AnimationController; import com.badlogic.gdx.graphics.g3d.utils.DepthShaderProvider; import com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder; import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder; import com.badlogic.gdx.math.Matrix4; import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.math.collision.BoundingBox; import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.StringBuilder; public class Animation3DTest extends BaseG3dHudTest { ModelInstance skydome; Model floorModel; ModelInstance character; Node ship; ModelInstance tree; AnimationController animation; DirectionalShadowLight shadowLight; ModelBatch shadowBatch; Environment lights; @Override public void create () { super.create(); lights = new Environment(); lights.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1.f)); lights .add((shadowLight = new DirectionalShadowLight(1024, 1024, 30f, 30f, 1f, 100f)).set(0.8f, 0.8f, 0.8f, -.4f, -.4f, -.4f)); lights.shadowMap = shadowLight; inputController.rotateLeftKey = inputController.rotateRightKey = inputController.forwardKey = inputController.backwardKey = 0; cam.position.set(25, 25, 25); cam.lookAt(0, 0, 0); cam.update(); modelsWindow.setVisible(false); assets.load("data/g3d/skydome.g3db", Model.class); assets.load("data/g3d/concrete.png", Texture.class); assets.load("data/tree.png", Texture.class); assets.load("data/g3d/ship.obj", Model.class); loading = true; trForward.translation.set(0, 0, 8f); trBackward.translation.set(0, 0, -8f); trLeft.rotation.setFromAxis(Vector3.Y, 90); trRight.rotation.setFromAxis(Vector3.Y, -90); ModelBuilder builder = new ModelBuilder(); builder.begin(); builder.node().id = "floor"; MeshPartBuilder part = builder.part("floor", GL20.GL_TRIANGLES, Usage.Position | Usage.TextureCoordinates | Usage.Normal, new Material("concrete")); part.ensureVertices(4 * 1600); part.ensureRectangleIndices(1600); for (float x = -200f; x < 200f; x += 10f) { for (float z = -200f; z < 200f; z += 10f) { part.rect(x, 0, z + 10f, x + 10f, 0, z + 10f, x + 10f, 0, z, x, 0, z, 0, 1, 0); } } builder.node().id = "tree"; part = builder.part("tree", GL20.GL_TRIANGLES, Usage.Position | Usage.TextureCoordinates | Usage.Normal, new Material("tree")); part.rect(0f, 0f, -10f, 10f, 0f, -10f, 10f, 10f, -10f, 0f, 10f, -10f, 0, 0, 1f); part.setUVRange(1, 0, 0, 1); part.rect(10f, 0f, -10f, 0f, 0f, -10f, 0f, 10f, -10f, 10f, 10f, -10f, 0, 0, -1f); floorModel = builder.end(); shadowBatch = new ModelBatch(new DepthShaderProvider()); } final AnimationController.Transform trTmp = new AnimationController.Transform(); final AnimationController.Transform trForward = new AnimationController.Transform(); final AnimationController.Transform trBackward = new AnimationController.Transform(); final AnimationController.Transform trRight = new AnimationController.Transform(); final AnimationController.Transform trLeft = new AnimationController.Transform(); final Matrix4 tmpMatrix = new Matrix4(); final Vector3 tmpVector = new Vector3(); int status = 0; final static int idle = 1; final static int walk = 2; final static int back = 3; final static int attack = 4; float angle = 0f; @Override public void render () { if (character != null) { animation.update(Gdx.graphics.getDeltaTime()); if (Gdx.input.isKeyPressed(Keys.UP)) { if (!animation.inAction) { trTmp.idt().lerp(trForward, Gdx.graphics.getDeltaTime() / animation.current.animation.duration); character.transform.mul(trTmp.toMatrix4(tmpMatrix)); } if (status != walk) { animation.animate("Walk", -1, 1f, null, 0.2f); status = walk; } } else if (Gdx.input.isKeyPressed(Keys.DOWN)) { if (!animation.inAction) { trTmp.idt().lerp(trBackward, Gdx.graphics.getDeltaTime() / animation.current.animation.duration); character.transform.mul(trTmp.toMatrix4(tmpMatrix)); } if (status != back) { animation.animate("Walk", -1, -1f, null, 0.2f); status = back; } } else if (status != idle) { animation.animate("Idle", -1, 1f, null, 0.2f); status = idle; } if (Gdx.input.isKeyPressed(Keys.RIGHT) && (status == walk || status == back) && !animation.inAction) { trTmp.idt().lerp(trRight, Gdx.graphics.getDeltaTime() / animation.current.animation.duration); character.transform.mul(trTmp.toMatrix4(tmpMatrix)); } else if (Gdx.input.isKeyPressed(Keys.LEFT) && (status == walk || status == back) && !animation.inAction) { trTmp.idt().lerp(trLeft, Gdx.graphics.getDeltaTime() / animation.current.animation.duration); character.transform.mul(trTmp.toMatrix4(tmpMatrix)); } if (Gdx.input.isKeyPressed(Keys.SPACE) && !animation.inAction) { animation.action("Attack", 1, 1f, null, 0.2f); } if (Gdx.input.isKeyJustPressed(Keys.Z)) ship.parts.get(0).enabled = !ship.parts.get(0).enabled; } if (character != null) { shadowLight.begin(character.transform.getTranslation(tmpVector), cam.direction); shadowBatch.begin(shadowLight.getCamera()); if (character != null) shadowBatch.render(character); if (tree != null) shadowBatch.render(tree); shadowBatch.end(); shadowLight.end(); } super.render(); } @Override protected void render (ModelBatch batch, Array<ModelInstance> instances) { batch.render(instances, lights); if (skydome != null) batch.render(skydome); } @Override protected void getStatus (StringBuilder stringBuilder) { super.getStatus(stringBuilder); stringBuilder.append(" use arrow keys to walk around, space to attack, Z to toggle attached node."); } @Override protected void onModelClicked (final String name) { } @Override protected void onLoaded () { if (skydome == null) { skydome = new ModelInstance(assets.get("data/g3d/skydome.g3db", Model.class)); floorModel.getMaterial("concrete") .set(TextureAttribute.createDiffuse(assets.get("data/g3d/concrete.png", Texture.class))); floorModel.getMaterial("tree").set(TextureAttribute.createDiffuse(assets.get("data/tree.png", Texture.class)), new BlendingAttribute()); instances.add(new ModelInstance(floorModel, "floor")); instances.add(tree = new ModelInstance(floorModel, "tree")); assets.load("data/g3d/knight.g3db", Model.class); loading = true; } else if (character == null) { character = new ModelInstance(assets.get("data/g3d/knight.g3db", Model.class)); BoundingBox bbox = new BoundingBox(); character.calculateBoundingBox(bbox); character.transform.setToRotation(Vector3.Y, 180).trn(0, -bbox.min.y, 0); instances.add(character); animation = new AnimationController(character); animation.animate("Idle", -1, 1f, null, 0.2f); status = idle; for (Animation anim : character.animations) Gdx.app.log("Test", anim.id); // Now attach the node of another model at the tip of this knights sword: ship = assets.get("data/g3d/ship.obj", Model.class).nodes.get(0).copy(); ship.detach(); ship.translation.x = 10f; // offset from the sword node to the tip of the sword, in rest pose ship.rotation.set(Vector3.Z, 90f); ship.scale.scl(5f); ship.parts.get(0).enabled = false; character.getNode("sword").addChild(ship); } } @Override public void dispose () { super.dispose(); floorModel.dispose(); shadowLight.dispose(); } }
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.tests.g3d; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Input.Keys; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.VertexAttributes.Usage; import com.badlogic.gdx.graphics.g3d.Environment; import com.badlogic.gdx.graphics.g3d.Material; import com.badlogic.gdx.graphics.g3d.Model; import com.badlogic.gdx.graphics.g3d.ModelBatch; import com.badlogic.gdx.graphics.g3d.ModelInstance; import com.badlogic.gdx.graphics.g3d.attributes.BlendingAttribute; import com.badlogic.gdx.graphics.g3d.attributes.ColorAttribute; import com.badlogic.gdx.graphics.g3d.attributes.TextureAttribute; import com.badlogic.gdx.graphics.g3d.environment.DirectionalShadowLight; import com.badlogic.gdx.graphics.g3d.model.Animation; import com.badlogic.gdx.graphics.g3d.model.Node; import com.badlogic.gdx.graphics.g3d.utils.AnimationController; import com.badlogic.gdx.graphics.g3d.utils.DepthShaderProvider; import com.badlogic.gdx.graphics.g3d.utils.MeshPartBuilder; import com.badlogic.gdx.graphics.g3d.utils.ModelBuilder; import com.badlogic.gdx.math.Matrix4; import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.math.collision.BoundingBox; import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.StringBuilder; public class Animation3DTest extends BaseG3dHudTest { ModelInstance skydome; Model floorModel; ModelInstance character; Node ship; ModelInstance tree; AnimationController animation; DirectionalShadowLight shadowLight; ModelBatch shadowBatch; Environment lights; @Override public void create () { super.create(); lights = new Environment(); lights.set(new ColorAttribute(ColorAttribute.AmbientLight, 0.4f, 0.4f, 0.4f, 1.f)); lights .add((shadowLight = new DirectionalShadowLight(1024, 1024, 30f, 30f, 1f, 100f)).set(0.8f, 0.8f, 0.8f, -.4f, -.4f, -.4f)); lights.shadowMap = shadowLight; inputController.rotateLeftKey = inputController.rotateRightKey = inputController.forwardKey = inputController.backwardKey = 0; cam.position.set(25, 25, 25); cam.lookAt(0, 0, 0); cam.update(); modelsWindow.setVisible(false); assets.load("data/g3d/skydome.g3db", Model.class); assets.load("data/g3d/concrete.png", Texture.class); assets.load("data/tree.png", Texture.class); assets.load("data/g3d/ship.obj", Model.class); loading = true; trForward.translation.set(0, 0, 8f); trBackward.translation.set(0, 0, -8f); trLeft.rotation.setFromAxis(Vector3.Y, 90); trRight.rotation.setFromAxis(Vector3.Y, -90); ModelBuilder builder = new ModelBuilder(); builder.begin(); builder.node().id = "floor"; MeshPartBuilder part = builder.part("floor", GL20.GL_TRIANGLES, Usage.Position | Usage.TextureCoordinates | Usage.Normal, new Material("concrete")); part.ensureVertices(4 * 1600); part.ensureRectangleIndices(1600); for (float x = -200f; x < 200f; x += 10f) { for (float z = -200f; z < 200f; z += 10f) { part.rect(x, 0, z + 10f, x + 10f, 0, z + 10f, x + 10f, 0, z, x, 0, z, 0, 1, 0); } } builder.node().id = "tree"; part = builder.part("tree", GL20.GL_TRIANGLES, Usage.Position | Usage.TextureCoordinates | Usage.Normal, new Material("tree")); part.rect(0f, 0f, -10f, 10f, 0f, -10f, 10f, 10f, -10f, 0f, 10f, -10f, 0, 0, 1f); part.setUVRange(1, 0, 0, 1); part.rect(10f, 0f, -10f, 0f, 0f, -10f, 0f, 10f, -10f, 10f, 10f, -10f, 0, 0, -1f); floorModel = builder.end(); shadowBatch = new ModelBatch(new DepthShaderProvider()); } final AnimationController.Transform trTmp = new AnimationController.Transform(); final AnimationController.Transform trForward = new AnimationController.Transform(); final AnimationController.Transform trBackward = new AnimationController.Transform(); final AnimationController.Transform trRight = new AnimationController.Transform(); final AnimationController.Transform trLeft = new AnimationController.Transform(); final Matrix4 tmpMatrix = new Matrix4(); final Vector3 tmpVector = new Vector3(); int status = 0; final static int idle = 1; final static int walk = 2; final static int back = 3; final static int attack = 4; float angle = 0f; @Override public void render () { if (character != null) { animation.update(Gdx.graphics.getDeltaTime()); if (Gdx.input.isKeyPressed(Keys.UP)) { if (!animation.inAction) { trTmp.idt().lerp(trForward, Gdx.graphics.getDeltaTime() / animation.current.animation.duration); character.transform.mul(trTmp.toMatrix4(tmpMatrix)); } if (status != walk) { animation.animate("Walk", -1, 1f, null, 0.2f); status = walk; } } else if (Gdx.input.isKeyPressed(Keys.DOWN)) { if (!animation.inAction) { trTmp.idt().lerp(trBackward, Gdx.graphics.getDeltaTime() / animation.current.animation.duration); character.transform.mul(trTmp.toMatrix4(tmpMatrix)); } if (status != back) { animation.animate("Walk", -1, -1f, null, 0.2f); status = back; } } else if (status != idle) { animation.animate("Idle", -1, 1f, null, 0.2f); status = idle; } if (Gdx.input.isKeyPressed(Keys.RIGHT) && (status == walk || status == back) && !animation.inAction) { trTmp.idt().lerp(trRight, Gdx.graphics.getDeltaTime() / animation.current.animation.duration); character.transform.mul(trTmp.toMatrix4(tmpMatrix)); } else if (Gdx.input.isKeyPressed(Keys.LEFT) && (status == walk || status == back) && !animation.inAction) { trTmp.idt().lerp(trLeft, Gdx.graphics.getDeltaTime() / animation.current.animation.duration); character.transform.mul(trTmp.toMatrix4(tmpMatrix)); } if (Gdx.input.isKeyPressed(Keys.SPACE) && !animation.inAction) { animation.action("Attack", 1, 1f, null, 0.2f); } if (Gdx.input.isKeyJustPressed(Keys.Z)) ship.parts.get(0).enabled = !ship.parts.get(0).enabled; } if (character != null) { shadowLight.begin(character.transform.getTranslation(tmpVector), cam.direction); shadowBatch.begin(shadowLight.getCamera()); if (character != null) shadowBatch.render(character); if (tree != null) shadowBatch.render(tree); shadowBatch.end(); shadowLight.end(); } super.render(); } @Override protected void render (ModelBatch batch, Array<ModelInstance> instances) { batch.render(instances, lights); if (skydome != null) batch.render(skydome); } @Override protected void getStatus (StringBuilder stringBuilder) { super.getStatus(stringBuilder); stringBuilder.append(" use arrow keys to walk around, space to attack, Z to toggle attached node."); } @Override protected void onModelClicked (final String name) { } @Override protected void onLoaded () { if (skydome == null) { skydome = new ModelInstance(assets.get("data/g3d/skydome.g3db", Model.class)); floorModel.getMaterial("concrete") .set(TextureAttribute.createDiffuse(assets.get("data/g3d/concrete.png", Texture.class))); floorModel.getMaterial("tree").set(TextureAttribute.createDiffuse(assets.get("data/tree.png", Texture.class)), new BlendingAttribute()); instances.add(new ModelInstance(floorModel, "floor")); instances.add(tree = new ModelInstance(floorModel, "tree")); assets.load("data/g3d/knight.g3db", Model.class); loading = true; } else if (character == null) { character = new ModelInstance(assets.get("data/g3d/knight.g3db", Model.class)); BoundingBox bbox = new BoundingBox(); character.calculateBoundingBox(bbox); character.transform.setToRotation(Vector3.Y, 180).trn(0, -bbox.min.y, 0); instances.add(character); animation = new AnimationController(character); animation.animate("Idle", -1, 1f, null, 0.2f); status = idle; for (Animation anim : character.animations) Gdx.app.log("Test", anim.id); // Now attach the node of another model at the tip of this knights sword: ship = assets.get("data/g3d/ship.obj", Model.class).nodes.get(0).copy(); ship.detach(); ship.translation.x = 10f; // offset from the sword node to the tip of the sword, in rest pose ship.rotation.set(Vector3.Z, 90f); ship.scale.scl(5f); ship.parts.get(0).enabled = false; character.getNode("sword").addChild(ship); } } @Override public void dispose () { super.dispose(); floorModel.dispose(); shadowLight.dispose(); } }
-1
libgdx/libgdx
7,260
Add Vector4 class and use it where fitting
There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
tommyettinger
"2023-10-20T11:43:38Z"
"2023-10-29T08:08:05Z"
7bcfbd42f1f7e8c26ff06144ac79a7ff38ffaf5b
413eddccd2765607da15a1a928689863702cf02a
Add Vector4 class and use it where fitting. There's a vec4 type in GLSL that I'm sure we're all familiar with, so it's a little strange that libGDX has Vector, Vector2, and Vector3, but as of right now, no Vector4. This tries to change that. Vector4 is rather similar to Vector3, except for a few methods that require a lot of extra effort due to how 4D space is (`setToRandomDirection()` and `isOnLine()`, mainly). Where ShaderProgram already allows setting a uniform with a Vector3 or Color, it now can take a Vector4 (which acts identically to Color, setting four float components). Most of the work in Vector4.java was done by Antz and largely follows in the footsteps of Vector2 and Vector3. There's some small changes in other Vector-related files -- `idt()` was present in Vector3 and now Vector4, but not Vector2, so I added it there to match the others. It's a very simple method to add. I improved existing docs in a few places, mostly fixing typos and capitalization mistakes. I changed some C-style array declarations in Vector3 to use the more conventional Java-style array declarations; this was easy to do automatically and I feel it makes this (Java) code more legible. The tests could be better; let me know if you think something should be tested that isn't now. Thanks Antz, and thanks in advance to anyone reviewing this!
./extensions/gdx-bullet/jni/swig-src/dynamics/com/badlogic/gdx/physics/bullet/dynamics/btMultiBody.java
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.dynamics; import com.badlogic.gdx.physics.bullet.BulletBase; import com.badlogic.gdx.physics.bullet.linearmath.*; import com.badlogic.gdx.physics.bullet.collision.*; import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.math.Quaternion; import com.badlogic.gdx.math.Matrix3; import com.badlogic.gdx.math.Matrix4; public class btMultiBody extends BulletBase { private long swigCPtr; protected btMultiBody (final String className, long cPtr, boolean cMemoryOwn) { super(className, cPtr, cMemoryOwn); swigCPtr = cPtr; } /** Construct a new btMultiBody, normally you should not need this constructor it's intended for low-level usage. */ public btMultiBody (long cPtr, boolean cMemoryOwn) { this("btMultiBody", cPtr, cMemoryOwn); construct(); } @Override protected void reset (long cPtr, boolean cMemoryOwn) { if (!destroyed) destroy(); super.reset(swigCPtr = cPtr, cMemoryOwn); } public static long getCPtr (btMultiBody obj) { return (obj == null) ? 0 : obj.swigCPtr; } @Override protected void finalize () throws Throwable { if (!destroyed) destroy(); super.finalize(); } @Override protected synchronized void delete () { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; DynamicsJNI.delete_btMultiBody(swigCPtr); } swigCPtr = 0; } super.delete(); } public long operatorNew (long sizeInBytes) { return DynamicsJNI.btMultiBody_operatorNew__SWIG_0(swigCPtr, this, sizeInBytes); } public void operatorDelete (long ptr) { DynamicsJNI.btMultiBody_operatorDelete__SWIG_0(swigCPtr, this, ptr); } public long operatorNew (long arg0, long ptr) { return DynamicsJNI.btMultiBody_operatorNew__SWIG_1(swigCPtr, this, arg0, ptr); } public void operatorDelete (long arg0, long arg1) { DynamicsJNI.btMultiBody_operatorDelete__SWIG_1(swigCPtr, this, arg0, arg1); } public long operatorNewArray (long sizeInBytes) { return DynamicsJNI.btMultiBody_operatorNewArray__SWIG_0(swigCPtr, this, sizeInBytes); } public void operatorDeleteArray (long ptr) { DynamicsJNI.btMultiBody_operatorDeleteArray__SWIG_0(swigCPtr, this, ptr); } public long operatorNewArray (long arg0, long ptr) { return DynamicsJNI.btMultiBody_operatorNewArray__SWIG_1(swigCPtr, this, arg0, ptr); } public void operatorDeleteArray (long arg0, long arg1) { DynamicsJNI.btMultiBody_operatorDeleteArray__SWIG_1(swigCPtr, this, arg0, arg1); } public btMultiBody (int n_links, float mass, Vector3 inertia, boolean fixedBase, boolean canSleep, boolean deprecatedMultiDof) { this(DynamicsJNI.new_btMultiBody__SWIG_0(n_links, mass, inertia, fixedBase, canSleep, deprecatedMultiDof), true); } public btMultiBody (int n_links, float mass, Vector3 inertia, boolean fixedBase, boolean canSleep) { this(DynamicsJNI.new_btMultiBody__SWIG_1(n_links, mass, inertia, fixedBase, canSleep), true); } public void setupFixed (int linkIndex, float mass, Vector3 inertia, int parent, Quaternion rotParentToThis, Vector3 parentComToThisPivotOffset, Vector3 thisPivotToThisComOffset, boolean deprecatedDisableParentCollision) { DynamicsJNI.btMultiBody_setupFixed__SWIG_0(swigCPtr, this, linkIndex, mass, inertia, parent, rotParentToThis, parentComToThisPivotOffset, thisPivotToThisComOffset, deprecatedDisableParentCollision); } public void setupFixed (int linkIndex, float mass, Vector3 inertia, int parent, Quaternion rotParentToThis, Vector3 parentComToThisPivotOffset, Vector3 thisPivotToThisComOffset) { DynamicsJNI.btMultiBody_setupFixed__SWIG_1(swigCPtr, this, linkIndex, mass, inertia, parent, rotParentToThis, parentComToThisPivotOffset, thisPivotToThisComOffset); } public void setupPrismatic (int i, float mass, Vector3 inertia, int parent, Quaternion rotParentToThis, Vector3 jointAxis, Vector3 parentComToThisPivotOffset, Vector3 thisPivotToThisComOffset, boolean disableParentCollision) { DynamicsJNI.btMultiBody_setupPrismatic(swigCPtr, this, i, mass, inertia, parent, rotParentToThis, jointAxis, parentComToThisPivotOffset, thisPivotToThisComOffset, disableParentCollision); } public void setupRevolute (int linkIndex, float mass, Vector3 inertia, int parentIndex, Quaternion rotParentToThis, Vector3 jointAxis, Vector3 parentComToThisPivotOffset, Vector3 thisPivotToThisComOffset, boolean disableParentCollision) { DynamicsJNI.btMultiBody_setupRevolute__SWIG_0(swigCPtr, this, linkIndex, mass, inertia, parentIndex, rotParentToThis, jointAxis, parentComToThisPivotOffset, thisPivotToThisComOffset, disableParentCollision); } public void setupRevolute (int linkIndex, float mass, Vector3 inertia, int parentIndex, Quaternion rotParentToThis, Vector3 jointAxis, Vector3 parentComToThisPivotOffset, Vector3 thisPivotToThisComOffset) { DynamicsJNI.btMultiBody_setupRevolute__SWIG_1(swigCPtr, this, linkIndex, mass, inertia, parentIndex, rotParentToThis, jointAxis, parentComToThisPivotOffset, thisPivotToThisComOffset); } public void setupSpherical (int linkIndex, float mass, Vector3 inertia, int parent, Quaternion rotParentToThis, Vector3 parentComToThisPivotOffset, Vector3 thisPivotToThisComOffset, boolean disableParentCollision) { DynamicsJNI.btMultiBody_setupSpherical__SWIG_0(swigCPtr, this, linkIndex, mass, inertia, parent, rotParentToThis, parentComToThisPivotOffset, thisPivotToThisComOffset, disableParentCollision); } public void setupSpherical (int linkIndex, float mass, Vector3 inertia, int parent, Quaternion rotParentToThis, Vector3 parentComToThisPivotOffset, Vector3 thisPivotToThisComOffset) { DynamicsJNI.btMultiBody_setupSpherical__SWIG_1(swigCPtr, this, linkIndex, mass, inertia, parent, rotParentToThis, parentComToThisPivotOffset, thisPivotToThisComOffset); } public void setupPlanar (int i, float mass, Vector3 inertia, int parent, Quaternion rotParentToThis, Vector3 rotationAxis, Vector3 parentComToThisComOffset, boolean disableParentCollision) { DynamicsJNI.btMultiBody_setupPlanar__SWIG_0(swigCPtr, this, i, mass, inertia, parent, rotParentToThis, rotationAxis, parentComToThisComOffset, disableParentCollision); } public void setupPlanar (int i, float mass, Vector3 inertia, int parent, Quaternion rotParentToThis, Vector3 rotationAxis, Vector3 parentComToThisComOffset) { DynamicsJNI.btMultiBody_setupPlanar__SWIG_1(swigCPtr, this, i, mass, inertia, parent, rotParentToThis, rotationAxis, parentComToThisComOffset); } public btMultibodyLink getLinkConst (int index) { return new btMultibodyLink(DynamicsJNI.btMultiBody_getLinkConst(swigCPtr, this, index), false); } public btMultibodyLink getLink (int index) { return new btMultibodyLink(DynamicsJNI.btMultiBody_getLink(swigCPtr, this, index), false); } public void setBaseCollider (btMultiBodyLinkCollider collider) { DynamicsJNI.btMultiBody_setBaseCollider(swigCPtr, this, btMultiBodyLinkCollider.getCPtr(collider), collider); } public btMultiBodyLinkCollider getBaseColliderConst () { long cPtr = DynamicsJNI.btMultiBody_getBaseColliderConst(swigCPtr, this); return (cPtr == 0) ? null : new btMultiBodyLinkCollider(cPtr, false); } public btMultiBodyLinkCollider getBaseCollider () { long cPtr = DynamicsJNI.btMultiBody_getBaseCollider(swigCPtr, this); return (cPtr == 0) ? null : new btMultiBodyLinkCollider(cPtr, false); } public btMultiBodyLinkCollider getLinkCollider (int index) { long cPtr = DynamicsJNI.btMultiBody_getLinkCollider(swigCPtr, this, index); return (cPtr == 0) ? null : new btMultiBodyLinkCollider(cPtr, false); } public int getParent (int link_num) { return DynamicsJNI.btMultiBody_getParent(swigCPtr, this, link_num); } public int getNumLinks () { return DynamicsJNI.btMultiBody_getNumLinks(swigCPtr, this); } public int getNumDofs () { return DynamicsJNI.btMultiBody_getNumDofs(swigCPtr, this); } public int getNumPosVars () { return DynamicsJNI.btMultiBody_getNumPosVars(swigCPtr, this); } public float getBaseMass () { return DynamicsJNI.btMultiBody_getBaseMass(swigCPtr, this); } public Vector3 getBaseInertia () { return DynamicsJNI.btMultiBody_getBaseInertia(swigCPtr, this); } public float getLinkMass (int i) { return DynamicsJNI.btMultiBody_getLinkMass(swigCPtr, this, i); } public Vector3 getLinkInertia (int i) { return DynamicsJNI.btMultiBody_getLinkInertia(swigCPtr, this, i); } public void setBaseMass (float mass) { DynamicsJNI.btMultiBody_setBaseMass(swigCPtr, this, mass); } public void setBaseInertia (Vector3 inertia) { DynamicsJNI.btMultiBody_setBaseInertia(swigCPtr, this, inertia); } public Vector3 getBasePos () { return DynamicsJNI.btMultiBody_getBasePos(swigCPtr, this); } public Vector3 getBaseVel () { return DynamicsJNI.btMultiBody_getBaseVel(swigCPtr, this); } public Quaternion getWorldToBaseRot () { return DynamicsJNI.btMultiBody_getWorldToBaseRot(swigCPtr, this); } public Vector3 getBaseOmega () { return DynamicsJNI.btMultiBody_getBaseOmega(swigCPtr, this); } public void setBasePos (Vector3 pos) { DynamicsJNI.btMultiBody_setBasePos(swigCPtr, this, pos); } public void setBaseWorldTransform (Matrix4 tr) { DynamicsJNI.btMultiBody_setBaseWorldTransform(swigCPtr, this, tr); } public Matrix4 getBaseWorldTransform () { return DynamicsJNI.btMultiBody_getBaseWorldTransform(swigCPtr, this); } public void setBaseVel (Vector3 vel) { DynamicsJNI.btMultiBody_setBaseVel(swigCPtr, this, vel); } public void setWorldToBaseRot (Quaternion rot) { DynamicsJNI.btMultiBody_setWorldToBaseRot(swigCPtr, this, rot); } public void setBaseOmega (Vector3 omega) { DynamicsJNI.btMultiBody_setBaseOmega(swigCPtr, this, omega); } public float getJointPos (int i) { return DynamicsJNI.btMultiBody_getJointPos(swigCPtr, this, i); } public float getJointVel (int i) { return DynamicsJNI.btMultiBody_getJointVel(swigCPtr, this, i); } public java.nio.FloatBuffer getJointVelMultiDof (int i) { return DynamicsJNI.btMultiBody_getJointVelMultiDof(swigCPtr, this, i); } public java.nio.FloatBuffer getJointPosMultiDof (int i) { return DynamicsJNI.btMultiBody_getJointPosMultiDof(swigCPtr, this, i); } public java.nio.FloatBuffer getJointVelMultiDofConst (int i) { return DynamicsJNI.btMultiBody_getJointVelMultiDofConst(swigCPtr, this, i); } public java.nio.FloatBuffer getJointPosMultiDofConst (int i) { return DynamicsJNI.btMultiBody_getJointPosMultiDofConst(swigCPtr, this, i); } public void setJointPos (int i, float q) { DynamicsJNI.btMultiBody_setJointPos(swigCPtr, this, i, q); } public void setJointVel (int i, float qdot) { DynamicsJNI.btMultiBody_setJointVel(swigCPtr, this, i, qdot); } public void setJointPosMultiDof (int i, java.nio.FloatBuffer q) { assert q.isDirect() : "Buffer must be allocated direct."; { DynamicsJNI.btMultiBody_setJointPosMultiDof(swigCPtr, this, i, q); } } public void setJointVelMultiDof (int i, java.nio.FloatBuffer qdot) { assert qdot.isDirect() : "Buffer must be allocated direct."; { DynamicsJNI.btMultiBody_setJointVelMultiDof(swigCPtr, this, i, qdot); } } public java.nio.FloatBuffer getVelocityVector () { return DynamicsJNI.btMultiBody_getVelocityVector(swigCPtr, this); } public Vector3 getRVector (int i) { return DynamicsJNI.btMultiBody_getRVector(swigCPtr, this, i); } public Quaternion getParentToLocalRot (int i) { return DynamicsJNI.btMultiBody_getParentToLocalRot(swigCPtr, this, i); } public Vector3 localPosToWorld (int i, Vector3 vec) { return DynamicsJNI.btMultiBody_localPosToWorld(swigCPtr, this, i, vec); } public Vector3 localDirToWorld (int i, Vector3 vec) { return DynamicsJNI.btMultiBody_localDirToWorld(swigCPtr, this, i, vec); } public Vector3 worldPosToLocal (int i, Vector3 vec) { return DynamicsJNI.btMultiBody_worldPosToLocal(swigCPtr, this, i, vec); } public Vector3 worldDirToLocal (int i, Vector3 vec) { return DynamicsJNI.btMultiBody_worldDirToLocal(swigCPtr, this, i, vec); } public Matrix3 localFrameToWorld (int i, Matrix3 mat) { return DynamicsJNI.btMultiBody_localFrameToWorld(swigCPtr, this, i, mat); } public float getKineticEnergy () { return DynamicsJNI.btMultiBody_getKineticEnergy(swigCPtr, this); } public Vector3 getAngularMomentum () { return DynamicsJNI.btMultiBody_getAngularMomentum(swigCPtr, this); } public void clearForcesAndTorques () { DynamicsJNI.btMultiBody_clearForcesAndTorques(swigCPtr, this); } public void clearConstraintForces () { DynamicsJNI.btMultiBody_clearConstraintForces(swigCPtr, this); } public void clearVelocities () { DynamicsJNI.btMultiBody_clearVelocities(swigCPtr, this); } public void addBaseForce (Vector3 f) { DynamicsJNI.btMultiBody_addBaseForce(swigCPtr, this, f); } public void addBaseTorque (Vector3 t) { DynamicsJNI.btMultiBody_addBaseTorque(swigCPtr, this, t); } public void addLinkForce (int i, Vector3 f) { DynamicsJNI.btMultiBody_addLinkForce(swigCPtr, this, i, f); } public void addLinkTorque (int i, Vector3 t) { DynamicsJNI.btMultiBody_addLinkTorque(swigCPtr, this, i, t); } public void addBaseConstraintForce (Vector3 f) { DynamicsJNI.btMultiBody_addBaseConstraintForce(swigCPtr, this, f); } public void addBaseConstraintTorque (Vector3 t) { DynamicsJNI.btMultiBody_addBaseConstraintTorque(swigCPtr, this, t); } public void addLinkConstraintForce (int i, Vector3 f) { DynamicsJNI.btMultiBody_addLinkConstraintForce(swigCPtr, this, i, f); } public void addLinkConstraintTorque (int i, Vector3 t) { DynamicsJNI.btMultiBody_addLinkConstraintTorque(swigCPtr, this, i, t); } public void addJointTorque (int i, float Q) { DynamicsJNI.btMultiBody_addJointTorque(swigCPtr, this, i, Q); } public void addJointTorqueMultiDof (int i, int dof, float Q) { DynamicsJNI.btMultiBody_addJointTorqueMultiDof__SWIG_0(swigCPtr, this, i, dof, Q); } public void addJointTorqueMultiDof (int i, java.nio.FloatBuffer Q) { assert Q.isDirect() : "Buffer must be allocated direct."; { DynamicsJNI.btMultiBody_addJointTorqueMultiDof__SWIG_1(swigCPtr, this, i, Q); } } public Vector3 getBaseForce () { return DynamicsJNI.btMultiBody_getBaseForce(swigCPtr, this); } public Vector3 getBaseTorque () { return DynamicsJNI.btMultiBody_getBaseTorque(swigCPtr, this); } public Vector3 getLinkForce (int i) { return DynamicsJNI.btMultiBody_getLinkForce(swigCPtr, this, i); } public Vector3 getLinkTorque (int i) { return DynamicsJNI.btMultiBody_getLinkTorque(swigCPtr, this, i); } public float getJointTorque (int i) { return DynamicsJNI.btMultiBody_getJointTorque(swigCPtr, this, i); } public java.nio.FloatBuffer getJointTorqueMultiDof (int i) { return DynamicsJNI.btMultiBody_getJointTorqueMultiDof(swigCPtr, this, i); } public void computeAccelerationsArticulatedBodyAlgorithmMultiDof (float dt, btScalarArray scratch_r, btVector3Array scratch_v, SWIGTYPE_p_btAlignedObjectArrayT_btMatrix3x3_t scratch_m, boolean isConstraintPass) { DynamicsJNI.btMultiBody_computeAccelerationsArticulatedBodyAlgorithmMultiDof__SWIG_0(swigCPtr, this, dt, btScalarArray.getCPtr(scratch_r), scratch_r, btVector3Array.getCPtr(scratch_v), scratch_v, SWIGTYPE_p_btAlignedObjectArrayT_btMatrix3x3_t.getCPtr(scratch_m), isConstraintPass); } public void computeAccelerationsArticulatedBodyAlgorithmMultiDof (float dt, btScalarArray scratch_r, btVector3Array scratch_v, SWIGTYPE_p_btAlignedObjectArrayT_btMatrix3x3_t scratch_m) { DynamicsJNI.btMultiBody_computeAccelerationsArticulatedBodyAlgorithmMultiDof__SWIG_1(swigCPtr, this, dt, btScalarArray.getCPtr(scratch_r), scratch_r, btVector3Array.getCPtr(scratch_v), scratch_v, SWIGTYPE_p_btAlignedObjectArrayT_btMatrix3x3_t.getCPtr(scratch_m)); } public void stepVelocitiesMultiDof (float dt, btScalarArray scratch_r, btVector3Array scratch_v, SWIGTYPE_p_btAlignedObjectArrayT_btMatrix3x3_t scratch_m, boolean isConstraintPass) { DynamicsJNI.btMultiBody_stepVelocitiesMultiDof__SWIG_0(swigCPtr, this, dt, btScalarArray.getCPtr(scratch_r), scratch_r, btVector3Array.getCPtr(scratch_v), scratch_v, SWIGTYPE_p_btAlignedObjectArrayT_btMatrix3x3_t.getCPtr(scratch_m), isConstraintPass); } public void stepVelocitiesMultiDof (float dt, btScalarArray scratch_r, btVector3Array scratch_v, SWIGTYPE_p_btAlignedObjectArrayT_btMatrix3x3_t scratch_m) { DynamicsJNI.btMultiBody_stepVelocitiesMultiDof__SWIG_1(swigCPtr, this, dt, btScalarArray.getCPtr(scratch_r), scratch_r, btVector3Array.getCPtr(scratch_v), scratch_v, SWIGTYPE_p_btAlignedObjectArrayT_btMatrix3x3_t.getCPtr(scratch_m)); } public void calcAccelerationDeltasMultiDof (java.nio.FloatBuffer force, java.nio.FloatBuffer output, btScalarArray scratch_r, btVector3Array scratch_v) { assert force.isDirect() : "Buffer must be allocated direct."; assert output.isDirect() : "Buffer must be allocated direct."; { DynamicsJNI.btMultiBody_calcAccelerationDeltasMultiDof(swigCPtr, this, force, output, btScalarArray.getCPtr(scratch_r), scratch_r, btVector3Array.getCPtr(scratch_v), scratch_v); } } public void applyDeltaVeeMultiDof2 (java.nio.FloatBuffer delta_vee, float multiplier) { assert delta_vee.isDirect() : "Buffer must be allocated direct."; { DynamicsJNI.btMultiBody_applyDeltaVeeMultiDof2(swigCPtr, this, delta_vee, multiplier); } } public void processDeltaVeeMultiDof2 () { DynamicsJNI.btMultiBody_processDeltaVeeMultiDof2(swigCPtr, this); } public void applyDeltaVeeMultiDof (java.nio.FloatBuffer delta_vee, float multiplier) { assert delta_vee.isDirect() : "Buffer must be allocated direct."; { DynamicsJNI.btMultiBody_applyDeltaVeeMultiDof(swigCPtr, this, delta_vee, multiplier); } } public void stepPositionsMultiDof (float dt, java.nio.FloatBuffer pq, java.nio.FloatBuffer pqd) { assert pq.isDirect() : "Buffer must be allocated direct."; assert pqd.isDirect() : "Buffer must be allocated direct."; { DynamicsJNI.btMultiBody_stepPositionsMultiDof__SWIG_0(swigCPtr, this, dt, pq, pqd); } } public void stepPositionsMultiDof (float dt, java.nio.FloatBuffer pq) { assert pq.isDirect() : "Buffer must be allocated direct."; { DynamicsJNI.btMultiBody_stepPositionsMultiDof__SWIG_1(swigCPtr, this, dt, pq); } } public void stepPositionsMultiDof (float dt) { DynamicsJNI.btMultiBody_stepPositionsMultiDof__SWIG_2(swigCPtr, this, dt); } public void fillContactJacobianMultiDof (int link, Vector3 contact_point, Vector3 normal, java.nio.FloatBuffer jac, btScalarArray scratch_r, btVector3Array scratch_v, SWIGTYPE_p_btAlignedObjectArrayT_btMatrix3x3_t scratch_m) { assert jac.isDirect() : "Buffer must be allocated direct."; { DynamicsJNI.btMultiBody_fillContactJacobianMultiDof(swigCPtr, this, link, contact_point, normal, jac, btScalarArray.getCPtr(scratch_r), scratch_r, btVector3Array.getCPtr(scratch_v), scratch_v, SWIGTYPE_p_btAlignedObjectArrayT_btMatrix3x3_t.getCPtr(scratch_m)); } } public void fillConstraintJacobianMultiDof (int link, Vector3 contact_point, Vector3 normal_ang, Vector3 normal_lin, java.nio.FloatBuffer jac, btScalarArray scratch_r, btVector3Array scratch_v, SWIGTYPE_p_btAlignedObjectArrayT_btMatrix3x3_t scratch_m) { assert jac.isDirect() : "Buffer must be allocated direct."; { DynamicsJNI.btMultiBody_fillConstraintJacobianMultiDof(swigCPtr, this, link, contact_point, normal_ang, normal_lin, jac, btScalarArray.getCPtr(scratch_r), scratch_r, btVector3Array.getCPtr(scratch_v), scratch_v, SWIGTYPE_p_btAlignedObjectArrayT_btMatrix3x3_t.getCPtr(scratch_m)); } } public void setCanSleep (boolean canSleep) { DynamicsJNI.btMultiBody_setCanSleep(swigCPtr, this, canSleep); } public boolean getCanSleep () { return DynamicsJNI.btMultiBody_getCanSleep(swigCPtr, this); } public boolean isAwake () { return DynamicsJNI.btMultiBody_isAwake(swigCPtr, this); } public void wakeUp () { DynamicsJNI.btMultiBody_wakeUp(swigCPtr, this); } public void goToSleep () { DynamicsJNI.btMultiBody_goToSleep(swigCPtr, this); } public void checkMotionAndSleepIfRequired (float timestep) { DynamicsJNI.btMultiBody_checkMotionAndSleepIfRequired(swigCPtr, this, timestep); } public boolean hasFixedBase () { return DynamicsJNI.btMultiBody_hasFixedBase(swigCPtr, this); } public int getCompanionId () { return DynamicsJNI.btMultiBody_getCompanionId(swigCPtr, this); } public void setCompanionId (int id) { DynamicsJNI.btMultiBody_setCompanionId(swigCPtr, this, id); } public void setNumLinks (int numLinks) { DynamicsJNI.btMultiBody_setNumLinks(swigCPtr, this, numLinks); } public float getLinearDamping () { return DynamicsJNI.btMultiBody_getLinearDamping(swigCPtr, this); } public void setLinearDamping (float damp) { DynamicsJNI.btMultiBody_setLinearDamping(swigCPtr, this, damp); } public float getAngularDamping () { return DynamicsJNI.btMultiBody_getAngularDamping(swigCPtr, this); } public void setAngularDamping (float damp) { DynamicsJNI.btMultiBody_setAngularDamping(swigCPtr, this, damp); } public boolean getUseGyroTerm () { return DynamicsJNI.btMultiBody_getUseGyroTerm(swigCPtr, this); } public void setUseGyroTerm (boolean useGyro) { DynamicsJNI.btMultiBody_setUseGyroTerm(swigCPtr, this, useGyro); } public float getMaxCoordinateVelocity () { return DynamicsJNI.btMultiBody_getMaxCoordinateVelocity(swigCPtr, this); } public void setMaxCoordinateVelocity (float maxVel) { DynamicsJNI.btMultiBody_setMaxCoordinateVelocity(swigCPtr, this, maxVel); } public float getMaxAppliedImpulse () { return DynamicsJNI.btMultiBody_getMaxAppliedImpulse(swigCPtr, this); } public void setMaxAppliedImpulse (float maxImp) { DynamicsJNI.btMultiBody_setMaxAppliedImpulse(swigCPtr, this, maxImp); } public void setHasSelfCollision (boolean hasSelfCollision) { DynamicsJNI.btMultiBody_setHasSelfCollision(swigCPtr, this, hasSelfCollision); } public boolean hasSelfCollision () { return DynamicsJNI.btMultiBody_hasSelfCollision(swigCPtr, this); } public void finalizeMultiDof () { DynamicsJNI.btMultiBody_finalizeMultiDof(swigCPtr, this); } public void useRK4Integration (boolean use) { DynamicsJNI.btMultiBody_useRK4Integration(swigCPtr, this, use); } public boolean isUsingRK4Integration () { return DynamicsJNI.btMultiBody_isUsingRK4Integration(swigCPtr, this); } public void useGlobalVelocities (boolean use) { DynamicsJNI.btMultiBody_useGlobalVelocities(swigCPtr, this, use); } public boolean isUsingGlobalVelocities () { return DynamicsJNI.btMultiBody_isUsingGlobalVelocities(swigCPtr, this); } public boolean isPosUpdated () { return DynamicsJNI.btMultiBody_isPosUpdated(swigCPtr, this); } public void setPosUpdated (boolean updated) { DynamicsJNI.btMultiBody_setPosUpdated(swigCPtr, this, updated); } public boolean internalNeedsJointFeedback () { return DynamicsJNI.btMultiBody_internalNeedsJointFeedback(swigCPtr, this); } public void forwardKinematics (SWIGTYPE_p_btAlignedObjectArrayT_btQuaternion_t scratch_q, btVector3Array scratch_m) { DynamicsJNI.btMultiBody_forwardKinematics(swigCPtr, this, SWIGTYPE_p_btAlignedObjectArrayT_btQuaternion_t.getCPtr(scratch_q), btVector3Array.getCPtr(scratch_m), scratch_m); } public void compTreeLinkVelocities (btVector3 omega, btVector3 vel) { DynamicsJNI.btMultiBody_compTreeLinkVelocities(swigCPtr, this, btVector3.getCPtr(omega), omega, btVector3.getCPtr(vel), vel); } public void updateCollisionObjectWorldTransforms (SWIGTYPE_p_btAlignedObjectArrayT_btQuaternion_t scratch_q, btVector3Array scratch_m) { DynamicsJNI.btMultiBody_updateCollisionObjectWorldTransforms(swigCPtr, this, SWIGTYPE_p_btAlignedObjectArrayT_btQuaternion_t.getCPtr(scratch_q), btVector3Array.getCPtr(scratch_m), scratch_m); } public int calculateSerializeBufferSize () { return DynamicsJNI.btMultiBody_calculateSerializeBufferSize(swigCPtr, this); } public String serialize (long dataBuffer, btSerializer serializer) { return DynamicsJNI.btMultiBody_serialize(swigCPtr, this, dataBuffer, btSerializer.getCPtr(serializer), serializer); } public String getBaseName () { return DynamicsJNI.btMultiBody_getBaseName(swigCPtr, this); } public void setBaseName (String name) { DynamicsJNI.btMultiBody_setBaseName(swigCPtr, this, name); } public long getUserPointer () { return DynamicsJNI.btMultiBody_getUserPointer(swigCPtr, this); } public int getUserIndex () { return DynamicsJNI.btMultiBody_getUserIndex(swigCPtr, this); } public int getUserIndex2 () { return DynamicsJNI.btMultiBody_getUserIndex2(swigCPtr, this); } public void setUserPointer (long userPointer) { DynamicsJNI.btMultiBody_setUserPointer(swigCPtr, this, userPointer); } public void setUserIndex (int index) { DynamicsJNI.btMultiBody_setUserIndex(swigCPtr, this, index); } public void setUserIndex2 (int index) { DynamicsJNI.btMultiBody_setUserIndex2(swigCPtr, this, index); } }
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.dynamics; import com.badlogic.gdx.physics.bullet.BulletBase; import com.badlogic.gdx.physics.bullet.linearmath.*; import com.badlogic.gdx.physics.bullet.collision.*; import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.math.Quaternion; import com.badlogic.gdx.math.Matrix3; import com.badlogic.gdx.math.Matrix4; public class btMultiBody extends BulletBase { private long swigCPtr; protected btMultiBody (final String className, long cPtr, boolean cMemoryOwn) { super(className, cPtr, cMemoryOwn); swigCPtr = cPtr; } /** Construct a new btMultiBody, normally you should not need this constructor it's intended for low-level usage. */ public btMultiBody (long cPtr, boolean cMemoryOwn) { this("btMultiBody", cPtr, cMemoryOwn); construct(); } @Override protected void reset (long cPtr, boolean cMemoryOwn) { if (!destroyed) destroy(); super.reset(swigCPtr = cPtr, cMemoryOwn); } public static long getCPtr (btMultiBody obj) { return (obj == null) ? 0 : obj.swigCPtr; } @Override protected void finalize () throws Throwable { if (!destroyed) destroy(); super.finalize(); } @Override protected synchronized void delete () { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; DynamicsJNI.delete_btMultiBody(swigCPtr); } swigCPtr = 0; } super.delete(); } public long operatorNew (long sizeInBytes) { return DynamicsJNI.btMultiBody_operatorNew__SWIG_0(swigCPtr, this, sizeInBytes); } public void operatorDelete (long ptr) { DynamicsJNI.btMultiBody_operatorDelete__SWIG_0(swigCPtr, this, ptr); } public long operatorNew (long arg0, long ptr) { return DynamicsJNI.btMultiBody_operatorNew__SWIG_1(swigCPtr, this, arg0, ptr); } public void operatorDelete (long arg0, long arg1) { DynamicsJNI.btMultiBody_operatorDelete__SWIG_1(swigCPtr, this, arg0, arg1); } public long operatorNewArray (long sizeInBytes) { return DynamicsJNI.btMultiBody_operatorNewArray__SWIG_0(swigCPtr, this, sizeInBytes); } public void operatorDeleteArray (long ptr) { DynamicsJNI.btMultiBody_operatorDeleteArray__SWIG_0(swigCPtr, this, ptr); } public long operatorNewArray (long arg0, long ptr) { return DynamicsJNI.btMultiBody_operatorNewArray__SWIG_1(swigCPtr, this, arg0, ptr); } public void operatorDeleteArray (long arg0, long arg1) { DynamicsJNI.btMultiBody_operatorDeleteArray__SWIG_1(swigCPtr, this, arg0, arg1); } public btMultiBody (int n_links, float mass, Vector3 inertia, boolean fixedBase, boolean canSleep, boolean deprecatedMultiDof) { this(DynamicsJNI.new_btMultiBody__SWIG_0(n_links, mass, inertia, fixedBase, canSleep, deprecatedMultiDof), true); } public btMultiBody (int n_links, float mass, Vector3 inertia, boolean fixedBase, boolean canSleep) { this(DynamicsJNI.new_btMultiBody__SWIG_1(n_links, mass, inertia, fixedBase, canSleep), true); } public void setupFixed (int linkIndex, float mass, Vector3 inertia, int parent, Quaternion rotParentToThis, Vector3 parentComToThisPivotOffset, Vector3 thisPivotToThisComOffset, boolean deprecatedDisableParentCollision) { DynamicsJNI.btMultiBody_setupFixed__SWIG_0(swigCPtr, this, linkIndex, mass, inertia, parent, rotParentToThis, parentComToThisPivotOffset, thisPivotToThisComOffset, deprecatedDisableParentCollision); } public void setupFixed (int linkIndex, float mass, Vector3 inertia, int parent, Quaternion rotParentToThis, Vector3 parentComToThisPivotOffset, Vector3 thisPivotToThisComOffset) { DynamicsJNI.btMultiBody_setupFixed__SWIG_1(swigCPtr, this, linkIndex, mass, inertia, parent, rotParentToThis, parentComToThisPivotOffset, thisPivotToThisComOffset); } public void setupPrismatic (int i, float mass, Vector3 inertia, int parent, Quaternion rotParentToThis, Vector3 jointAxis, Vector3 parentComToThisPivotOffset, Vector3 thisPivotToThisComOffset, boolean disableParentCollision) { DynamicsJNI.btMultiBody_setupPrismatic(swigCPtr, this, i, mass, inertia, parent, rotParentToThis, jointAxis, parentComToThisPivotOffset, thisPivotToThisComOffset, disableParentCollision); } public void setupRevolute (int linkIndex, float mass, Vector3 inertia, int parentIndex, Quaternion rotParentToThis, Vector3 jointAxis, Vector3 parentComToThisPivotOffset, Vector3 thisPivotToThisComOffset, boolean disableParentCollision) { DynamicsJNI.btMultiBody_setupRevolute__SWIG_0(swigCPtr, this, linkIndex, mass, inertia, parentIndex, rotParentToThis, jointAxis, parentComToThisPivotOffset, thisPivotToThisComOffset, disableParentCollision); } public void setupRevolute (int linkIndex, float mass, Vector3 inertia, int parentIndex, Quaternion rotParentToThis, Vector3 jointAxis, Vector3 parentComToThisPivotOffset, Vector3 thisPivotToThisComOffset) { DynamicsJNI.btMultiBody_setupRevolute__SWIG_1(swigCPtr, this, linkIndex, mass, inertia, parentIndex, rotParentToThis, jointAxis, parentComToThisPivotOffset, thisPivotToThisComOffset); } public void setupSpherical (int linkIndex, float mass, Vector3 inertia, int parent, Quaternion rotParentToThis, Vector3 parentComToThisPivotOffset, Vector3 thisPivotToThisComOffset, boolean disableParentCollision) { DynamicsJNI.btMultiBody_setupSpherical__SWIG_0(swigCPtr, this, linkIndex, mass, inertia, parent, rotParentToThis, parentComToThisPivotOffset, thisPivotToThisComOffset, disableParentCollision); } public void setupSpherical (int linkIndex, float mass, Vector3 inertia, int parent, Quaternion rotParentToThis, Vector3 parentComToThisPivotOffset, Vector3 thisPivotToThisComOffset) { DynamicsJNI.btMultiBody_setupSpherical__SWIG_1(swigCPtr, this, linkIndex, mass, inertia, parent, rotParentToThis, parentComToThisPivotOffset, thisPivotToThisComOffset); } public void setupPlanar (int i, float mass, Vector3 inertia, int parent, Quaternion rotParentToThis, Vector3 rotationAxis, Vector3 parentComToThisComOffset, boolean disableParentCollision) { DynamicsJNI.btMultiBody_setupPlanar__SWIG_0(swigCPtr, this, i, mass, inertia, parent, rotParentToThis, rotationAxis, parentComToThisComOffset, disableParentCollision); } public void setupPlanar (int i, float mass, Vector3 inertia, int parent, Quaternion rotParentToThis, Vector3 rotationAxis, Vector3 parentComToThisComOffset) { DynamicsJNI.btMultiBody_setupPlanar__SWIG_1(swigCPtr, this, i, mass, inertia, parent, rotParentToThis, rotationAxis, parentComToThisComOffset); } public btMultibodyLink getLinkConst (int index) { return new btMultibodyLink(DynamicsJNI.btMultiBody_getLinkConst(swigCPtr, this, index), false); } public btMultibodyLink getLink (int index) { return new btMultibodyLink(DynamicsJNI.btMultiBody_getLink(swigCPtr, this, index), false); } public void setBaseCollider (btMultiBodyLinkCollider collider) { DynamicsJNI.btMultiBody_setBaseCollider(swigCPtr, this, btMultiBodyLinkCollider.getCPtr(collider), collider); } public btMultiBodyLinkCollider getBaseColliderConst () { long cPtr = DynamicsJNI.btMultiBody_getBaseColliderConst(swigCPtr, this); return (cPtr == 0) ? null : new btMultiBodyLinkCollider(cPtr, false); } public btMultiBodyLinkCollider getBaseCollider () { long cPtr = DynamicsJNI.btMultiBody_getBaseCollider(swigCPtr, this); return (cPtr == 0) ? null : new btMultiBodyLinkCollider(cPtr, false); } public btMultiBodyLinkCollider getLinkCollider (int index) { long cPtr = DynamicsJNI.btMultiBody_getLinkCollider(swigCPtr, this, index); return (cPtr == 0) ? null : new btMultiBodyLinkCollider(cPtr, false); } public int getParent (int link_num) { return DynamicsJNI.btMultiBody_getParent(swigCPtr, this, link_num); } public int getNumLinks () { return DynamicsJNI.btMultiBody_getNumLinks(swigCPtr, this); } public int getNumDofs () { return DynamicsJNI.btMultiBody_getNumDofs(swigCPtr, this); } public int getNumPosVars () { return DynamicsJNI.btMultiBody_getNumPosVars(swigCPtr, this); } public float getBaseMass () { return DynamicsJNI.btMultiBody_getBaseMass(swigCPtr, this); } public Vector3 getBaseInertia () { return DynamicsJNI.btMultiBody_getBaseInertia(swigCPtr, this); } public float getLinkMass (int i) { return DynamicsJNI.btMultiBody_getLinkMass(swigCPtr, this, i); } public Vector3 getLinkInertia (int i) { return DynamicsJNI.btMultiBody_getLinkInertia(swigCPtr, this, i); } public void setBaseMass (float mass) { DynamicsJNI.btMultiBody_setBaseMass(swigCPtr, this, mass); } public void setBaseInertia (Vector3 inertia) { DynamicsJNI.btMultiBody_setBaseInertia(swigCPtr, this, inertia); } public Vector3 getBasePos () { return DynamicsJNI.btMultiBody_getBasePos(swigCPtr, this); } public Vector3 getBaseVel () { return DynamicsJNI.btMultiBody_getBaseVel(swigCPtr, this); } public Quaternion getWorldToBaseRot () { return DynamicsJNI.btMultiBody_getWorldToBaseRot(swigCPtr, this); } public Vector3 getBaseOmega () { return DynamicsJNI.btMultiBody_getBaseOmega(swigCPtr, this); } public void setBasePos (Vector3 pos) { DynamicsJNI.btMultiBody_setBasePos(swigCPtr, this, pos); } public void setBaseWorldTransform (Matrix4 tr) { DynamicsJNI.btMultiBody_setBaseWorldTransform(swigCPtr, this, tr); } public Matrix4 getBaseWorldTransform () { return DynamicsJNI.btMultiBody_getBaseWorldTransform(swigCPtr, this); } public void setBaseVel (Vector3 vel) { DynamicsJNI.btMultiBody_setBaseVel(swigCPtr, this, vel); } public void setWorldToBaseRot (Quaternion rot) { DynamicsJNI.btMultiBody_setWorldToBaseRot(swigCPtr, this, rot); } public void setBaseOmega (Vector3 omega) { DynamicsJNI.btMultiBody_setBaseOmega(swigCPtr, this, omega); } public float getJointPos (int i) { return DynamicsJNI.btMultiBody_getJointPos(swigCPtr, this, i); } public float getJointVel (int i) { return DynamicsJNI.btMultiBody_getJointVel(swigCPtr, this, i); } public java.nio.FloatBuffer getJointVelMultiDof (int i) { return DynamicsJNI.btMultiBody_getJointVelMultiDof(swigCPtr, this, i); } public java.nio.FloatBuffer getJointPosMultiDof (int i) { return DynamicsJNI.btMultiBody_getJointPosMultiDof(swigCPtr, this, i); } public java.nio.FloatBuffer getJointVelMultiDofConst (int i) { return DynamicsJNI.btMultiBody_getJointVelMultiDofConst(swigCPtr, this, i); } public java.nio.FloatBuffer getJointPosMultiDofConst (int i) { return DynamicsJNI.btMultiBody_getJointPosMultiDofConst(swigCPtr, this, i); } public void setJointPos (int i, float q) { DynamicsJNI.btMultiBody_setJointPos(swigCPtr, this, i, q); } public void setJointVel (int i, float qdot) { DynamicsJNI.btMultiBody_setJointVel(swigCPtr, this, i, qdot); } public void setJointPosMultiDof (int i, java.nio.FloatBuffer q) { assert q.isDirect() : "Buffer must be allocated direct."; { DynamicsJNI.btMultiBody_setJointPosMultiDof(swigCPtr, this, i, q); } } public void setJointVelMultiDof (int i, java.nio.FloatBuffer qdot) { assert qdot.isDirect() : "Buffer must be allocated direct."; { DynamicsJNI.btMultiBody_setJointVelMultiDof(swigCPtr, this, i, qdot); } } public java.nio.FloatBuffer getVelocityVector () { return DynamicsJNI.btMultiBody_getVelocityVector(swigCPtr, this); } public Vector3 getRVector (int i) { return DynamicsJNI.btMultiBody_getRVector(swigCPtr, this, i); } public Quaternion getParentToLocalRot (int i) { return DynamicsJNI.btMultiBody_getParentToLocalRot(swigCPtr, this, i); } public Vector3 localPosToWorld (int i, Vector3 vec) { return DynamicsJNI.btMultiBody_localPosToWorld(swigCPtr, this, i, vec); } public Vector3 localDirToWorld (int i, Vector3 vec) { return DynamicsJNI.btMultiBody_localDirToWorld(swigCPtr, this, i, vec); } public Vector3 worldPosToLocal (int i, Vector3 vec) { return DynamicsJNI.btMultiBody_worldPosToLocal(swigCPtr, this, i, vec); } public Vector3 worldDirToLocal (int i, Vector3 vec) { return DynamicsJNI.btMultiBody_worldDirToLocal(swigCPtr, this, i, vec); } public Matrix3 localFrameToWorld (int i, Matrix3 mat) { return DynamicsJNI.btMultiBody_localFrameToWorld(swigCPtr, this, i, mat); } public float getKineticEnergy () { return DynamicsJNI.btMultiBody_getKineticEnergy(swigCPtr, this); } public Vector3 getAngularMomentum () { return DynamicsJNI.btMultiBody_getAngularMomentum(swigCPtr, this); } public void clearForcesAndTorques () { DynamicsJNI.btMultiBody_clearForcesAndTorques(swigCPtr, this); } public void clearConstraintForces () { DynamicsJNI.btMultiBody_clearConstraintForces(swigCPtr, this); } public void clearVelocities () { DynamicsJNI.btMultiBody_clearVelocities(swigCPtr, this); } public void addBaseForce (Vector3 f) { DynamicsJNI.btMultiBody_addBaseForce(swigCPtr, this, f); } public void addBaseTorque (Vector3 t) { DynamicsJNI.btMultiBody_addBaseTorque(swigCPtr, this, t); } public void addLinkForce (int i, Vector3 f) { DynamicsJNI.btMultiBody_addLinkForce(swigCPtr, this, i, f); } public void addLinkTorque (int i, Vector3 t) { DynamicsJNI.btMultiBody_addLinkTorque(swigCPtr, this, i, t); } public void addBaseConstraintForce (Vector3 f) { DynamicsJNI.btMultiBody_addBaseConstraintForce(swigCPtr, this, f); } public void addBaseConstraintTorque (Vector3 t) { DynamicsJNI.btMultiBody_addBaseConstraintTorque(swigCPtr, this, t); } public void addLinkConstraintForce (int i, Vector3 f) { DynamicsJNI.btMultiBody_addLinkConstraintForce(swigCPtr, this, i, f); } public void addLinkConstraintTorque (int i, Vector3 t) { DynamicsJNI.btMultiBody_addLinkConstraintTorque(swigCPtr, this, i, t); } public void addJointTorque (int i, float Q) { DynamicsJNI.btMultiBody_addJointTorque(swigCPtr, this, i, Q); } public void addJointTorqueMultiDof (int i, int dof, float Q) { DynamicsJNI.btMultiBody_addJointTorqueMultiDof__SWIG_0(swigCPtr, this, i, dof, Q); } public void addJointTorqueMultiDof (int i, java.nio.FloatBuffer Q) { assert Q.isDirect() : "Buffer must be allocated direct."; { DynamicsJNI.btMultiBody_addJointTorqueMultiDof__SWIG_1(swigCPtr, this, i, Q); } } public Vector3 getBaseForce () { return DynamicsJNI.btMultiBody_getBaseForce(swigCPtr, this); } public Vector3 getBaseTorque () { return DynamicsJNI.btMultiBody_getBaseTorque(swigCPtr, this); } public Vector3 getLinkForce (int i) { return DynamicsJNI.btMultiBody_getLinkForce(swigCPtr, this, i); } public Vector3 getLinkTorque (int i) { return DynamicsJNI.btMultiBody_getLinkTorque(swigCPtr, this, i); } public float getJointTorque (int i) { return DynamicsJNI.btMultiBody_getJointTorque(swigCPtr, this, i); } public java.nio.FloatBuffer getJointTorqueMultiDof (int i) { return DynamicsJNI.btMultiBody_getJointTorqueMultiDof(swigCPtr, this, i); } public void computeAccelerationsArticulatedBodyAlgorithmMultiDof (float dt, btScalarArray scratch_r, btVector3Array scratch_v, SWIGTYPE_p_btAlignedObjectArrayT_btMatrix3x3_t scratch_m, boolean isConstraintPass) { DynamicsJNI.btMultiBody_computeAccelerationsArticulatedBodyAlgorithmMultiDof__SWIG_0(swigCPtr, this, dt, btScalarArray.getCPtr(scratch_r), scratch_r, btVector3Array.getCPtr(scratch_v), scratch_v, SWIGTYPE_p_btAlignedObjectArrayT_btMatrix3x3_t.getCPtr(scratch_m), isConstraintPass); } public void computeAccelerationsArticulatedBodyAlgorithmMultiDof (float dt, btScalarArray scratch_r, btVector3Array scratch_v, SWIGTYPE_p_btAlignedObjectArrayT_btMatrix3x3_t scratch_m) { DynamicsJNI.btMultiBody_computeAccelerationsArticulatedBodyAlgorithmMultiDof__SWIG_1(swigCPtr, this, dt, btScalarArray.getCPtr(scratch_r), scratch_r, btVector3Array.getCPtr(scratch_v), scratch_v, SWIGTYPE_p_btAlignedObjectArrayT_btMatrix3x3_t.getCPtr(scratch_m)); } public void stepVelocitiesMultiDof (float dt, btScalarArray scratch_r, btVector3Array scratch_v, SWIGTYPE_p_btAlignedObjectArrayT_btMatrix3x3_t scratch_m, boolean isConstraintPass) { DynamicsJNI.btMultiBody_stepVelocitiesMultiDof__SWIG_0(swigCPtr, this, dt, btScalarArray.getCPtr(scratch_r), scratch_r, btVector3Array.getCPtr(scratch_v), scratch_v, SWIGTYPE_p_btAlignedObjectArrayT_btMatrix3x3_t.getCPtr(scratch_m), isConstraintPass); } public void stepVelocitiesMultiDof (float dt, btScalarArray scratch_r, btVector3Array scratch_v, SWIGTYPE_p_btAlignedObjectArrayT_btMatrix3x3_t scratch_m) { DynamicsJNI.btMultiBody_stepVelocitiesMultiDof__SWIG_1(swigCPtr, this, dt, btScalarArray.getCPtr(scratch_r), scratch_r, btVector3Array.getCPtr(scratch_v), scratch_v, SWIGTYPE_p_btAlignedObjectArrayT_btMatrix3x3_t.getCPtr(scratch_m)); } public void calcAccelerationDeltasMultiDof (java.nio.FloatBuffer force, java.nio.FloatBuffer output, btScalarArray scratch_r, btVector3Array scratch_v) { assert force.isDirect() : "Buffer must be allocated direct."; assert output.isDirect() : "Buffer must be allocated direct."; { DynamicsJNI.btMultiBody_calcAccelerationDeltasMultiDof(swigCPtr, this, force, output, btScalarArray.getCPtr(scratch_r), scratch_r, btVector3Array.getCPtr(scratch_v), scratch_v); } } public void applyDeltaVeeMultiDof2 (java.nio.FloatBuffer delta_vee, float multiplier) { assert delta_vee.isDirect() : "Buffer must be allocated direct."; { DynamicsJNI.btMultiBody_applyDeltaVeeMultiDof2(swigCPtr, this, delta_vee, multiplier); } } public void processDeltaVeeMultiDof2 () { DynamicsJNI.btMultiBody_processDeltaVeeMultiDof2(swigCPtr, this); } public void applyDeltaVeeMultiDof (java.nio.FloatBuffer delta_vee, float multiplier) { assert delta_vee.isDirect() : "Buffer must be allocated direct."; { DynamicsJNI.btMultiBody_applyDeltaVeeMultiDof(swigCPtr, this, delta_vee, multiplier); } } public void stepPositionsMultiDof (float dt, java.nio.FloatBuffer pq, java.nio.FloatBuffer pqd) { assert pq.isDirect() : "Buffer must be allocated direct."; assert pqd.isDirect() : "Buffer must be allocated direct."; { DynamicsJNI.btMultiBody_stepPositionsMultiDof__SWIG_0(swigCPtr, this, dt, pq, pqd); } } public void stepPositionsMultiDof (float dt, java.nio.FloatBuffer pq) { assert pq.isDirect() : "Buffer must be allocated direct."; { DynamicsJNI.btMultiBody_stepPositionsMultiDof__SWIG_1(swigCPtr, this, dt, pq); } } public void stepPositionsMultiDof (float dt) { DynamicsJNI.btMultiBody_stepPositionsMultiDof__SWIG_2(swigCPtr, this, dt); } public void fillContactJacobianMultiDof (int link, Vector3 contact_point, Vector3 normal, java.nio.FloatBuffer jac, btScalarArray scratch_r, btVector3Array scratch_v, SWIGTYPE_p_btAlignedObjectArrayT_btMatrix3x3_t scratch_m) { assert jac.isDirect() : "Buffer must be allocated direct."; { DynamicsJNI.btMultiBody_fillContactJacobianMultiDof(swigCPtr, this, link, contact_point, normal, jac, btScalarArray.getCPtr(scratch_r), scratch_r, btVector3Array.getCPtr(scratch_v), scratch_v, SWIGTYPE_p_btAlignedObjectArrayT_btMatrix3x3_t.getCPtr(scratch_m)); } } public void fillConstraintJacobianMultiDof (int link, Vector3 contact_point, Vector3 normal_ang, Vector3 normal_lin, java.nio.FloatBuffer jac, btScalarArray scratch_r, btVector3Array scratch_v, SWIGTYPE_p_btAlignedObjectArrayT_btMatrix3x3_t scratch_m) { assert jac.isDirect() : "Buffer must be allocated direct."; { DynamicsJNI.btMultiBody_fillConstraintJacobianMultiDof(swigCPtr, this, link, contact_point, normal_ang, normal_lin, jac, btScalarArray.getCPtr(scratch_r), scratch_r, btVector3Array.getCPtr(scratch_v), scratch_v, SWIGTYPE_p_btAlignedObjectArrayT_btMatrix3x3_t.getCPtr(scratch_m)); } } public void setCanSleep (boolean canSleep) { DynamicsJNI.btMultiBody_setCanSleep(swigCPtr, this, canSleep); } public boolean getCanSleep () { return DynamicsJNI.btMultiBody_getCanSleep(swigCPtr, this); } public boolean isAwake () { return DynamicsJNI.btMultiBody_isAwake(swigCPtr, this); } public void wakeUp () { DynamicsJNI.btMultiBody_wakeUp(swigCPtr, this); } public void goToSleep () { DynamicsJNI.btMultiBody_goToSleep(swigCPtr, this); } public void checkMotionAndSleepIfRequired (float timestep) { DynamicsJNI.btMultiBody_checkMotionAndSleepIfRequired(swigCPtr, this, timestep); } public boolean hasFixedBase () { return DynamicsJNI.btMultiBody_hasFixedBase(swigCPtr, this); } public int getCompanionId () { return DynamicsJNI.btMultiBody_getCompanionId(swigCPtr, this); } public void setCompanionId (int id) { DynamicsJNI.btMultiBody_setCompanionId(swigCPtr, this, id); } public void setNumLinks (int numLinks) { DynamicsJNI.btMultiBody_setNumLinks(swigCPtr, this, numLinks); } public float getLinearDamping () { return DynamicsJNI.btMultiBody_getLinearDamping(swigCPtr, this); } public void setLinearDamping (float damp) { DynamicsJNI.btMultiBody_setLinearDamping(swigCPtr, this, damp); } public float getAngularDamping () { return DynamicsJNI.btMultiBody_getAngularDamping(swigCPtr, this); } public void setAngularDamping (float damp) { DynamicsJNI.btMultiBody_setAngularDamping(swigCPtr, this, damp); } public boolean getUseGyroTerm () { return DynamicsJNI.btMultiBody_getUseGyroTerm(swigCPtr, this); } public void setUseGyroTerm (boolean useGyro) { DynamicsJNI.btMultiBody_setUseGyroTerm(swigCPtr, this, useGyro); } public float getMaxCoordinateVelocity () { return DynamicsJNI.btMultiBody_getMaxCoordinateVelocity(swigCPtr, this); } public void setMaxCoordinateVelocity (float maxVel) { DynamicsJNI.btMultiBody_setMaxCoordinateVelocity(swigCPtr, this, maxVel); } public float getMaxAppliedImpulse () { return DynamicsJNI.btMultiBody_getMaxAppliedImpulse(swigCPtr, this); } public void setMaxAppliedImpulse (float maxImp) { DynamicsJNI.btMultiBody_setMaxAppliedImpulse(swigCPtr, this, maxImp); } public void setHasSelfCollision (boolean hasSelfCollision) { DynamicsJNI.btMultiBody_setHasSelfCollision(swigCPtr, this, hasSelfCollision); } public boolean hasSelfCollision () { return DynamicsJNI.btMultiBody_hasSelfCollision(swigCPtr, this); } public void finalizeMultiDof () { DynamicsJNI.btMultiBody_finalizeMultiDof(swigCPtr, this); } public void useRK4Integration (boolean use) { DynamicsJNI.btMultiBody_useRK4Integration(swigCPtr, this, use); } public boolean isUsingRK4Integration () { return DynamicsJNI.btMultiBody_isUsingRK4Integration(swigCPtr, this); } public void useGlobalVelocities (boolean use) { DynamicsJNI.btMultiBody_useGlobalVelocities(swigCPtr, this, use); } public boolean isUsingGlobalVelocities () { return DynamicsJNI.btMultiBody_isUsingGlobalVelocities(swigCPtr, this); } public boolean isPosUpdated () { return DynamicsJNI.btMultiBody_isPosUpdated(swigCPtr, this); } public void setPosUpdated (boolean updated) { DynamicsJNI.btMultiBody_setPosUpdated(swigCPtr, this, updated); } public boolean internalNeedsJointFeedback () { return DynamicsJNI.btMultiBody_internalNeedsJointFeedback(swigCPtr, this); } public void forwardKinematics (SWIGTYPE_p_btAlignedObjectArrayT_btQuaternion_t scratch_q, btVector3Array scratch_m) { DynamicsJNI.btMultiBody_forwardKinematics(swigCPtr, this, SWIGTYPE_p_btAlignedObjectArrayT_btQuaternion_t.getCPtr(scratch_q), btVector3Array.getCPtr(scratch_m), scratch_m); } public void compTreeLinkVelocities (btVector3 omega, btVector3 vel) { DynamicsJNI.btMultiBody_compTreeLinkVelocities(swigCPtr, this, btVector3.getCPtr(omega), omega, btVector3.getCPtr(vel), vel); } public void updateCollisionObjectWorldTransforms (SWIGTYPE_p_btAlignedObjectArrayT_btQuaternion_t scratch_q, btVector3Array scratch_m) { DynamicsJNI.btMultiBody_updateCollisionObjectWorldTransforms(swigCPtr, this, SWIGTYPE_p_btAlignedObjectArrayT_btQuaternion_t.getCPtr(scratch_q), btVector3Array.getCPtr(scratch_m), scratch_m); } public int calculateSerializeBufferSize () { return DynamicsJNI.btMultiBody_calculateSerializeBufferSize(swigCPtr, this); } public String serialize (long dataBuffer, btSerializer serializer) { return DynamicsJNI.btMultiBody_serialize(swigCPtr, this, dataBuffer, btSerializer.getCPtr(serializer), serializer); } public String getBaseName () { return DynamicsJNI.btMultiBody_getBaseName(swigCPtr, this); } public void setBaseName (String name) { DynamicsJNI.btMultiBody_setBaseName(swigCPtr, this, name); } public long getUserPointer () { return DynamicsJNI.btMultiBody_getUserPointer(swigCPtr, this); } public int getUserIndex () { return DynamicsJNI.btMultiBody_getUserIndex(swigCPtr, this); } public int getUserIndex2 () { return DynamicsJNI.btMultiBody_getUserIndex2(swigCPtr, this); } public void setUserPointer (long userPointer) { DynamicsJNI.btMultiBody_setUserPointer(swigCPtr, this, userPointer); } public void setUserIndex (int index) { DynamicsJNI.btMultiBody_setUserIndex(swigCPtr, this, index); } public void setUserIndex2 (int index) { DynamicsJNI.btMultiBody_setUserIndex2(swigCPtr, this, index); } }
-1
libgdx/libgdx
7,250
chore: Update to gwt 2.10.0
I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
SimonIT
"2023-10-06T10:43:44Z"
"2023-11-12T07:23:11Z"
e688cf718d56048bd9ab3e61180b93ee46f399d7
93503b4120f2c6002c7b1ecc73fc36bef4b678a0
chore: Update to gwt 2.10.0. I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
./backends/gdx-backends-gwt/res/com/badlogic/gdx/backends/gdx_backends_gwt.gwt.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.5.1//EN" "http://www.gwtproject.org/doctype/2.5.1/gwt-module.dtd"> <module rename-to='com.badlogic.gdx.backends.gwt'> <inherits name='com.google.gwt.user.User' /> <!-- Inherit edited chrome theme ("gwt"-prefixed classes only) for a little bit of default styling in the text input dialogs --> <inherits name='com.badlogic.gdx.backends.gwt.theme.chrome.Chrome'/> <inherits name="com.google.gwt.http.HTTP"/> <inherits name="com.badlogic.gdx" /> <inherits name="com.google.gwt.webgl.WebGL" /> <inherits name="com.badlogic.gwtref.GwtReflect"/> <public path="gwt/resources"/> <super-source path="gwt/emu" /> <source path="gwt"> <exclude name="**/emu/**" /> <exclude name="**/theme/**" /> <exclude name="**/PreloaderBundleGenerator.java"/> <exclude name="**/FileWrapper.java"/> </source> <define-configuration-property name="gdx.assetpath" is-multi-valued="false"/> <define-configuration-property name="gdx.assetfilterclass" is-multi-valued="false"/> <define-configuration-property name="gdx.assetoutputpath" is-multi-valued="false"/> <generate-with class="com.badlogic.gdx.backends.gwt.preloader.PreloaderBundleGenerator"> <when-type-assignable class="com.badlogic.gdx.backends.gwt.preloader.PreloaderBundle"/> </generate-with> </module>
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.10.0//EN" "https://www.gwtproject.org/doctype/2.10.0/gwt-module.dtd"> <module rename-to='com.badlogic.gdx.backends.gwt'> <inherits name='com.google.gwt.user.User' /> <!-- Inherit edited chrome theme ("gwt"-prefixed classes only) for a little bit of default styling in the text input dialogs --> <inherits name='com.badlogic.gdx.backends.gwt.theme.chrome.Chrome'/> <inherits name="com.google.gwt.http.HTTP"/> <inherits name="com.badlogic.gdx" /> <inherits name="com.google.gwt.webgl.WebGL" /> <inherits name="com.badlogic.gwtref.GwtReflect"/> <inherits name="jsinterop.annotations.Annotations" /> <public path="gwt/resources"/> <super-source path="gwt/emu" /> <source path="gwt"> <exclude name="**/emu/**" /> <exclude name="**/theme/**" /> <exclude name="**/PreloaderBundleGenerator.java"/> <exclude name="**/FileWrapper.java"/> </source> <define-configuration-property name="gdx.assetpath" is-multi-valued="false"/> <define-configuration-property name="gdx.assetfilterclass" is-multi-valued="false"/> <define-configuration-property name="gdx.assetoutputpath" is-multi-valued="false"/> <generate-with class="com.badlogic.gdx.backends.gwt.preloader.PreloaderBundleGenerator"> <when-type-assignable class="com.badlogic.gdx.backends.gwt.preloader.PreloaderBundle"/> </generate-with> </module>
1
libgdx/libgdx
7,250
chore: Update to gwt 2.10.0
I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
SimonIT
"2023-10-06T10:43:44Z"
"2023-11-12T07:23:11Z"
e688cf718d56048bd9ab3e61180b93ee46f399d7
93503b4120f2c6002c7b1ecc73fc36bef4b678a0
chore: Update to gwt 2.10.0. I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
./backends/gdx-backends-gwt/res/com/badlogic/gwtref/GwtReflect.gwt.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit trunk//EN" "https://www.gwtproject.org/doctype/2.8.2/gwt-module.dtd"> <module> <inherits name='com.google.gwt.user.User' /> <define-configuration-property name="gdx.reflect.include" is-multi-valued="true" /> <define-configuration-property name="gdx.reflect.exclude" is-multi-valued="true" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.scenes.scene2d" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.math" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.g2d.GlyphLayout" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.g2d.TextureRegion" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.g2d.Sprite" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.g2d.BitmapFont" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.g2d.NinePatch" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.g3d.materials.MaterialAttribute" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.Color" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.Texture" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.utils.Array" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.utils.Disposable" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.utils.Json" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.utils.ObjectMap" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.utils.OrderedMap" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.utils.Queue" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.VertexAttribute" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.g3d.model" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.Net" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.maps.Map" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.maps.MapGroupLayer" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.maps.MapLayer" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.maps.MapLayers" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.maps.MapObject" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.maps.MapObjects" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.maps.MapProperties" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.maps.objects" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.maps.tiled.TiledMap" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.maps.tiled.TiledMapImageLayer" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.maps.tiled.TiledMapTileLayer" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.maps.tiled.TiledMapTileSet" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.maps.tiled.TiledMapTileSets" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.maps.tiled.objects" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.g3d.particles.ParticleEffect" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.g3d.particles.ParticleController" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.g3d.particles.ResourceData" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.g3d.particles.ResourceData.SaveData" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.g3d.particles.ResourceData.AssetData" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.g3d.particles.ParallelArray" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.g3d.particles.values" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.g3d.particles.emitters" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.g3d.particles.influencers" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.g3d.particles.renderers" /> <extend-configuration-property name="gdx.reflect.include" value="java.util.Collection" /> <extend-configuration-property name="gdx.reflect.include" value="java.util.List" /> <extend-configuration-property name="gdx.reflect.include" value="java.util.ArrayList" /> <extend-configuration-property name="gdx.reflect.include" value="java.util.Map" /> <extend-configuration-property name="gdx.reflect.include" value="java.util.HashMap" /> <extend-configuration-property name="gdx.reflect.include" value="java.lang.String" /> <extend-configuration-property name="gdx.reflect.include" value="java.lang.Boolean" /> <extend-configuration-property name="gdx.reflect.include" value="java.lang.Byte" /> <extend-configuration-property name="gdx.reflect.include" value="java.lang.Short" /> <extend-configuration-property name="gdx.reflect.include" value="java.lang.Character" /> <extend-configuration-property name="gdx.reflect.include" value="java.lang.Integer" /> <extend-configuration-property name="gdx.reflect.include" value="java.lang.Float" /> <extend-configuration-property name="gdx.reflect.include" value="java.lang.Double" /> <extend-configuration-property name="gdx.reflect.include" value="java.lang.CharSequence" /> <extend-configuration-property name="gdx.reflect.include" value="java.lang.Enum" /> <extend-configuration-property name="gdx.reflect.include" value="java.lang.Object" /> <generate-with class="com.badlogic.gwtref.gen.ReflectionCacheGenerator"> <when-type-assignable class="com.badlogic.gwtref.client.IReflectionCache" /> </generate-with> </module>
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit trunk//EN" "https://www.gwtproject.org/doctype/2.10.0/gwt-module.dtd"> <module> <inherits name='com.google.gwt.user.User' /> <define-configuration-property name="gdx.reflect.include" is-multi-valued="true" /> <define-configuration-property name="gdx.reflect.exclude" is-multi-valued="true" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.scenes.scene2d" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.math" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.g2d.GlyphLayout" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.g2d.TextureRegion" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.g2d.Sprite" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.g2d.BitmapFont" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.g2d.NinePatch" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.g2d.TextureAtlas.AtlasRegion" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.g3d.materials.MaterialAttribute" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.Color" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.Texture" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.utils.Array" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.utils.Disposable" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.utils.Json" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.utils.ObjectMap" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.utils.OrderedMap" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.utils.Queue" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.VertexAttribute" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.g3d.model" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.Net" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.maps.Map" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.maps.MapGroupLayer" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.maps.MapLayer" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.maps.MapLayers" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.maps.MapObject" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.maps.MapObjects" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.maps.MapProperties" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.maps.objects" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.maps.tiled.TiledMap" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.maps.tiled.TiledMapImageLayer" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.maps.tiled.TiledMapTileLayer" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.maps.tiled.TiledMapTileSet" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.maps.tiled.TiledMapTileSets" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.maps.tiled.objects" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.g3d.particles.ParticleEffect" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.g3d.particles.ParticleController" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.g3d.particles.ResourceData" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.g3d.particles.ResourceData.SaveData" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.g3d.particles.ResourceData.AssetData" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.g3d.particles.ParallelArray" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.g3d.particles.values" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.g3d.particles.emitters" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.g3d.particles.influencers" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.graphics.g3d.particles.renderers" /> <extend-configuration-property name="gdx.reflect.include" value="java.util.Collection" /> <extend-configuration-property name="gdx.reflect.include" value="java.util.List" /> <extend-configuration-property name="gdx.reflect.include" value="java.util.ArrayList" /> <extend-configuration-property name="gdx.reflect.include" value="java.util.Map" /> <extend-configuration-property name="gdx.reflect.include" value="java.util.HashMap" /> <extend-configuration-property name="gdx.reflect.include" value="java.lang.String" /> <extend-configuration-property name="gdx.reflect.include" value="java.lang.Boolean" /> <extend-configuration-property name="gdx.reflect.include" value="java.lang.Byte" /> <extend-configuration-property name="gdx.reflect.include" value="java.lang.Short" /> <extend-configuration-property name="gdx.reflect.include" value="java.lang.Character" /> <extend-configuration-property name="gdx.reflect.include" value="java.lang.Integer" /> <extend-configuration-property name="gdx.reflect.include" value="java.lang.Float" /> <extend-configuration-property name="gdx.reflect.include" value="java.lang.Double" /> <extend-configuration-property name="gdx.reflect.include" value="java.lang.CharSequence" /> <extend-configuration-property name="gdx.reflect.include" value="java.lang.Enum" /> <extend-configuration-property name="gdx.reflect.include" value="java.lang.Object" /> <generate-with class="com.badlogic.gwtref.gen.ReflectionCacheGenerator"> <when-type-assignable class="com.badlogic.gwtref.client.IReflectionCache" /> </generate-with> </module>
1
libgdx/libgdx
7,250
chore: Update to gwt 2.10.0
I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
SimonIT
"2023-10-06T10:43:44Z"
"2023-11-12T07:23:11Z"
e688cf718d56048bd9ab3e61180b93ee46f399d7
93503b4120f2c6002c7b1ecc73fc36bef4b678a0
chore: Update to gwt 2.10.0. I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
./backends/gdx-backends-gwt/res/com/google/gwt/webgl/WebGL.gwt.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit trunk//EN" "http://www.gwtproject.org/doctype/2.8.0/gwt-module.dtd"> <module> <inherits name="com.google.gwt.user.User"/> <inherits name="com.google.gwt.canvas.Canvas"/> </module>
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit trunk//EN" "https://www.gwtproject.org/doctype/2.10.0/gwt-module.dtd"> <module> <inherits name="com.google.gwt.user.User"/> <inherits name="com.google.gwt.canvas.Canvas"/> </module>
1
libgdx/libgdx
7,250
chore: Update to gwt 2.10.0
I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
SimonIT
"2023-10-06T10:43:44Z"
"2023-11-12T07:23:11Z"
e688cf718d56048bd9ab3e61180b93ee46f399d7
93503b4120f2c6002c7b1ecc73fc36bef4b678a0
chore: Update to gwt 2.10.0. I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
./extensions/gdx-box2d/gdx-box2d-gwt/res/com/badlogic/gdx/physics/box2d/box2d-gwt.gwt.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit trunk//EN" "http://www.gwtproject.org/doctype/2.8.0/gwt-module.dtd"> <module> <inherits name='com.badlogic.gdx.physics.box2d'/> <source path="gwt"/> <super-source path="gwt/emu" /> </module>
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit trunk//EN" "https://www.gwtproject.org/doctype/2.10.0/gwt-module.dtd"> <module> <inherits name='com.badlogic.gdx.physics.box2d'/> <source path="gwt"/> <super-source path="gwt/emu" /> </module>
1
libgdx/libgdx
7,250
chore: Update to gwt 2.10.0
I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
SimonIT
"2023-10-06T10:43:44Z"
"2023-11-12T07:23:11Z"
e688cf718d56048bd9ab3e61180b93ee46f399d7
93503b4120f2c6002c7b1ecc73fc36bef4b678a0
chore: Update to gwt 2.10.0. I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
./extensions/gdx-box2d/gdx-box2d/res/com/badlogic/gdx/physics/box2d.gwt.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit trunk//EN" "http://www.gwtproject.org/doctype/2.8.0/gwt-module.dtd"> <module> <source path="box2d"> </source> </module>
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit trunk//EN" "https://www.gwtproject.org/doctype/2.10.0/gwt-module.dtd"> <module> <source path="box2d"> </source> </module>
1
libgdx/libgdx
7,250
chore: Update to gwt 2.10.0
I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
SimonIT
"2023-10-06T10:43:44Z"
"2023-11-12T07:23:11Z"
e688cf718d56048bd9ab3e61180b93ee46f399d7
93503b4120f2c6002c7b1ecc73fc36bef4b678a0
chore: Update to gwt 2.10.0. I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
./extensions/gdx-setup/res/com/badlogic/gdx/setup/resources/core/CoreGdxDefinition
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit trunk//EN" "http://www.gwtproject.org/doctype/2.8.0/gwt-module.dtd"> <module> <source path="%PACKAGE_DIR%" /> </module>
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit trunk//EN" "https://www.gwtproject.org/doctype/2.10.0/gwt-module.dtd"> <module> <source path="%PACKAGE_DIR%" /> </module>
1
libgdx/libgdx
7,250
chore: Update to gwt 2.10.0
I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
SimonIT
"2023-10-06T10:43:44Z"
"2023-11-12T07:23:11Z"
e688cf718d56048bd9ab3e61180b93ee46f399d7
93503b4120f2c6002c7b1ecc73fc36bef4b678a0
chore: Update to gwt 2.10.0. I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
./extensions/gdx-setup/res/com/badlogic/gdx/setup/resources/html/GdxDefinition
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit trunk//EN" "http://www.gwtproject.org/doctype/2.8.0/gwt-module.dtd"> <module rename-to="html"> %GWT_INHERITS% <inherits name='%MAIN_CLASS%' /> <entry-point class='%PACKAGE%.client.HtmlLauncher' /> <set-configuration-property name='xsiframe.failIfScriptTag' value='FALSE'/> <set-configuration-property name="gdx.assetpath" value="../%ASSET_PATH%" /> <set-property name="user.agent" value="gecko1_8, safari"/> <collapse-property name="user.agent" values="*" /> </module>
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit trunk//EN" "https://www.gwtproject.org/doctype/2.10.0/gwt-module.dtd"> <module rename-to="html"> %GWT_INHERITS% <inherits name='%MAIN_CLASS%' /> <entry-point class='%PACKAGE%.client.HtmlLauncher' /> <set-configuration-property name='xsiframe.failIfScriptTag' value='FALSE'/> <set-configuration-property name="gdx.assetpath" value="../%ASSET_PATH%" /> <set-property name="user.agent" value="gecko1_8, safari"/> <collapse-property name="user.agent" values="*" /> </module>
1
libgdx/libgdx
7,250
chore: Update to gwt 2.10.0
I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
SimonIT
"2023-10-06T10:43:44Z"
"2023-11-12T07:23:11Z"
e688cf718d56048bd9ab3e61180b93ee46f399d7
93503b4120f2c6002c7b1ecc73fc36bef4b678a0
chore: Update to gwt 2.10.0. I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
./extensions/gdx-setup/res/com/badlogic/gdx/setup/resources/html/GdxDefinitionSuperdev
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit trunk//EN" "http://www.gwtproject.org/doctype/2.8.0/gwt-module.dtd"> <module rename-to="html"> %GWT_INHERITS% <inherits name='%PACKAGE%.GdxDefinition' /> <collapse-all-properties /> <add-linker name="xsiframe"/> <set-configuration-property name="devModeRedirectEnabled" value="true"/> <set-configuration-property name='xsiframe.failIfScriptTag' value='FALSE'/> </module>
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit trunk//EN" "https://www.gwtproject.org/doctype/2.10.0/gwt-module.dtd"> <module rename-to="html"> %GWT_INHERITS% <inherits name='%PACKAGE%.GdxDefinition' /> <collapse-all-properties /> <add-linker name="xsiframe"/> <set-configuration-property name="devModeRedirectEnabled" value="true"/> <set-configuration-property name='xsiframe.failIfScriptTag' value='FALSE'/> </module>
1
libgdx/libgdx
7,250
chore: Update to gwt 2.10.0
I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
SimonIT
"2023-10-06T10:43:44Z"
"2023-11-12T07:23:11Z"
e688cf718d56048bd9ab3e61180b93ee46f399d7
93503b4120f2c6002c7b1ecc73fc36bef4b678a0
chore: Update to gwt 2.10.0. I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
./extensions/gdx-setup/res/com/badlogic/gdx/setup/resources/html/build.gradle
gwt { gwtVersion='%GWT_VERSION%' // Should match the gwt version used for building the gwt backend maxHeapSize="1G" // Default 256m is not enough for gwt compiler. GWT is HUNGRY minHeapSize="1G" src = files(file("src/")) // Needs to be in front of "modules" below. modules '%PACKAGE%.GdxDefinition' devModules '%PACKAGE%.GdxDefinitionSuperdev' project.webAppDirName = 'webapp' compiler { strict = true; disableCastChecking = true; } } import org.wisepersist.gradle.plugins.gwt.GwtSuperDev import org.akhikhl.gretty.AppBeforeIntegrationTestTask gretty.httpPort = 8080 gretty.resourceBase = project.buildDir.path + "/gwt/draftOut" gretty.contextPath = "/" gretty.portPropertiesFileName = "TEMP_PORTS.properties" tasks.register('startHttpServer') { dependsOn draftCompileGwt doFirst { copy { from "webapp" into gretty.resourceBase } copy { from "war" into gretty.resourceBase } } } task beforeRun(type: AppBeforeIntegrationTestTask, dependsOn: startHttpServer) { // The next line allows ports to be reused instead of // needing a process to be manually terminated. file("build/TEMP_PORTS.properties").delete() // Somewhat of a hack; uses Gretty's support for wrapping a task in // a start and then stop of a Jetty server that serves files while // also running the SuperDev code server. integrationTestTask 'superDev' interactive false } tasks.register('superDev', GwtSuperDev) { dependsOn startHttpServer doFirst { gwt.modules = gwt.devModules } } tasks.register('dist') { dependsOn clean, compileGwt doLast { file("build/dist").mkdirs() copy { from "build/gwt/out" into "build/dist" } copy { from "webapp" into "build/dist" } copy { from "war" into "build/dist" } } } tasks.register('addSource') { doLast { sourceSets.main.compileClasspath += files(project(':core').sourceSets.main.allJava.srcDirs) } } tasks.compileGwt.dependsOn(addSource) tasks.draftCompileGwt.dependsOn(addSource) tasks.checkGwt.dependsOn(addSource) checkGwt.war = file("war") sourceCompatibility = 1.7 sourceSets.main.java.srcDirs = [ "src/" ] eclipse.project.name = appName + "-html"
gwt { gwtVersion='%GWT_VERSION%' // Should match the gwt version used for building the gwt backend maxHeapSize="1G" // Default 256m is not enough for gwt compiler. GWT is HUNGRY minHeapSize="1G" src = files(file("src/")) // Needs to be in front of "modules" below. modules '%PACKAGE%.GdxDefinition' devModules '%PACKAGE%.GdxDefinitionSuperdev' project.webAppDirName = 'webapp' compiler { strict = true; disableCastChecking = true; } } import org.docstr.gradle.plugins.gwt.GwtSuperDev import org.akhikhl.gretty.AppBeforeIntegrationTestTask gretty.httpPort = 8080 gretty.resourceBase = project.buildDir.path + "/gwt/draftOut" gretty.contextPath = "/" gretty.portPropertiesFileName = "TEMP_PORTS.properties" tasks.register('startHttpServer') { dependsOn draftCompileGwt doFirst { copy { from "webapp" into gretty.resourceBase } copy { from "war" into gretty.resourceBase } } } task beforeRun(type: AppBeforeIntegrationTestTask, dependsOn: startHttpServer) { // The next line allows ports to be reused instead of // needing a process to be manually terminated. file("build/TEMP_PORTS.properties").delete() // Somewhat of a hack; uses Gretty's support for wrapping a task in // a start and then stop of a Jetty server that serves files while // also running the SuperDev code server. integrationTestTask 'superDev' interactive false } tasks.register('superDev', GwtSuperDev) { dependsOn startHttpServer doFirst { gwt.modules = gwt.devModules } } tasks.register('dist') { dependsOn clean, compileGwt doLast { file("build/dist").mkdirs() copy { from "build/gwt/out" into "build/dist" } copy { from "webapp" into "build/dist" } copy { from "war" into "build/dist" } } } tasks.register('addSource') { doLast { sourceSets.main.compileClasspath += files(project(':core').sourceSets.main.allJava.srcDirs) } } tasks.compileGwt.dependsOn(addSource) tasks.draftCompileGwt.dependsOn(addSource) tasks.checkGwt.dependsOn(addSource) checkGwt.war = file("war") sourceCompatibility = 1.7 sourceSets.main.java.srcDirs = [ "src/" ] eclipse.project.name = appName + "-html"
1
libgdx/libgdx
7,250
chore: Update to gwt 2.10.0
I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
SimonIT
"2023-10-06T10:43:44Z"
"2023-11-12T07:23:11Z"
e688cf718d56048bd9ab3e61180b93ee46f399d7
93503b4120f2c6002c7b1ecc73fc36bef4b678a0
chore: Update to gwt 2.10.0. I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
./extensions/gdx-setup/src/com/badlogic/gdx/setup/DependencyBank.java
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.setup; import java.util.HashMap; public class DependencyBank { // Versions static String libgdxVersion = "1.12.0"; // Temporary snapshot version, we need a more dynamic solution for pointing to the latest nightly static String libgdxNightlyVersion = "1.12.1-SNAPSHOT"; static String roboVMVersion = "2.3.20"; static String buildToolsVersion = "33.0.2"; static String androidAPILevel = "33"; static String androidMinAPILevel = "14"; static String gwtVersion = "2.8.2"; // Repositories static String mavenLocal = "mavenLocal()"; static String mavenCentral = "mavenCentral()"; static String google = "google()"; static String gradlePlugins = "gradlePluginPortal()"; static String libGDXSnapshotsUrl = "https://oss.sonatype.org/content/repositories/snapshots/"; static String libGDXReleaseUrl = "https://oss.sonatype.org/content/repositories/releases/"; static String jitpackUrl = "https://jitpack.io"; // Project plugins static String gwtPluginImport = "org.wisepersist:gwt-gradle-plugin:1.1.16"; static String grettyPluginImport = "org.gretty:gretty:3.0.7"; static String androidPluginImport = "com.android.tools.build:gradle:7.3.1"; static String roboVMPluginImport = "com.mobidevelop.robovm:robovm-gradle-plugin:" + roboVMVersion; // Extension versions static String box2DLightsVersion = "1.5"; static String ashleyVersion = "1.7.4"; static String aiVersion = "1.8.2"; static String controllersVersion = "2.2.1"; HashMap<ProjectDependency, Dependency> gdxDependencies = new HashMap<ProjectDependency, Dependency>(); public DependencyBank () { for (ProjectDependency projectDep : ProjectDependency.values()) { Dependency dependency = new Dependency(projectDep.name(), projectDep.getGwtInherits(), projectDep.getDependencies(ProjectType.CORE), projectDep.getDependencies(ProjectType.LWJGL2), projectDep.getDependencies(ProjectType.LWJGL3), projectDep.getDependencies(ProjectType.ANDROID), projectDep.getDependencies(ProjectType.IOS), projectDep.getDependencies(ProjectType.HTML)); gdxDependencies.put(projectDep, dependency); } } public Dependency getDependency (ProjectDependency gdx) { return gdxDependencies.get(gdx); } /** This enum will hold all dependencies available for libgdx, allowing the setup to pick the ones needed by default, and allow * the option to choose extensions as the user wishes. * <p/> * These dependency strings can be later used in a simple gradle plugin to manipulate the users project either after/before * project generation * * @see Dependency for the object that handles sub-module dependencies. If no dependency is found for a sub-module, ie * FreeTypeFont for gwt, an exception is thrown so the user can be notified of incompatability */ public enum ProjectDependency { GDX(new String[] {"com.badlogicgames.gdx:gdx:$gdxVersion"}, new String[] {"com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion", "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"}, new String[] {"com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion", "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"}, new String[] {"com.badlogicgames.gdx:gdx-backend-android:$gdxVersion", "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a", "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a", "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86", "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"}, new String[] {"com.mobidevelop.robovm:robovm-rt:$roboVMVersion", "com.mobidevelop.robovm:robovm-cocoatouch:$roboVMVersion", "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion", "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"}, new String[] {"com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion", "com.badlogicgames.gdx:gdx:$gdxVersion:sources", "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion:sources"}, new String[] {"com.badlogic.gdx.backends.gdx_backends_gwt"}, "Core Library for libGDX"), BULLET(new String[] {"com.badlogicgames.gdx:gdx-bullet:$gdxVersion"}, new String[] {"com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-desktop"}, new String[] {"com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-desktop"}, new String[] {"com.badlogicgames.gdx:gdx-bullet:$gdxVersion", "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-armeabi-v7a", "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-arm64-v8a", "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-x86", "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-x86_64"}, new String[] {"com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-ios"}, null, null, "3D Collision Detection and Rigid Body Dynamics"), FREETYPE( new String[] {"com.badlogicgames.gdx:gdx-freetype:$gdxVersion"}, new String[] {"com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"}, new String[] {"com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"}, new String[] {"com.badlogicgames.gdx:gdx-freetype:$gdxVersion", "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a", "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a", "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86", "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"}, new String[] {"com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-ios"}, null, null, "Generate BitmapFonts from .ttf font files"), TOOLS(new String[] {}, new String[] {"com.badlogicgames.gdx:gdx-tools:$gdxVersion"}, new String[] {}, new String[] {}, new String[] {}, new String[] {}, new String[] {}, "Collection of tools, including 2D/3D particle editors, texture packers, and file processors"), CONTROLLERS( new String[] {"com.badlogicgames.gdx-controllers:gdx-controllers-core:$gdxControllersVersion"}, new String[] {"com.badlogicgames.gdx-controllers:gdx-controllers-desktop:$gdxControllersVersion"}, new String[] {"com.badlogicgames.gdx-controllers:gdx-controllers-desktop:$gdxControllersVersion"}, new String[] {"com.badlogicgames.gdx-controllers:gdx-controllers-android:$gdxControllersVersion"}, new String[] {"com.badlogicgames.gdx-controllers:gdx-controllers-ios:$gdxControllersVersion"}, new String[] {"com.badlogicgames.gdx-controllers:gdx-controllers-core:$gdxControllersVersion:sources", "com.badlogicgames.gdx-controllers:gdx-controllers-gwt:$gdxControllersVersion", "com.badlogicgames.gdx-controllers:gdx-controllers-gwt:$gdxControllersVersion:sources"}, new String[] {"com.badlogic.gdx.controllers", "com.badlogic.gdx.controllers.controllers-gwt"}, "Game Controller/Gamepad API"), BOX2D(new String[] {"com.badlogicgames.gdx:gdx-box2d:$gdxVersion"}, new String[] {"com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"}, new String[] {"com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"}, new String[] {"com.badlogicgames.gdx:gdx-box2d:$gdxVersion", "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a", "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-arm64-v8a", "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86", "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86_64"}, new String[] {"com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-ios"}, new String[] {"com.badlogicgames.gdx:gdx-box2d:$gdxVersion:sources", "com.badlogicgames.gdx:gdx-box2d-gwt:$gdxVersion:sources"}, new String[] {"com.badlogic.gdx.physics.box2d.box2d-gwt"}, "2D Physics Library"), BOX2DLIGHTS( new String[] {"com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion"}, new String[] {}, new String[] {}, new String[] {"com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion"}, new String[] {}, new String[] {"com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion:sources"}, new String[] {"Box2DLights"}, "2D Lighting framework that utilises Box2D"), ASHLEY( new String[] {"com.badlogicgames.ashley:ashley:$ashleyVersion"}, new String[] {}, new String[] {}, new String[] {"com.badlogicgames.ashley:ashley:$ashleyVersion"}, new String[] {}, new String[] {"com.badlogicgames.ashley:ashley:$ashleyVersion:sources"}, new String[] {"com.badlogic.ashley_gwt"}, "Lightweight Entity framework"), AI(new String[] {"com.badlogicgames.gdx:gdx-ai:$aiVersion"}, new String[] {}, new String[] {}, new String[] {"com.badlogicgames.gdx:gdx-ai:$aiVersion"}, new String[] {}, new String[] {"com.badlogicgames.gdx:gdx-ai:$aiVersion:sources"}, new String[] {"com.badlogic.gdx.ai"}, "Artificial Intelligence framework"); private String[] coreDependencies; private String[] lwjgl2Dependencies; private String[] lwjgl3Dependencies; private String[] androidDependencies; private String[] iosDependencies; private String[] gwtDependencies; private String[] gwtInherits; private String description; ProjectDependency (String[] coreDeps, String[] lwjgl2Deps, String[] lwjgl3Deps, String[] androidDeps, String[] iosDeps, String[] gwtDeps, String[] gwtInhertis, String description) { this.coreDependencies = coreDeps; this.lwjgl2Dependencies = lwjgl2Deps; this.lwjgl3Dependencies = lwjgl3Deps; this.androidDependencies = androidDeps; this.iosDependencies = iosDeps; this.gwtDependencies = gwtDeps; this.gwtInherits = gwtInhertis; this.description = description; } public String[] getDependencies (ProjectType type) { switch (type) { case CORE: return coreDependencies; case LWJGL2: return lwjgl2Dependencies; case LWJGL3: return lwjgl3Dependencies; case ANDROID: return androidDependencies; case IOS: return iosDependencies; case HTML: return gwtDependencies; } return null; } public String[] getGwtInherits () { return gwtInherits; } public String getDescription () { return description; } } public enum ProjectType { CORE("core", "Core"), LWJGL2("legacy_desktop", "Desktop (LWJGL2)"), LWJGL3("desktop", "Desktop (LWJGL 3)"), ANDROID("android", "Android"), IOS("ios", "iOS"), HTML("html", "HTML"); private final String name; private final String displayName; ProjectType (String name, String displayName) { this.name = name; this.displayName = displayName; } public String getName () { return name; } public String getDisplayName () { return displayName; } public String[] getPlugins (Language sourceLanguage) { return sourceLanguage.platformPlugins[ordinal()]; } } }
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.setup; import java.util.HashMap; public class DependencyBank { // Versions static String libgdxVersion = "1.12.0"; // Temporary snapshot version, we need a more dynamic solution for pointing to the latest nightly static String libgdxNightlyVersion = "1.12.1-SNAPSHOT"; static String roboVMVersion = "2.3.20"; static String buildToolsVersion = "33.0.2"; static String androidAPILevel = "33"; static String androidMinAPILevel = "14"; static String gwtVersion = "2.10.0"; // Repositories static String mavenLocal = "mavenLocal()"; static String mavenCentral = "mavenCentral()"; static String google = "google()"; static String gradlePlugins = "gradlePluginPortal()"; static String libGDXSnapshotsUrl = "https://oss.sonatype.org/content/repositories/snapshots/"; static String libGDXReleaseUrl = "https://oss.sonatype.org/content/repositories/releases/"; static String jitpackUrl = "https://jitpack.io"; // Project plugins static String gwtPluginImport = "org.docstr:gwt-gradle-plugin:1.1.29"; static String grettyPluginImport = "org.gretty:gretty:3.0.7"; static String androidPluginImport = "com.android.tools.build:gradle:7.3.1"; static String roboVMPluginImport = "com.mobidevelop.robovm:robovm-gradle-plugin:" + roboVMVersion; // Extension versions static String box2DLightsVersion = "1.5"; static String ashleyVersion = "1.7.4"; static String aiVersion = "1.8.2"; static String controllersVersion = "2.2.1"; HashMap<ProjectDependency, Dependency> gdxDependencies = new HashMap<ProjectDependency, Dependency>(); public DependencyBank () { for (ProjectDependency projectDep : ProjectDependency.values()) { Dependency dependency = new Dependency(projectDep.name(), projectDep.getGwtInherits(), projectDep.getDependencies(ProjectType.CORE), projectDep.getDependencies(ProjectType.LWJGL2), projectDep.getDependencies(ProjectType.LWJGL3), projectDep.getDependencies(ProjectType.ANDROID), projectDep.getDependencies(ProjectType.IOS), projectDep.getDependencies(ProjectType.HTML)); gdxDependencies.put(projectDep, dependency); } } public Dependency getDependency (ProjectDependency gdx) { return gdxDependencies.get(gdx); } /** This enum will hold all dependencies available for libgdx, allowing the setup to pick the ones needed by default, and allow * the option to choose extensions as the user wishes. * <p/> * These dependency strings can be later used in a simple gradle plugin to manipulate the users project either after/before * project generation * * @see Dependency for the object that handles sub-module dependencies. If no dependency is found for a sub-module, ie * FreeTypeFont for gwt, an exception is thrown so the user can be notified of incompatability */ public enum ProjectDependency { GDX(new String[] {"com.badlogicgames.gdx:gdx:$gdxVersion"}, new String[] {"com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion", "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"}, new String[] {"com.badlogicgames.gdx:gdx-backend-lwjgl3:$gdxVersion", "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop"}, new String[] {"com.badlogicgames.gdx:gdx-backend-android:$gdxVersion", "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a", "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-arm64-v8a", "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86", "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86_64"}, new String[] {"com.mobidevelop.robovm:robovm-rt:$roboVMVersion", "com.mobidevelop.robovm:robovm-cocoatouch:$roboVMVersion", "com.badlogicgames.gdx:gdx-backend-robovm:$gdxVersion", "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-ios"}, new String[] {"com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion", "com.badlogicgames.gdx:gdx:$gdxVersion:sources", "com.badlogicgames.gdx:gdx-backend-gwt:$gdxVersion:sources"}, new String[] {"com.badlogic.gdx.backends.gdx_backends_gwt"}, "Core Library for libGDX"), BULLET(new String[] {"com.badlogicgames.gdx:gdx-bullet:$gdxVersion"}, new String[] {"com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-desktop"}, new String[] {"com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-desktop"}, new String[] {"com.badlogicgames.gdx:gdx-bullet:$gdxVersion", "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-armeabi-v7a", "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-arm64-v8a", "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-x86", "com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-x86_64"}, new String[] {"com.badlogicgames.gdx:gdx-bullet-platform:$gdxVersion:natives-ios"}, null, null, "3D Collision Detection and Rigid Body Dynamics"), FREETYPE( new String[] {"com.badlogicgames.gdx:gdx-freetype:$gdxVersion"}, new String[] {"com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"}, new String[] {"com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-desktop"}, new String[] {"com.badlogicgames.gdx:gdx-freetype:$gdxVersion", "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-armeabi-v7a", "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-arm64-v8a", "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86", "com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-x86_64"}, new String[] {"com.badlogicgames.gdx:gdx-freetype-platform:$gdxVersion:natives-ios"}, null, null, "Generate BitmapFonts from .ttf font files"), TOOLS(new String[] {}, new String[] {"com.badlogicgames.gdx:gdx-tools:$gdxVersion"}, new String[] {}, new String[] {}, new String[] {}, new String[] {}, new String[] {}, "Collection of tools, including 2D/3D particle editors, texture packers, and file processors"), CONTROLLERS( new String[] {"com.badlogicgames.gdx-controllers:gdx-controllers-core:$gdxControllersVersion"}, new String[] {"com.badlogicgames.gdx-controllers:gdx-controllers-desktop:$gdxControllersVersion"}, new String[] {"com.badlogicgames.gdx-controllers:gdx-controllers-desktop:$gdxControllersVersion"}, new String[] {"com.badlogicgames.gdx-controllers:gdx-controllers-android:$gdxControllersVersion"}, new String[] {"com.badlogicgames.gdx-controllers:gdx-controllers-ios:$gdxControllersVersion"}, new String[] {"com.badlogicgames.gdx-controllers:gdx-controllers-core:$gdxControllersVersion:sources", "com.badlogicgames.gdx-controllers:gdx-controllers-gwt:$gdxControllersVersion", "com.badlogicgames.gdx-controllers:gdx-controllers-gwt:$gdxControllersVersion:sources"}, new String[] {"com.badlogic.gdx.controllers", "com.badlogic.gdx.controllers.controllers-gwt"}, "Game Controller/Gamepad API"), BOX2D(new String[] {"com.badlogicgames.gdx:gdx-box2d:$gdxVersion"}, new String[] {"com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"}, new String[] {"com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-desktop"}, new String[] {"com.badlogicgames.gdx:gdx-box2d:$gdxVersion", "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-armeabi-v7a", "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-arm64-v8a", "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86", "com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-x86_64"}, new String[] {"com.badlogicgames.gdx:gdx-box2d-platform:$gdxVersion:natives-ios"}, new String[] {"com.badlogicgames.gdx:gdx-box2d:$gdxVersion:sources", "com.badlogicgames.gdx:gdx-box2d-gwt:$gdxVersion:sources"}, new String[] {"com.badlogic.gdx.physics.box2d.box2d-gwt"}, "2D Physics Library"), BOX2DLIGHTS( new String[] {"com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion"}, new String[] {}, new String[] {}, new String[] {"com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion"}, new String[] {}, new String[] {"com.badlogicgames.box2dlights:box2dlights:$box2DLightsVersion:sources"}, new String[] {"Box2DLights"}, "2D Lighting framework that utilises Box2D"), ASHLEY( new String[] {"com.badlogicgames.ashley:ashley:$ashleyVersion"}, new String[] {}, new String[] {}, new String[] {"com.badlogicgames.ashley:ashley:$ashleyVersion"}, new String[] {}, new String[] {"com.badlogicgames.ashley:ashley:$ashleyVersion:sources"}, new String[] {"com.badlogic.ashley_gwt"}, "Lightweight Entity framework"), AI(new String[] {"com.badlogicgames.gdx:gdx-ai:$aiVersion"}, new String[] {}, new String[] {}, new String[] {"com.badlogicgames.gdx:gdx-ai:$aiVersion"}, new String[] {}, new String[] {"com.badlogicgames.gdx:gdx-ai:$aiVersion:sources"}, new String[] {"com.badlogic.gdx.ai"}, "Artificial Intelligence framework"); private String[] coreDependencies; private String[] lwjgl2Dependencies; private String[] lwjgl3Dependencies; private String[] androidDependencies; private String[] iosDependencies; private String[] gwtDependencies; private String[] gwtInherits; private String description; ProjectDependency (String[] coreDeps, String[] lwjgl2Deps, String[] lwjgl3Deps, String[] androidDeps, String[] iosDeps, String[] gwtDeps, String[] gwtInhertis, String description) { this.coreDependencies = coreDeps; this.lwjgl2Dependencies = lwjgl2Deps; this.lwjgl3Dependencies = lwjgl3Deps; this.androidDependencies = androidDeps; this.iosDependencies = iosDeps; this.gwtDependencies = gwtDeps; this.gwtInherits = gwtInhertis; this.description = description; } public String[] getDependencies (ProjectType type) { switch (type) { case CORE: return coreDependencies; case LWJGL2: return lwjgl2Dependencies; case LWJGL3: return lwjgl3Dependencies; case ANDROID: return androidDependencies; case IOS: return iosDependencies; case HTML: return gwtDependencies; } return null; } public String[] getGwtInherits () { return gwtInherits; } public String getDescription () { return description; } } public enum ProjectType { CORE("core", "Core"), LWJGL2("legacy_desktop", "Desktop (LWJGL2)"), LWJGL3("desktop", "Desktop (LWJGL 3)"), ANDROID("android", "Android"), IOS("ios", "iOS"), HTML("html", "HTML"); private final String name; private final String displayName; ProjectType (String name, String displayName) { this.name = name; this.displayName = displayName; } public String getName () { return name; } public String getDisplayName () { return displayName; } public String[] getPlugins (Language sourceLanguage) { return sourceLanguage.platformPlugins[ordinal()]; } } }
1
libgdx/libgdx
7,250
chore: Update to gwt 2.10.0
I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
SimonIT
"2023-10-06T10:43:44Z"
"2023-11-12T07:23:11Z"
e688cf718d56048bd9ab3e61180b93ee46f399d7
93503b4120f2c6002c7b1ecc73fc36bef4b678a0
chore: Update to gwt 2.10.0. I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
./gradle/dependencies.gradle
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ ext { versions = [:] libraries = [:] testnatives = [:] gdxnatives = [:] } versions.java = project.hasProperty("javaVersion") ? Integer.parseInt(project.getProperty("javaVersion")) : 7 versions.javaLwjgl3 = project.hasProperty("javaVersion") ? Integer.parseInt(project.getProperty("javaVersion")) : 8 versions.robovm = "2.3.20" versions.gwt = "2.8.2" versions.gwtPlugin = "1.1.16" versions.gretty = "3.0.7" versions.jglwf = "1.1" versions.lwjgl = "2.9.3" versions.lwjgl3 = "3.3.3" versions.jlayer = "1.0.1-gdx" versions.jorbis = "0.0.17" versions.junit = "4.13.2" versions.androidPlugin = "7.3.1" versions.multiDex = "2.0.1" versions.androidCompileSdk = 33 versions.androidTargetSdk = 33 versions.androidMinSdk = 14 versions.androidBuildTools = "33.0.2" versions.androidFragment = "1.5.7" versions.javaparser = "2.3.0" versions.spotless = "6.7.1" libraries.compileOnly = [:] libraries.lwjgl = [ "org.lwjgl.lwjgl:lwjgl:${versions.lwjgl}", "com.badlogicgames.jlayer:jlayer:${versions.jlayer}", "org.jcraft:jorbis:${versions.jorbis}" ] libraries.lwjgl3 = [ "org.lwjgl:lwjgl:${versions.lwjgl3}", "org.lwjgl:lwjgl:${versions.lwjgl3}:natives-linux", "org.lwjgl:lwjgl:${versions.lwjgl3}:natives-linux-arm32", "org.lwjgl:lwjgl:${versions.lwjgl3}:natives-linux-arm64", "org.lwjgl:lwjgl:${versions.lwjgl3}:natives-macos", "org.lwjgl:lwjgl:${versions.lwjgl3}:natives-macos-arm64", "org.lwjgl:lwjgl:${versions.lwjgl3}:natives-windows", "org.lwjgl:lwjgl:${versions.lwjgl3}:natives-windows-x86", "org.lwjgl:lwjgl-glfw:${versions.lwjgl3}", "org.lwjgl:lwjgl-glfw:${versions.lwjgl3}:natives-linux", "org.lwjgl:lwjgl-glfw:${versions.lwjgl3}:natives-linux-arm32", "org.lwjgl:lwjgl-glfw:${versions.lwjgl3}:natives-linux-arm64", "org.lwjgl:lwjgl-glfw:${versions.lwjgl3}:natives-macos", "org.lwjgl:lwjgl-glfw:${versions.lwjgl3}:natives-macos-arm64", "org.lwjgl:lwjgl-glfw:${versions.lwjgl3}:natives-windows", "org.lwjgl:lwjgl-glfw:${versions.lwjgl3}:natives-windows-x86", "org.lwjgl:lwjgl-jemalloc:${versions.lwjgl3}", "org.lwjgl:lwjgl-jemalloc:${versions.lwjgl3}:natives-linux", "org.lwjgl:lwjgl-jemalloc:${versions.lwjgl3}:natives-linux-arm32", "org.lwjgl:lwjgl-jemalloc:${versions.lwjgl3}:natives-linux-arm64", "org.lwjgl:lwjgl-jemalloc:${versions.lwjgl3}:natives-macos", "org.lwjgl:lwjgl-jemalloc:${versions.lwjgl3}:natives-macos-arm64", "org.lwjgl:lwjgl-jemalloc:${versions.lwjgl3}:natives-windows", "org.lwjgl:lwjgl-jemalloc:${versions.lwjgl3}:natives-windows-x86", "org.lwjgl:lwjgl-openal:${versions.lwjgl3}", "org.lwjgl:lwjgl-openal:${versions.lwjgl3}:natives-linux", "org.lwjgl:lwjgl-openal:${versions.lwjgl3}:natives-linux-arm32", "org.lwjgl:lwjgl-openal:${versions.lwjgl3}:natives-linux-arm64", "org.lwjgl:lwjgl-openal:${versions.lwjgl3}:natives-macos", "org.lwjgl:lwjgl-openal:${versions.lwjgl3}:natives-macos-arm64", "org.lwjgl:lwjgl-openal:${versions.lwjgl3}:natives-windows", "org.lwjgl:lwjgl-openal:${versions.lwjgl3}:natives-windows-x86", "org.lwjgl:lwjgl-opengl:${versions.lwjgl3}", "org.lwjgl:lwjgl-opengl:${versions.lwjgl3}:natives-linux", "org.lwjgl:lwjgl-opengl:${versions.lwjgl3}:natives-linux-arm32", "org.lwjgl:lwjgl-opengl:${versions.lwjgl3}:natives-linux-arm64", "org.lwjgl:lwjgl-opengl:${versions.lwjgl3}:natives-macos", "org.lwjgl:lwjgl-opengl:${versions.lwjgl3}:natives-macos-arm64", "org.lwjgl:lwjgl-opengl:${versions.lwjgl3}:natives-windows", "org.lwjgl:lwjgl-opengl:${versions.lwjgl3}:natives-windows-x86", "org.lwjgl:lwjgl-stb:${versions.lwjgl3}", "org.lwjgl:lwjgl-stb:${versions.lwjgl3}:natives-linux", "org.lwjgl:lwjgl-stb:${versions.lwjgl3}:natives-linux-arm32", "org.lwjgl:lwjgl-stb:${versions.lwjgl3}:natives-linux-arm64", "org.lwjgl:lwjgl-stb:${versions.lwjgl3}:natives-macos", "org.lwjgl:lwjgl-stb:${versions.lwjgl3}:natives-macos-arm64", "org.lwjgl:lwjgl-stb:${versions.lwjgl3}:natives-windows", "org.lwjgl:lwjgl-stb:${versions.lwjgl3}:natives-windows-x86", "com.badlogicgames.jlayer:jlayer:${versions.jlayer}", "org.jcraft:jorbis:${versions.jorbis}" ] libraries.lwjgl3GLES = [ "org.lwjgl:lwjgl-opengles:${versions.lwjgl3}", "org.lwjgl:lwjgl-opengles:${versions.lwjgl3}:natives-linux", "org.lwjgl:lwjgl-opengles:${versions.lwjgl3}:natives-linux-arm32", "org.lwjgl:lwjgl-opengles:${versions.lwjgl3}:natives-linux-arm64", "org.lwjgl:lwjgl-opengles:${versions.lwjgl3}:natives-macos", "org.lwjgl:lwjgl-opengles:${versions.lwjgl3}:natives-macos-arm64", "org.lwjgl:lwjgl-opengles:${versions.lwjgl3}:natives-windows", "org.lwjgl:lwjgl-opengles:${versions.lwjgl3}:natives-windows-x86", "org.lwjgl:lwjgl-egl:${versions.lwjgl3}", ] libraries.robovm = [ "com.mobidevelop.robovm:robovm-rt:${versions.robovm}", "com.mobidevelop.robovm:robovm-objc:${versions.robovm}", "com.mobidevelop.robovm:robovm-cocoatouch:${versions.robovm}" ] libraries.compileOnly.android = [ "androidx.fragment:fragment:${versions.androidFragment}" ] libraries.gwt = [ "com.google.gwt:gwt-user:${versions.gwt}" ] libraries.compileOnly.gwt = [ "com.google.gwt:gwt-dev:${versions.gwt}" ] libraries.junit = [ "junit:junit:${versions.junit}" ] testnatives.desktop = [ files("gdx/libs/gdx-natives.jar"), files("extensions/gdx-box2d/gdx-box2d/libs/gdx-box2d-natives.jar"), files("extensions/gdx-bullet/libs/gdx-bullet-natives.jar"), files("extensions/gdx-freetype/libs/gdx-freetype-natives.jar") ] gdxnatives.desktop = [ files("gdx/libs/gdx-natives.jar") ]
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ ext { versions = [:] libraries = [:] testnatives = [:] gdxnatives = [:] } versions.java = project.hasProperty("javaVersion") ? Integer.parseInt(project.getProperty("javaVersion")) : 7 versions.javaLwjgl3 = project.hasProperty("javaVersion") ? Integer.parseInt(project.getProperty("javaVersion")) : 8 versions.robovm = "2.3.20" versions.gwt = "2.10.0" versions.gwtPlugin = "1.1.29" versions.jsinteropAnnotations = "2.0.2" versions.gretty = "3.0.7" versions.jglwf = "1.1" versions.lwjgl = "2.9.3" versions.lwjgl3 = "3.3.3" versions.jlayer = "1.0.1-gdx" versions.jorbis = "0.0.17" versions.junit = "4.13.2" versions.androidPlugin = "7.3.1" versions.multiDex = "2.0.1" versions.androidCompileSdk = 33 versions.androidTargetSdk = 33 versions.androidMinSdk = 14 versions.androidBuildTools = "33.0.2" versions.androidFragment = "1.5.7" versions.javaparser = "2.3.0" versions.spotless = "6.7.1" libraries.compileOnly = [:] libraries.lwjgl = [ "org.lwjgl.lwjgl:lwjgl:${versions.lwjgl}", "com.badlogicgames.jlayer:jlayer:${versions.jlayer}", "org.jcraft:jorbis:${versions.jorbis}" ] libraries.lwjgl3 = [ "org.lwjgl:lwjgl:${versions.lwjgl3}", "org.lwjgl:lwjgl:${versions.lwjgl3}:natives-linux", "org.lwjgl:lwjgl:${versions.lwjgl3}:natives-linux-arm32", "org.lwjgl:lwjgl:${versions.lwjgl3}:natives-linux-arm64", "org.lwjgl:lwjgl:${versions.lwjgl3}:natives-macos", "org.lwjgl:lwjgl:${versions.lwjgl3}:natives-macos-arm64", "org.lwjgl:lwjgl:${versions.lwjgl3}:natives-windows", "org.lwjgl:lwjgl:${versions.lwjgl3}:natives-windows-x86", "org.lwjgl:lwjgl-glfw:${versions.lwjgl3}", "org.lwjgl:lwjgl-glfw:${versions.lwjgl3}:natives-linux", "org.lwjgl:lwjgl-glfw:${versions.lwjgl3}:natives-linux-arm32", "org.lwjgl:lwjgl-glfw:${versions.lwjgl3}:natives-linux-arm64", "org.lwjgl:lwjgl-glfw:${versions.lwjgl3}:natives-macos", "org.lwjgl:lwjgl-glfw:${versions.lwjgl3}:natives-macos-arm64", "org.lwjgl:lwjgl-glfw:${versions.lwjgl3}:natives-windows", "org.lwjgl:lwjgl-glfw:${versions.lwjgl3}:natives-windows-x86", "org.lwjgl:lwjgl-jemalloc:${versions.lwjgl3}", "org.lwjgl:lwjgl-jemalloc:${versions.lwjgl3}:natives-linux", "org.lwjgl:lwjgl-jemalloc:${versions.lwjgl3}:natives-linux-arm32", "org.lwjgl:lwjgl-jemalloc:${versions.lwjgl3}:natives-linux-arm64", "org.lwjgl:lwjgl-jemalloc:${versions.lwjgl3}:natives-macos", "org.lwjgl:lwjgl-jemalloc:${versions.lwjgl3}:natives-macos-arm64", "org.lwjgl:lwjgl-jemalloc:${versions.lwjgl3}:natives-windows", "org.lwjgl:lwjgl-jemalloc:${versions.lwjgl3}:natives-windows-x86", "org.lwjgl:lwjgl-openal:${versions.lwjgl3}", "org.lwjgl:lwjgl-openal:${versions.lwjgl3}:natives-linux", "org.lwjgl:lwjgl-openal:${versions.lwjgl3}:natives-linux-arm32", "org.lwjgl:lwjgl-openal:${versions.lwjgl3}:natives-linux-arm64", "org.lwjgl:lwjgl-openal:${versions.lwjgl3}:natives-macos", "org.lwjgl:lwjgl-openal:${versions.lwjgl3}:natives-macos-arm64", "org.lwjgl:lwjgl-openal:${versions.lwjgl3}:natives-windows", "org.lwjgl:lwjgl-openal:${versions.lwjgl3}:natives-windows-x86", "org.lwjgl:lwjgl-opengl:${versions.lwjgl3}", "org.lwjgl:lwjgl-opengl:${versions.lwjgl3}:natives-linux", "org.lwjgl:lwjgl-opengl:${versions.lwjgl3}:natives-linux-arm32", "org.lwjgl:lwjgl-opengl:${versions.lwjgl3}:natives-linux-arm64", "org.lwjgl:lwjgl-opengl:${versions.lwjgl3}:natives-macos", "org.lwjgl:lwjgl-opengl:${versions.lwjgl3}:natives-macos-arm64", "org.lwjgl:lwjgl-opengl:${versions.lwjgl3}:natives-windows", "org.lwjgl:lwjgl-opengl:${versions.lwjgl3}:natives-windows-x86", "org.lwjgl:lwjgl-stb:${versions.lwjgl3}", "org.lwjgl:lwjgl-stb:${versions.lwjgl3}:natives-linux", "org.lwjgl:lwjgl-stb:${versions.lwjgl3}:natives-linux-arm32", "org.lwjgl:lwjgl-stb:${versions.lwjgl3}:natives-linux-arm64", "org.lwjgl:lwjgl-stb:${versions.lwjgl3}:natives-macos", "org.lwjgl:lwjgl-stb:${versions.lwjgl3}:natives-macos-arm64", "org.lwjgl:lwjgl-stb:${versions.lwjgl3}:natives-windows", "org.lwjgl:lwjgl-stb:${versions.lwjgl3}:natives-windows-x86", "com.badlogicgames.jlayer:jlayer:${versions.jlayer}", "org.jcraft:jorbis:${versions.jorbis}" ] libraries.lwjgl3GLES = [ "org.lwjgl:lwjgl-opengles:${versions.lwjgl3}", "org.lwjgl:lwjgl-opengles:${versions.lwjgl3}:natives-linux", "org.lwjgl:lwjgl-opengles:${versions.lwjgl3}:natives-linux-arm32", "org.lwjgl:lwjgl-opengles:${versions.lwjgl3}:natives-linux-arm64", "org.lwjgl:lwjgl-opengles:${versions.lwjgl3}:natives-macos", "org.lwjgl:lwjgl-opengles:${versions.lwjgl3}:natives-macos-arm64", "org.lwjgl:lwjgl-opengles:${versions.lwjgl3}:natives-windows", "org.lwjgl:lwjgl-opengles:${versions.lwjgl3}:natives-windows-x86", "org.lwjgl:lwjgl-egl:${versions.lwjgl3}", ] libraries.robovm = [ "com.mobidevelop.robovm:robovm-rt:${versions.robovm}", "com.mobidevelop.robovm:robovm-objc:${versions.robovm}", "com.mobidevelop.robovm:robovm-cocoatouch:${versions.robovm}" ] libraries.compileOnly.android = [ "androidx.fragment:fragment:${versions.androidFragment}" ] libraries.gwt = [ "com.google.gwt:gwt-user:${versions.gwt}", "com.google.jsinterop:jsinterop-annotations:${versions.jsinteropAnnotations}:sources" ] libraries.compileOnly.gwt = [ "com.google.gwt:gwt-dev:${versions.gwt}" ] libraries.junit = [ "junit:junit:${versions.junit}" ] testnatives.desktop = [ files("gdx/libs/gdx-natives.jar"), files("extensions/gdx-box2d/gdx-box2d/libs/gdx-box2d-natives.jar"), files("extensions/gdx-bullet/libs/gdx-bullet-natives.jar"), files("extensions/gdx-freetype/libs/gdx-freetype-natives.jar") ] gdxnatives.desktop = [ files("gdx/libs/gdx-natives.jar") ]
1
libgdx/libgdx
7,250
chore: Update to gwt 2.10.0
I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
SimonIT
"2023-10-06T10:43:44Z"
"2023-11-12T07:23:11Z"
e688cf718d56048bd9ab3e61180b93ee46f399d7
93503b4120f2c6002c7b1ecc73fc36bef4b678a0
chore: Update to gwt 2.10.0. I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
./tests/gdx-tests-gwt/build.gradle
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ buildscript { dependencies { classpath "org.wisepersist:gwt-gradle-plugin:${versions.gwtPlugin}" classpath "org.gretty:gretty:${versions.gretty}" } } configurations.all { // gwt-dev pulls in apache-jsp (Tomcat), but we don't need it and it messes with gretty exclude group: 'org.eclipse.jetty', module: 'apache-jsp' } apply plugin: 'gwt' apply plugin: 'war' apply plugin: 'org.gretty' import org.wisepersist.gradle.plugins.gwt.GwtSuperDev import org.akhikhl.gretty.AppBeforeIntegrationTestTask gretty.httpPort = 8080 gretty.resourceBase = project.buildDir.path + "/gwt/draftOut" gretty.contextPath = "/" gretty.portPropertiesFileName = "TEMP_PORTS.properties" dependencies { implementation project(":tests:gdx-tests") implementation project(":backends:gdx-backend-gwt") implementation project(":extensions:gdx-box2d-parent:gdx-box2d-gwt") compileOnly "com.google.gwt:gwt-dev:${versions.gwt}" } gwt { gwtVersion='2.8.2' // Should match the gwt version used for building the gwt backend maxHeapSize="1G" // Default 256m is not enough for gwt compiler. GWT is HUNGRY minHeapSize="1G" src = files(file("src/")) // Needs to be in front of "modules" below. modules 'com.badlogic.gdx.tests.gwt.GdxTestsGwt' devModules 'com.badlogic.gdx.tests.gwt.GdxTestsGwt' compiler.strict = true compiler.disableCastChecking = true } task startHttpServer () { dependsOn draftCompileGwt doFirst { copy { from "webapp" into gretty.resourceBase } copy { from "war" into gretty.resourceBase } } } task beforeRun(type: AppBeforeIntegrationTestTask, dependsOn: startHttpServer) { // The next line allows ports to be reused instead of // needing a process to be manually terminated. file("build/TEMP_PORTS.properties").delete() // Somewhat of a hack; uses Gretty's support for wrapping a task in // a start and then stop of a Jetty server that serves files while // also running the SuperDev code server. integrationTestTask 'superDev' interactive false } task superDev (type: GwtSuperDev) { dependsOn startHttpServer doFirst { gwt.modules = gwt.devModules } } task dist(dependsOn: [clean, compileGwt]) { doLast { file("build/dist").mkdirs() copy { from "build/gwt/out" into "build/dist" } copy { from "webapp" into "build/dist" } copy { from "war" into "build/dist" } } } task addSource { doLast { sourceSets.main.compileClasspath += files(project(':tests:gdx-tests').sourceSets.main.allJava.srcDirs) sourceSets.main.compileClasspath += files(project(':tests:gdx-tests').sourceSets.main.resources.srcDirs) sourceSets.main.compileClasspath += files(project(':backends:gdx-backend-gwt').sourceSets.main.allJava.srcDirs) sourceSets.main.compileClasspath += files(project(':backends:gdx-backend-gwt').sourceSets.main.resources.srcDirs) sourceSets.main.compileClasspath += files(project(':extensions:gdx-box2d-parent:gdx-box2d').sourceSets.main.resources.srcDirs) sourceSets.main.compileClasspath += files(project(':extensions:gdx-box2d-parent:gdx-box2d-gwt').sourceSets.main.allJava.srcDirs) sourceSets.main.compileClasspath += files(project(':extensions:gdx-box2d-parent:gdx-box2d-gwt').sourceSets.main.resources.srcDirs) sourceSets.main.compileClasspath += files(project(':gdx').sourceSets.main.allJava.srcDirs) sourceSets.main.compileClasspath += files(project(':gdx').sourceSets.main.resources.srcDirs) sourceSets.main.compileClasspath += files(sourceSets.main.resources.srcDirs) } } tasks.compileGwt.dependsOn(addSource) tasks.draftCompileGwt.dependsOn(addSource) eclipse { classpath { containers += [ 'com.google.gwt.eclipse.core.GWT_CONTAINER', 'com.gwtplugins.gwt.eclipse.core.GWT_CONTAINER' ] } }
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ buildscript { dependencies { classpath "org.docstr:gwt-gradle-plugin:${versions.gwtPlugin}" classpath "org.gretty:gretty:${versions.gretty}" } } configurations.all { // gwt-dev pulls in apache-jsp (Tomcat), but we don't need it and it messes with gretty exclude group: 'org.eclipse.jetty', module: 'apache-jsp' } apply plugin: 'gwt' apply plugin: 'war' apply plugin: 'org.gretty' import org.docstr.gradle.plugins.gwt.GwtSuperDev import org.akhikhl.gretty.AppBeforeIntegrationTestTask gretty.httpPort = 8080 gretty.resourceBase = project.buildDir.path + "/gwt/draftOut" gretty.contextPath = "/" gretty.portPropertiesFileName = "TEMP_PORTS.properties" dependencies { implementation project(":tests:gdx-tests") implementation project(":backends:gdx-backend-gwt") implementation project(":extensions:gdx-box2d-parent:gdx-box2d-gwt") compileOnly "com.google.gwt:gwt-dev:${versions.gwt}" } gwt { gwtVersion='2.10.0' // Should match the gwt version used for building the gwt backend maxHeapSize="1G" // Default 256m is not enough for gwt compiler. GWT is HUNGRY minHeapSize="1G" src = files(file("src/")) // Needs to be in front of "modules" below. modules 'com.badlogic.gdx.tests.gwt.GdxTestsGwt' devModules 'com.badlogic.gdx.tests.gwt.GdxTestsGwt' compiler.strict = true compiler.disableCastChecking = true } task startHttpServer () { dependsOn draftCompileGwt doFirst { copy { from "webapp" into gretty.resourceBase } copy { from "war" into gretty.resourceBase } } } task beforeRun(type: AppBeforeIntegrationTestTask, dependsOn: startHttpServer) { // The next line allows ports to be reused instead of // needing a process to be manually terminated. file("build/TEMP_PORTS.properties").delete() // Somewhat of a hack; uses Gretty's support for wrapping a task in // a start and then stop of a Jetty server that serves files while // also running the SuperDev code server. integrationTestTask 'superDev' interactive false } task superDev (type: GwtSuperDev) { dependsOn startHttpServer doFirst { gwt.modules = gwt.devModules } } task dist(dependsOn: [clean, compileGwt]) { doLast { file("build/dist").mkdirs() copy { from "build/gwt/out" into "build/dist" } copy { from "webapp" into "build/dist" } copy { from "war" into "build/dist" } } } task addSource { doLast { sourceSets.main.compileClasspath += files(project(':tests:gdx-tests').sourceSets.main.allJava.srcDirs) sourceSets.main.compileClasspath += files(project(':tests:gdx-tests').sourceSets.main.resources.srcDirs) sourceSets.main.compileClasspath += files(project(':backends:gdx-backend-gwt').sourceSets.main.allJava.srcDirs) sourceSets.main.compileClasspath += files(project(':backends:gdx-backend-gwt').sourceSets.main.resources.srcDirs) sourceSets.main.compileClasspath += files(project(':extensions:gdx-box2d-parent:gdx-box2d').sourceSets.main.resources.srcDirs) sourceSets.main.compileClasspath += files(project(':extensions:gdx-box2d-parent:gdx-box2d-gwt').sourceSets.main.allJava.srcDirs) sourceSets.main.compileClasspath += files(project(':extensions:gdx-box2d-parent:gdx-box2d-gwt').sourceSets.main.resources.srcDirs) sourceSets.main.compileClasspath += files(project(':gdx').sourceSets.main.allJava.srcDirs) sourceSets.main.compileClasspath += files(project(':gdx').sourceSets.main.resources.srcDirs) sourceSets.main.compileClasspath += files(sourceSets.main.resources.srcDirs) } } tasks.compileGwt.dependsOn(addSource) tasks.draftCompileGwt.dependsOn(addSource) eclipse { classpath { containers += [ 'com.google.gwt.eclipse.core.GWT_CONTAINER', 'com.gwtplugins.gwt.eclipse.core.GWT_CONTAINER' ] } }
1
libgdx/libgdx
7,250
chore: Update to gwt 2.10.0
I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
SimonIT
"2023-10-06T10:43:44Z"
"2023-11-12T07:23:11Z"
e688cf718d56048bd9ab3e61180b93ee46f399d7
93503b4120f2c6002c7b1ecc73fc36bef4b678a0
chore: Update to gwt 2.10.0. I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
./tests/gdx-tests-gwt/res/com/badlogic/gdx/tests/gwt/GdxTestsGwt.gwt.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit trunk//EN" "http://www.gwtproject.org/doctype/2.8.0/gwt-module.dtd"> <module> <inherits name='com.badlogic.gdx.backends.gdx_backends_gwt' /> <inherits name='com.badlogic.gdx.GdxTests' /> <inherits name="com.badlogic.gdx.physics.box2d.box2d-gwt"/> <set-configuration-property name="gdx.assetpath" value="../gdx-tests-android/assets"/> <set-configuration-property name='xsiframe.failIfScriptTag' value='FALSE'/> <entry-point class='com.badlogic.gdx.tests.gwt.client.GwtTestStarter' /> <set-configuration-property name="gdx.assetfilterclass" value="com.badlogic.gdx.tests.gwt.client.GwtTestAssetFilter"/> </module>
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit trunk//EN" "https://www.gwtproject.org/doctype/2.10.0/gwt-module.dtd"> <module> <inherits name='com.badlogic.gdx.backends.gdx_backends_gwt' /> <inherits name='com.badlogic.gdx.GdxTests' /> <inherits name="com.badlogic.gdx.physics.box2d.box2d-gwt"/> <set-configuration-property name="gdx.assetpath" value="../gdx-tests-android/assets"/> <set-configuration-property name='xsiframe.failIfScriptTag' value='FALSE'/> <entry-point class='com.badlogic.gdx.tests.gwt.client.GwtTestStarter' /> <set-configuration-property name="gdx.assetfilterclass" value="com.badlogic.gdx.tests.gwt.client.GwtTestAssetFilter"/> </module>
1
libgdx/libgdx
7,250
chore: Update to gwt 2.10.0
I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
SimonIT
"2023-10-06T10:43:44Z"
"2023-11-12T07:23:11Z"
e688cf718d56048bd9ab3e61180b93ee46f399d7
93503b4120f2c6002c7b1ecc73fc36bef4b678a0
chore: Update to gwt 2.10.0. I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
./tests/gdx-tests/res/com/badlogic/gdx/GdxTests.gwt.xml
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit trunk//EN" "http://www.gwtproject.org/doctype/2.8.0/gwt-module.dtd"> <module> <source path="tests"> <exclude name="**/AssetsFileGenerator.java"/> <!-- utility --> <exclude name="**/AudioDeviceTest.java"/> <!-- audio missing --> <exclude name="**/AudioRecorderTest.java"/> <!-- audio missing --> <exclude name="**/BitmapFontWriterTest.java"/> <!-- gdx-tools --> <exclude name="**/BobTest.java"/> <!-- GL ES 1.0 --> <exclude name="**/bullet/"/> <!-- native --> <exclude name="**/BulletTestCollection.java"/> <!-- native --> <exclude name="**/ContactListenerTest.java"/> <!-- String.format, Reflection --> <exclude name="**/CullTest.java"/> <!-- GL ES 1.0 --> <exclude name="**/KTXTest.java"/> <!-- use ECT1 which is native --> <exclude name="**/ETC1Test.java"/> <!-- native --> <exclude name="**/FFTTest.java"/> <!-- native --> <exclude name="**/FreeType*.java"/> <!-- native --> <exclude name="**/Gdx2DTest.java"/> <!-- native --> <exclude name="**/GdxTests.java"/> <!-- utility --> <exclude name="**/HeightField.java"/> <!-- Incompatible type due to emulation --> <exclude name="**/HeightMapTest.java"/> <!-- Incompatible type due to emulation --> <exclude name="**/I18NMessageTest.java"/> <!-- MessageBundle --> <exclude name="**/InternationalFontsTest.java"/> <!-- utility --> <exclude name="**/JpegTest.java"/> <!-- native --> <exclude name="**/JsonReaderTest.java"/> <!-- uses ArrayList --> <exclude name="**/Mpg123Test.java"/> <!-- native --> <exclude name="**/NetAPITest.java"/> <!-- abuses FileHandle() --> <exclude name="**/NoncontinuousRenderingTest.java"/> <!-- Noncontinuous rendering not supported --> <exclude name="**/PingPongSocketExample.java"/> <!-- networking --> <exclude name="**/PixelBufferObjectTest.java"/> <!-- threading --> <exclude name="**/PixmapPackerIOTest.java"/> <!-- gdx-tools --> <exclude name="**/PngTest.java"/> <!-- Not compatible --> <exclude name="**/RemoteTest.java"/> <!-- networking --> <exclude name="**/SelectTest.java"/> <!-- String.format --> <exclude name="**/SensorTest.java"/> <!-- Tests device accelerometer, compass, gyro --> <exclude name="**/SoundTouchTest.java"/> <!-- native --> <exclude name="**/StbTrueTypeTest.java"/> <!-- native --> <exclude name="**/TextureDownloadTest.java"/> <!-- http utils missing --> <exclude name="**/TTFFactoryTest.java"/> <!-- native --> <exclude name="**/VBOWithVAOPerformanceTest.java"/> <!-- GLES 3.0, Emulation issues --> <exclude name="**/VorbisTest.java"/> <!-- native --> <exclude name="**/WavTest.java"/> <!-- naive --> <exclude name="**/voxel/*.java"/> <!-- PerlinNoiseGenerator uses a method not in the emulated version of Buffer --> <exclude name="utils/CommandLineOptions.java"/> </source> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.tests.AnnotationTest" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.tests.ReflectionCorrectnessTest" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.tests.utils.GdxTestConfig" /> </module>
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit trunk//EN" "https://www.gwtproject.org/doctype/2.10.0/gwt-module.dtd"> <module> <source path="tests"> <exclude name="**/AssetsFileGenerator.java"/> <!-- utility --> <exclude name="**/AudioDeviceTest.java"/> <!-- audio missing --> <exclude name="**/AudioRecorderTest.java"/> <!-- audio missing --> <exclude name="**/BitmapFontWriterTest.java"/> <!-- gdx-tools --> <exclude name="**/BobTest.java"/> <!-- GL ES 1.0 --> <exclude name="**/bullet/"/> <!-- native --> <exclude name="**/BulletTestCollection.java"/> <!-- native --> <exclude name="**/ContactListenerTest.java"/> <!-- String.format, Reflection --> <exclude name="**/CullTest.java"/> <!-- GL ES 1.0 --> <exclude name="**/KTXTest.java"/> <!-- use ECT1 which is native --> <exclude name="**/ETC1Test.java"/> <!-- native --> <exclude name="**/FFTTest.java"/> <!-- native --> <exclude name="**/FreeType*.java"/> <!-- native --> <exclude name="**/Gdx2DTest.java"/> <!-- native --> <exclude name="**/GdxTests.java"/> <!-- utility --> <exclude name="**/HeightField.java"/> <!-- Incompatible type due to emulation --> <exclude name="**/HeightMapTest.java"/> <!-- Incompatible type due to emulation --> <exclude name="**/I18NMessageTest.java"/> <!-- MessageBundle --> <exclude name="**/InternationalFontsTest.java"/> <!-- utility --> <exclude name="**/JpegTest.java"/> <!-- native --> <exclude name="**/JsonReaderTest.java"/> <!-- uses ArrayList --> <exclude name="**/Mpg123Test.java"/> <!-- native --> <exclude name="**/NetAPITest.java"/> <!-- abuses FileHandle() --> <exclude name="**/NoncontinuousRenderingTest.java"/> <!-- Noncontinuous rendering not supported --> <exclude name="**/PingPongSocketExample.java"/> <!-- networking --> <exclude name="**/PixelBufferObjectTest.java"/> <!-- threading --> <exclude name="**/PixmapPackerIOTest.java"/> <!-- gdx-tools --> <exclude name="**/PngTest.java"/> <!-- Not compatible --> <exclude name="**/RemoteTest.java"/> <!-- networking --> <exclude name="**/SelectTest.java"/> <!-- String.format --> <exclude name="**/SensorTest.java"/> <!-- Tests device accelerometer, compass, gyro --> <exclude name="**/SoundTouchTest.java"/> <!-- native --> <exclude name="**/StbTrueTypeTest.java"/> <!-- native --> <exclude name="**/TextureDownloadTest.java"/> <!-- http utils missing --> <exclude name="**/TTFFactoryTest.java"/> <!-- native --> <exclude name="**/VBOWithVAOPerformanceTest.java"/> <!-- GLES 3.0, Emulation issues --> <exclude name="**/VorbisTest.java"/> <!-- native --> <exclude name="**/WavTest.java"/> <!-- naive --> <exclude name="**/voxel/*.java"/> <!-- PerlinNoiseGenerator uses a method not in the emulated version of Buffer --> <exclude name="utils/CommandLineOptions.java"/> </source> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.tests.AnnotationTest" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.tests.ReflectionCorrectnessTest" /> <extend-configuration-property name="gdx.reflect.include" value="com.badlogic.gdx.tests.utils.GdxTestConfig" /> </module>
1
libgdx/libgdx
7,250
chore: Update to gwt 2.10.0
I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
SimonIT
"2023-10-06T10:43:44Z"
"2023-11-12T07:23:11Z"
e688cf718d56048bd9ab3e61180b93ee46f399d7
93503b4120f2c6002c7b1ecc73fc36bef4b678a0
chore: Update to gwt 2.10.0. I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
./extensions/gdx-bullet/jni/swig-src/collision/com/badlogic/gdx/physics/bullet/collision/DISTANCE_PLANE_3D_FUNC.java
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.collision; import com.badlogic.gdx.physics.bullet.BulletBase; import com.badlogic.gdx.physics.bullet.linearmath.*; public class DISTANCE_PLANE_3D_FUNC extends BulletBase { private long swigCPtr; protected DISTANCE_PLANE_3D_FUNC (final String className, long cPtr, boolean cMemoryOwn) { super(className, cPtr, cMemoryOwn); swigCPtr = cPtr; } /** Construct a new DISTANCE_PLANE_3D_FUNC, normally you should not need this constructor it's intended for low-level usage. */ public DISTANCE_PLANE_3D_FUNC (long cPtr, boolean cMemoryOwn) { this("DISTANCE_PLANE_3D_FUNC", cPtr, cMemoryOwn); construct(); } @Override protected void reset (long cPtr, boolean cMemoryOwn) { if (!destroyed) destroy(); super.reset(swigCPtr = cPtr, cMemoryOwn); } public static long getCPtr (DISTANCE_PLANE_3D_FUNC obj) { return (obj == null) ? 0 : obj.swigCPtr; } @Override protected void finalize () throws Throwable { if (!destroyed) destroy(); super.finalize(); } @Override protected synchronized void delete () { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; CollisionJNI.delete_DISTANCE_PLANE_3D_FUNC(swigCPtr); } swigCPtr = 0; } super.delete(); } public DISTANCE_PLANE_3D_FUNC () { this(CollisionJNI.new_DISTANCE_PLANE_3D_FUNC(), true); } }
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.collision; import com.badlogic.gdx.physics.bullet.BulletBase; import com.badlogic.gdx.physics.bullet.linearmath.*; public class DISTANCE_PLANE_3D_FUNC extends BulletBase { private long swigCPtr; protected DISTANCE_PLANE_3D_FUNC (final String className, long cPtr, boolean cMemoryOwn) { super(className, cPtr, cMemoryOwn); swigCPtr = cPtr; } /** Construct a new DISTANCE_PLANE_3D_FUNC, normally you should not need this constructor it's intended for low-level usage. */ public DISTANCE_PLANE_3D_FUNC (long cPtr, boolean cMemoryOwn) { this("DISTANCE_PLANE_3D_FUNC", cPtr, cMemoryOwn); construct(); } @Override protected void reset (long cPtr, boolean cMemoryOwn) { if (!destroyed) destroy(); super.reset(swigCPtr = cPtr, cMemoryOwn); } public static long getCPtr (DISTANCE_PLANE_3D_FUNC obj) { return (obj == null) ? 0 : obj.swigCPtr; } @Override protected void finalize () throws Throwable { if (!destroyed) destroy(); super.finalize(); } @Override protected synchronized void delete () { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; CollisionJNI.delete_DISTANCE_PLANE_3D_FUNC(swigCPtr); } swigCPtr = 0; } super.delete(); } public DISTANCE_PLANE_3D_FUNC () { this(CollisionJNI.new_DISTANCE_PLANE_3D_FUNC(), true); } }
-1
libgdx/libgdx
7,250
chore: Update to gwt 2.10.0
I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
SimonIT
"2023-10-06T10:43:44Z"
"2023-11-12T07:23:11Z"
e688cf718d56048bd9ab3e61180b93ee46f399d7
93503b4120f2c6002c7b1ecc73fc36bef4b678a0
chore: Update to gwt 2.10.0. I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
./extensions/gdx-tools/src/com/badlogic/gdx/tools/flame/TextureLoaderPanel.java
package com.badlogic.gdx.tools.flame; import java.awt.GridBagConstraints; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; import javax.swing.DefaultComboBoxModel; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JLabel; import com.badlogic.gdx.assets.loaders.TextureLoader.TextureParameter; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture.TextureFilter; import com.badlogic.gdx.graphics.g2d.TextureAtlas; /** @author Inferno */ public class TextureLoaderPanel extends EditorPanel { public TextureLoaderPanel (FlameMain editor, String name, String description) { super(editor, name, description); setValue(null); } @Override protected void initializeComponents () { super.initializeComponents(); JButton atlasButton = new JButton("Open Atlas"); JButton textureButton = new JButton("Open Texture"); JButton defaultTextureButton = new JButton("Default Texture"); final JCheckBox genMipMaps = new JCheckBox("Generate MipMaps"); final JComboBox minFilterBox = new JComboBox(new DefaultComboBoxModel(TextureFilter.values())); final JComboBox magFilterBox = new JComboBox(new DefaultComboBoxModel(TextureFilter.values())); minFilterBox.setSelectedItem(editor.getTexture().getMinFilter()); magFilterBox.setSelectedItem(editor.getTexture().getMagFilter()); ActionListener filterListener = new ActionListener() { public void actionPerformed (ActionEvent event) { editor.getTexture().setFilter((TextureFilter)minFilterBox.getSelectedItem(), (TextureFilter)magFilterBox.getSelectedItem()); } }; minFilterBox.addActionListener(filterListener); magFilterBox.addActionListener(filterListener); atlasButton.addActionListener(new ActionListener() { @Override public void actionPerformed (ActionEvent e) { File file = editor.showFileLoadDialog(); if (file != null) { TextureAtlas atlas = editor.load(file.getAbsolutePath(), TextureAtlas.class, null, null); if (atlas != null) { editor.setAtlas(atlas); } } } }); textureButton.addActionListener(new ActionListener() { @Override public void actionPerformed (ActionEvent e) { File file = editor.showFileLoadDialog(); if (file != null) { TextureParameter params = new TextureParameter(); params.genMipMaps = genMipMaps.isSelected(); params.minFilter = (TextureFilter)minFilterBox.getSelectedItem(); params.magFilter = (TextureFilter)magFilterBox.getSelectedItem(); Texture texture = editor.load(file.getAbsolutePath(), Texture.class, null, params); if (texture != null) { editor.setTexture(texture); } } } }); defaultTextureButton.addActionListener(new ActionListener() { @Override public void actionPerformed (ActionEvent e) { editor.setTexture(editor.assetManager.get(FlameMain.DEFAULT_BILLBOARD_PARTICLE, Texture.class)); } }); contentPanel.add(new JLabel("Min. Filter"), new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0)); contentPanel.add(minFilterBox, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0)); contentPanel.add(new JLabel("Mag. Filter"), new GridBagConstraints(0, 1, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0)); contentPanel.add(magFilterBox, new GridBagConstraints(1, 1, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0)); contentPanel.add(genMipMaps, new GridBagConstraints(0, 2, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0)); contentPanel.add(atlasButton, new GridBagConstraints(0, 3, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0)); contentPanel.add(textureButton, new GridBagConstraints(1, 3, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0)); contentPanel.add(defaultTextureButton, new GridBagConstraints(2, 3, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0)); } }
package com.badlogic.gdx.tools.flame; import java.awt.GridBagConstraints; import java.awt.Insets; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.File; import javax.swing.DefaultComboBoxModel; import javax.swing.JButton; import javax.swing.JCheckBox; import javax.swing.JComboBox; import javax.swing.JLabel; import com.badlogic.gdx.assets.loaders.TextureLoader.TextureParameter; import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.Texture.TextureFilter; import com.badlogic.gdx.graphics.g2d.TextureAtlas; /** @author Inferno */ public class TextureLoaderPanel extends EditorPanel { public TextureLoaderPanel (FlameMain editor, String name, String description) { super(editor, name, description); setValue(null); } @Override protected void initializeComponents () { super.initializeComponents(); JButton atlasButton = new JButton("Open Atlas"); JButton textureButton = new JButton("Open Texture"); JButton defaultTextureButton = new JButton("Default Texture"); final JCheckBox genMipMaps = new JCheckBox("Generate MipMaps"); final JComboBox minFilterBox = new JComboBox(new DefaultComboBoxModel(TextureFilter.values())); final JComboBox magFilterBox = new JComboBox(new DefaultComboBoxModel(TextureFilter.values())); minFilterBox.setSelectedItem(editor.getTexture().getMinFilter()); magFilterBox.setSelectedItem(editor.getTexture().getMagFilter()); ActionListener filterListener = new ActionListener() { public void actionPerformed (ActionEvent event) { editor.getTexture().setFilter((TextureFilter)minFilterBox.getSelectedItem(), (TextureFilter)magFilterBox.getSelectedItem()); } }; minFilterBox.addActionListener(filterListener); magFilterBox.addActionListener(filterListener); atlasButton.addActionListener(new ActionListener() { @Override public void actionPerformed (ActionEvent e) { File file = editor.showFileLoadDialog(); if (file != null) { TextureAtlas atlas = editor.load(file.getAbsolutePath(), TextureAtlas.class, null, null); if (atlas != null) { editor.setAtlas(atlas); } } } }); textureButton.addActionListener(new ActionListener() { @Override public void actionPerformed (ActionEvent e) { File file = editor.showFileLoadDialog(); if (file != null) { TextureParameter params = new TextureParameter(); params.genMipMaps = genMipMaps.isSelected(); params.minFilter = (TextureFilter)minFilterBox.getSelectedItem(); params.magFilter = (TextureFilter)magFilterBox.getSelectedItem(); Texture texture = editor.load(file.getAbsolutePath(), Texture.class, null, params); if (texture != null) { editor.setTexture(texture); } } } }); defaultTextureButton.addActionListener(new ActionListener() { @Override public void actionPerformed (ActionEvent e) { editor.setTexture(editor.assetManager.get(FlameMain.DEFAULT_BILLBOARD_PARTICLE, Texture.class)); } }); contentPanel.add(new JLabel("Min. Filter"), new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0)); contentPanel.add(minFilterBox, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0)); contentPanel.add(new JLabel("Mag. Filter"), new GridBagConstraints(0, 1, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0)); contentPanel.add(magFilterBox, new GridBagConstraints(1, 1, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0)); contentPanel.add(genMipMaps, new GridBagConstraints(0, 2, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0)); contentPanel.add(atlasButton, new GridBagConstraints(0, 3, 1, 1, 0, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0)); contentPanel.add(textureButton, new GridBagConstraints(1, 3, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0)); contentPanel.add(defaultTextureButton, new GridBagConstraints(2, 3, 1, 1, 1, 0, GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(6, 0, 0, 0), 0, 0)); } }
-1
libgdx/libgdx
7,250
chore: Update to gwt 2.10.0
I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
SimonIT
"2023-10-06T10:43:44Z"
"2023-11-12T07:23:11Z"
e688cf718d56048bd9ab3e61180b93ee46f399d7
93503b4120f2c6002c7b1ecc73fc36bef4b678a0
chore: Update to gwt 2.10.0. I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
./extensions/gdx-bullet/jni/swig-src/linearmath/com/badlogic/gdx/physics/bullet/linearmath/btConvexSeparatingDistanceUtil.java
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.linearmath; import com.badlogic.gdx.physics.bullet.BulletBase; import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.math.Matrix4; public class btConvexSeparatingDistanceUtil extends BulletBase { private long swigCPtr; protected btConvexSeparatingDistanceUtil (final String className, long cPtr, boolean cMemoryOwn) { super(className, cPtr, cMemoryOwn); swigCPtr = cPtr; } /** Construct a new btConvexSeparatingDistanceUtil, normally you should not need this constructor it's intended for low-level * usage. */ public btConvexSeparatingDistanceUtil (long cPtr, boolean cMemoryOwn) { this("btConvexSeparatingDistanceUtil", cPtr, cMemoryOwn); construct(); } @Override protected void reset (long cPtr, boolean cMemoryOwn) { if (!destroyed) destroy(); super.reset(swigCPtr = cPtr, cMemoryOwn); } public static long getCPtr (btConvexSeparatingDistanceUtil obj) { return (obj == null) ? 0 : obj.swigCPtr; } @Override protected void finalize () throws Throwable { if (!destroyed) destroy(); super.finalize(); } @Override protected synchronized void delete () { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; LinearMathJNI.delete_btConvexSeparatingDistanceUtil(swigCPtr); } swigCPtr = 0; } super.delete(); } public btConvexSeparatingDistanceUtil (float boundingRadiusA, float boundingRadiusB) { this(LinearMathJNI.new_btConvexSeparatingDistanceUtil(boundingRadiusA, boundingRadiusB), true); } public float getConservativeSeparatingDistance () { return LinearMathJNI.btConvexSeparatingDistanceUtil_getConservativeSeparatingDistance(swigCPtr, this); } public void updateSeparatingDistance (Matrix4 transA, Matrix4 transB) { LinearMathJNI.btConvexSeparatingDistanceUtil_updateSeparatingDistance(swigCPtr, this, transA, transB); } public void initSeparatingDistance (Vector3 separatingVector, float separatingDistance, Matrix4 transA, Matrix4 transB) { LinearMathJNI.btConvexSeparatingDistanceUtil_initSeparatingDistance(swigCPtr, this, separatingVector, separatingDistance, transA, transB); } }
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.linearmath; import com.badlogic.gdx.physics.bullet.BulletBase; import com.badlogic.gdx.math.Vector3; import com.badlogic.gdx.math.Matrix4; public class btConvexSeparatingDistanceUtil extends BulletBase { private long swigCPtr; protected btConvexSeparatingDistanceUtil (final String className, long cPtr, boolean cMemoryOwn) { super(className, cPtr, cMemoryOwn); swigCPtr = cPtr; } /** Construct a new btConvexSeparatingDistanceUtil, normally you should not need this constructor it's intended for low-level * usage. */ public btConvexSeparatingDistanceUtil (long cPtr, boolean cMemoryOwn) { this("btConvexSeparatingDistanceUtil", cPtr, cMemoryOwn); construct(); } @Override protected void reset (long cPtr, boolean cMemoryOwn) { if (!destroyed) destroy(); super.reset(swigCPtr = cPtr, cMemoryOwn); } public static long getCPtr (btConvexSeparatingDistanceUtil obj) { return (obj == null) ? 0 : obj.swigCPtr; } @Override protected void finalize () throws Throwable { if (!destroyed) destroy(); super.finalize(); } @Override protected synchronized void delete () { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; LinearMathJNI.delete_btConvexSeparatingDistanceUtil(swigCPtr); } swigCPtr = 0; } super.delete(); } public btConvexSeparatingDistanceUtil (float boundingRadiusA, float boundingRadiusB) { this(LinearMathJNI.new_btConvexSeparatingDistanceUtil(boundingRadiusA, boundingRadiusB), true); } public float getConservativeSeparatingDistance () { return LinearMathJNI.btConvexSeparatingDistanceUtil_getConservativeSeparatingDistance(swigCPtr, this); } public void updateSeparatingDistance (Matrix4 transA, Matrix4 transB) { LinearMathJNI.btConvexSeparatingDistanceUtil_updateSeparatingDistance(swigCPtr, this, transA, transB); } public void initSeparatingDistance (Vector3 separatingVector, float separatingDistance, Matrix4 transA, Matrix4 transB) { LinearMathJNI.btConvexSeparatingDistanceUtil_initSeparatingDistance(swigCPtr, this, separatingVector, separatingDistance, transA, transB); } }
-1
libgdx/libgdx
7,250
chore: Update to gwt 2.10.0
I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
SimonIT
"2023-10-06T10:43:44Z"
"2023-11-12T07:23:11Z"
e688cf718d56048bd9ab3e61180b93ee46f399d7
93503b4120f2c6002c7b1ecc73fc36bef4b678a0
chore: Update to gwt 2.10.0. I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
./gdx/test/com/badlogic/gdx/utils/MixedPutRemoveTest.java
package com.badlogic.gdx.utils; import org.junit.Assert; import org.junit.Test; import java.util.HashMap; import java.util.Iterator; public class MixedPutRemoveTest { @Test public void testLongMapPut () { LongMap<Integer> gdxMap = new LongMap<Integer>(); HashMap<Long, Integer> jdkMap = new HashMap<Long, Integer>(); long stateA = 0L, stateB = 1L; int gdxRepeats = 0, jdkRepeats = 0; long item; for (int i = 0; i < 0x100000; i++) { // a million should do // simple-ish RNG that repeats more than RandomXS128; we want repeats to test behavior stateA += 0xC6BC279692B5C323L; item = (stateA ^ stateA >>> 31) * (stateB += 0x9E3779B97F4A7C16L); item &= item >>> 24; // causes 64-bit state to get crammed into 40 bits, with item biased toward low bit counts if (gdxMap.put(item, i) != null) gdxRepeats++; if (jdkMap.put(item, i) != null) jdkRepeats++; Assert.assertEquals(gdxMap.size, jdkMap.size()); } Assert.assertEquals(gdxRepeats, jdkRepeats); } @Test public void testLongMapMix () { LongMap<Integer> gdxMap = new LongMap<Integer>(); HashMap<Long, Integer> jdkMap = new HashMap<Long, Integer>(); long stateA = 0L, stateB = 1L; int gdxRemovals = 0, jdkRemovals = 0; long item; for (int i = 0; i < 0x100000; i++) { // 1 million should do // simple-ish RNG that repeats more than RandomXS128; we want repeats to test behavior stateA += 0xC6BC279692B5C323L; item = (stateA ^ stateA >>> 31) * (stateB += 0x9E3779B97F4A7C16L); item &= item >>> 24; // causes 64-bit state to get crammed into 40 bits, with item biased toward low bit counts if (gdxMap.remove(item) == null) gdxMap.put(item, i); else gdxRemovals++; if (jdkMap.remove(item) == null) jdkMap.put(item, i); else jdkRemovals++; Assert.assertEquals(gdxMap.size, jdkMap.size()); } Assert.assertEquals(gdxRemovals, jdkRemovals); } @Test public void testLongMapIterator () { LongMap<Long> gdxMap = new LongMap<Long>(); long stateA = 0L, stateB = 1L, temp; int actualSize = 0; long item; for (int i = 0; i < 0x10000; i++) { // 64K should do // simple-ish RNG that repeats more than RandomXS128; we want repeats to test behavior stateA += 0xC6BC279692B5C323L; item = (stateA ^ stateA >>> 31) * (stateB += 0x9E3779B97F4A7C16L); item &= item >>> 24; // causes 64-bit state to get crammed into 40 bits, with item biased toward low bit counts if (gdxMap.put(item, item) == null) actualSize++; if (actualSize % 6 == 5) { Iterator<Long> it = gdxMap.values().iterator(); for (int n = (int)(item & 3) + 1; n > 0; n--) { it.next(); } it.remove(); actualSize--; // repeat above RNG for (int j = 0; j < 2; j++) { stateA += 0xC6BC279692B5C323L; item = (stateA ^ stateA >>> 31) * (stateB += 0x9E3779B97F4A7C16L); item &= item >>> 24; if (gdxMap.put(item, item) == null) actualSize++; } } Assert.assertEquals(gdxMap.size, actualSize); } for (LongMap.Entry<Long> ent : gdxMap) { Assert.assertEquals(ent.key, ent.value.longValue()); } } @Test public void testIntMapPut () { IntMap<Integer> gdxMap = new IntMap<Integer>(); HashMap<Integer, Integer> jdkMap = new HashMap<Integer, Integer>(); long stateA = 0L, stateB = 1L, temp; int gdxRepeats = 0, jdkRepeats = 0; int item; for (int i = 0; i < 0x100000; i++) { // 1 million should do // simple-ish RNG that repeats more than RandomXS128; we want repeats to test behavior stateA += 0xC6BC279692B5C323L; temp = (stateA ^ stateA >>> 31) * (stateB += 0x9E3779B97F4A7C16L); item = (int)(temp & temp >>> 24); // causes 64-bit state to get crammed into 32 bits, with item biased toward low bit // counts if (gdxMap.put(item, i) != null) gdxRepeats++; if (jdkMap.put(item, i) != null) jdkRepeats++; Assert.assertEquals(gdxMap.size, jdkMap.size()); } Assert.assertEquals(gdxRepeats, jdkRepeats); } @Test public void testIntMapMix () { IntMap<Integer> gdxMap = new IntMap<Integer>(); HashMap<Integer, Integer> jdkMap = new HashMap<Integer, Integer>(); long stateA = 0L, stateB = 1L, temp; int gdxRemovals = 0, jdkRemovals = 0; int item; for (int i = 0; i < 0x100000; i++) { // 1 million should do // simple-ish RNG that repeats more than RandomXS128; we want repeats to test behavior stateA += 0xC6BC279692B5C323L; temp = (stateA ^ stateA >>> 31) * (stateB += 0x9E3779B97F4A7C16L); item = (int)(temp & temp >>> 24); // causes 64-bit state to get crammed into 32 bits, with item biased toward low bit // counts if (gdxMap.remove(item) == null) gdxMap.put(item, i); else gdxRemovals++; if (jdkMap.remove(item) == null) jdkMap.put(item, i); else jdkRemovals++; Assert.assertEquals(gdxMap.size, jdkMap.size()); } Assert.assertEquals(gdxRemovals, jdkRemovals); } @Test public void testIntMapIterator () { IntMap<Integer> gdxMap = new IntMap<Integer>(); long stateA = 0L, stateB = 1L, temp; int gdxRemovals = 0, actualSize = 0; int item; for (int i = 0; i < 0x10000; i++) { // 64K should do // simple-ish RNG that repeats more than RandomXS128; we want repeats to test behavior stateA += 0xC6BC279692B5C323L; temp = (stateA ^ stateA >>> 31) * (stateB += 0x9E3779B97F4A7C16L); item = (int)(temp & temp >>> 24); // causes 64-bit state to get crammed into 32 bits, with item biased toward low bit // counts if (gdxMap.put(item, item) == null) actualSize++; if (actualSize % 6 == 5) { Iterator<Integer> it = gdxMap.values().iterator(); for (int n = (int)(temp & 3) + 1; n > 0; n--) { it.next(); } it.remove(); actualSize--; // repeat above RNG for (int j = 0; j < 2; j++) { stateA += 0xC6BC279692B5C323L; temp = (stateA ^ stateA >>> 31) * (stateB += 0x9E3779B97F4A7C16L); item = (int)(temp & temp >>> 24); if (gdxMap.put(item, item) == null) actualSize++; } } Assert.assertEquals(gdxMap.size, actualSize); } for (IntMap.Entry<Integer> ent : gdxMap) { Assert.assertEquals(ent.key, ent.value.intValue()); } } @Test public void testObjectMapPut () { ObjectMap<Integer, Integer> gdxMap = new ObjectMap<Integer, Integer>(); HashMap<Integer, Integer> jdkMap = new HashMap<Integer, Integer>(); long stateA = 0L, stateB = 1L, temp; int gdxRepeats = 0, jdkRepeats = 0; int item; for (int i = 0; i < 0x100000; i++) { // 1 million should do // simple-ish RNG that repeats more than RandomXS128; we want repeats to test behavior stateA += 0xC6BC279692B5C323L; temp = (stateA ^ stateA >>> 31) * (stateB += 0x9E3779B97F4A7C16L); item = (int)(temp & temp >>> 24); // causes 64-bit state to get crammed into 32 bits, with item biased toward low bit // counts if (gdxMap.put(item, i) != null) gdxRepeats++; if (jdkMap.put(item, i) != null) jdkRepeats++; Assert.assertEquals(gdxMap.size, jdkMap.size()); } Assert.assertEquals(gdxRepeats, jdkRepeats); } @Test public void testObjectMapMix () { ObjectMap<Integer, Integer> gdxMap = new ObjectMap<Integer, Integer>(); HashMap<Integer, Integer> jdkMap = new HashMap<Integer, Integer>(); long stateA = 0L, stateB = 1L, temp; int gdxRemovals = 0, jdkRemovals = 0; int item; for (int i = 0; i < 0x100000; i++) { // 1 million should do // simple-ish RNG that repeats more than RandomXS128; we want repeats to test behavior stateA += 0xC6BC279692B5C323L; temp = (stateA ^ stateA >>> 31) * (stateB += 0x9E3779B97F4A7C16L); item = (int)(temp & temp >>> 24); // causes 64-bit state to get crammed into 32 bits, with item biased toward low bit // counts if (gdxMap.remove(item) == null) gdxMap.put(item, i); else gdxRemovals++; if (jdkMap.remove(item) == null) jdkMap.put(item, i); else jdkRemovals++; Assert.assertEquals(gdxMap.size, jdkMap.size()); } Assert.assertEquals(gdxRemovals, jdkRemovals); } }
package com.badlogic.gdx.utils; import org.junit.Assert; import org.junit.Test; import java.util.HashMap; import java.util.Iterator; public class MixedPutRemoveTest { @Test public void testLongMapPut () { LongMap<Integer> gdxMap = new LongMap<Integer>(); HashMap<Long, Integer> jdkMap = new HashMap<Long, Integer>(); long stateA = 0L, stateB = 1L; int gdxRepeats = 0, jdkRepeats = 0; long item; for (int i = 0; i < 0x100000; i++) { // a million should do // simple-ish RNG that repeats more than RandomXS128; we want repeats to test behavior stateA += 0xC6BC279692B5C323L; item = (stateA ^ stateA >>> 31) * (stateB += 0x9E3779B97F4A7C16L); item &= item >>> 24; // causes 64-bit state to get crammed into 40 bits, with item biased toward low bit counts if (gdxMap.put(item, i) != null) gdxRepeats++; if (jdkMap.put(item, i) != null) jdkRepeats++; Assert.assertEquals(gdxMap.size, jdkMap.size()); } Assert.assertEquals(gdxRepeats, jdkRepeats); } @Test public void testLongMapMix () { LongMap<Integer> gdxMap = new LongMap<Integer>(); HashMap<Long, Integer> jdkMap = new HashMap<Long, Integer>(); long stateA = 0L, stateB = 1L; int gdxRemovals = 0, jdkRemovals = 0; long item; for (int i = 0; i < 0x100000; i++) { // 1 million should do // simple-ish RNG that repeats more than RandomXS128; we want repeats to test behavior stateA += 0xC6BC279692B5C323L; item = (stateA ^ stateA >>> 31) * (stateB += 0x9E3779B97F4A7C16L); item &= item >>> 24; // causes 64-bit state to get crammed into 40 bits, with item biased toward low bit counts if (gdxMap.remove(item) == null) gdxMap.put(item, i); else gdxRemovals++; if (jdkMap.remove(item) == null) jdkMap.put(item, i); else jdkRemovals++; Assert.assertEquals(gdxMap.size, jdkMap.size()); } Assert.assertEquals(gdxRemovals, jdkRemovals); } @Test public void testLongMapIterator () { LongMap<Long> gdxMap = new LongMap<Long>(); long stateA = 0L, stateB = 1L, temp; int actualSize = 0; long item; for (int i = 0; i < 0x10000; i++) { // 64K should do // simple-ish RNG that repeats more than RandomXS128; we want repeats to test behavior stateA += 0xC6BC279692B5C323L; item = (stateA ^ stateA >>> 31) * (stateB += 0x9E3779B97F4A7C16L); item &= item >>> 24; // causes 64-bit state to get crammed into 40 bits, with item biased toward low bit counts if (gdxMap.put(item, item) == null) actualSize++; if (actualSize % 6 == 5) { Iterator<Long> it = gdxMap.values().iterator(); for (int n = (int)(item & 3) + 1; n > 0; n--) { it.next(); } it.remove(); actualSize--; // repeat above RNG for (int j = 0; j < 2; j++) { stateA += 0xC6BC279692B5C323L; item = (stateA ^ stateA >>> 31) * (stateB += 0x9E3779B97F4A7C16L); item &= item >>> 24; if (gdxMap.put(item, item) == null) actualSize++; } } Assert.assertEquals(gdxMap.size, actualSize); } for (LongMap.Entry<Long> ent : gdxMap) { Assert.assertEquals(ent.key, ent.value.longValue()); } } @Test public void testIntMapPut () { IntMap<Integer> gdxMap = new IntMap<Integer>(); HashMap<Integer, Integer> jdkMap = new HashMap<Integer, Integer>(); long stateA = 0L, stateB = 1L, temp; int gdxRepeats = 0, jdkRepeats = 0; int item; for (int i = 0; i < 0x100000; i++) { // 1 million should do // simple-ish RNG that repeats more than RandomXS128; we want repeats to test behavior stateA += 0xC6BC279692B5C323L; temp = (stateA ^ stateA >>> 31) * (stateB += 0x9E3779B97F4A7C16L); item = (int)(temp & temp >>> 24); // causes 64-bit state to get crammed into 32 bits, with item biased toward low bit // counts if (gdxMap.put(item, i) != null) gdxRepeats++; if (jdkMap.put(item, i) != null) jdkRepeats++; Assert.assertEquals(gdxMap.size, jdkMap.size()); } Assert.assertEquals(gdxRepeats, jdkRepeats); } @Test public void testIntMapMix () { IntMap<Integer> gdxMap = new IntMap<Integer>(); HashMap<Integer, Integer> jdkMap = new HashMap<Integer, Integer>(); long stateA = 0L, stateB = 1L, temp; int gdxRemovals = 0, jdkRemovals = 0; int item; for (int i = 0; i < 0x100000; i++) { // 1 million should do // simple-ish RNG that repeats more than RandomXS128; we want repeats to test behavior stateA += 0xC6BC279692B5C323L; temp = (stateA ^ stateA >>> 31) * (stateB += 0x9E3779B97F4A7C16L); item = (int)(temp & temp >>> 24); // causes 64-bit state to get crammed into 32 bits, with item biased toward low bit // counts if (gdxMap.remove(item) == null) gdxMap.put(item, i); else gdxRemovals++; if (jdkMap.remove(item) == null) jdkMap.put(item, i); else jdkRemovals++; Assert.assertEquals(gdxMap.size, jdkMap.size()); } Assert.assertEquals(gdxRemovals, jdkRemovals); } @Test public void testIntMapIterator () { IntMap<Integer> gdxMap = new IntMap<Integer>(); long stateA = 0L, stateB = 1L, temp; int gdxRemovals = 0, actualSize = 0; int item; for (int i = 0; i < 0x10000; i++) { // 64K should do // simple-ish RNG that repeats more than RandomXS128; we want repeats to test behavior stateA += 0xC6BC279692B5C323L; temp = (stateA ^ stateA >>> 31) * (stateB += 0x9E3779B97F4A7C16L); item = (int)(temp & temp >>> 24); // causes 64-bit state to get crammed into 32 bits, with item biased toward low bit // counts if (gdxMap.put(item, item) == null) actualSize++; if (actualSize % 6 == 5) { Iterator<Integer> it = gdxMap.values().iterator(); for (int n = (int)(temp & 3) + 1; n > 0; n--) { it.next(); } it.remove(); actualSize--; // repeat above RNG for (int j = 0; j < 2; j++) { stateA += 0xC6BC279692B5C323L; temp = (stateA ^ stateA >>> 31) * (stateB += 0x9E3779B97F4A7C16L); item = (int)(temp & temp >>> 24); if (gdxMap.put(item, item) == null) actualSize++; } } Assert.assertEquals(gdxMap.size, actualSize); } for (IntMap.Entry<Integer> ent : gdxMap) { Assert.assertEquals(ent.key, ent.value.intValue()); } } @Test public void testObjectMapPut () { ObjectMap<Integer, Integer> gdxMap = new ObjectMap<Integer, Integer>(); HashMap<Integer, Integer> jdkMap = new HashMap<Integer, Integer>(); long stateA = 0L, stateB = 1L, temp; int gdxRepeats = 0, jdkRepeats = 0; int item; for (int i = 0; i < 0x100000; i++) { // 1 million should do // simple-ish RNG that repeats more than RandomXS128; we want repeats to test behavior stateA += 0xC6BC279692B5C323L; temp = (stateA ^ stateA >>> 31) * (stateB += 0x9E3779B97F4A7C16L); item = (int)(temp & temp >>> 24); // causes 64-bit state to get crammed into 32 bits, with item biased toward low bit // counts if (gdxMap.put(item, i) != null) gdxRepeats++; if (jdkMap.put(item, i) != null) jdkRepeats++; Assert.assertEquals(gdxMap.size, jdkMap.size()); } Assert.assertEquals(gdxRepeats, jdkRepeats); } @Test public void testObjectMapMix () { ObjectMap<Integer, Integer> gdxMap = new ObjectMap<Integer, Integer>(); HashMap<Integer, Integer> jdkMap = new HashMap<Integer, Integer>(); long stateA = 0L, stateB = 1L, temp; int gdxRemovals = 0, jdkRemovals = 0; int item; for (int i = 0; i < 0x100000; i++) { // 1 million should do // simple-ish RNG that repeats more than RandomXS128; we want repeats to test behavior stateA += 0xC6BC279692B5C323L; temp = (stateA ^ stateA >>> 31) * (stateB += 0x9E3779B97F4A7C16L); item = (int)(temp & temp >>> 24); // causes 64-bit state to get crammed into 32 bits, with item biased toward low bit // counts if (gdxMap.remove(item) == null) gdxMap.put(item, i); else gdxRemovals++; if (jdkMap.remove(item) == null) jdkMap.put(item, i); else jdkRemovals++; Assert.assertEquals(gdxMap.size, jdkMap.size()); } Assert.assertEquals(gdxRemovals, jdkRemovals); } }
-1
libgdx/libgdx
7,250
chore: Update to gwt 2.10.0
I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
SimonIT
"2023-10-06T10:43:44Z"
"2023-11-12T07:23:11Z"
e688cf718d56048bd9ab3e61180b93ee46f399d7
93503b4120f2c6002c7b1ecc73fc36bef4b678a0
chore: Update to gwt 2.10.0. I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
./backends/gdx-backend-robovm-metalangle/src/com/badlogic/gdx/backends/iosrobovm/objectal/OALAudioSession.java
/*DO NOT EDIT THIS FILE - it is machine generated*/ package com.badlogic.gdx.backends.iosrobovm.objectal; import org.robovm.apple.foundation.NSObject; import org.robovm.objc.ObjCRuntime; import org.robovm.objc.annotation.Method; import org.robovm.objc.annotation.NativeClass; import org.robovm.rt.bro.annotation.Library; /** DO NOT EDIT THIS FILE - it is machine generated */ @Library(Library.INTERNAL) @NativeClass public final class OALAudioSession extends NSObject { static { ObjCRuntime.bind(OALAudioSession.class); } @Method public native static OALAudioSession sharedInstance (); @Method public native void forceEndInterruption (); }
/*DO NOT EDIT THIS FILE - it is machine generated*/ package com.badlogic.gdx.backends.iosrobovm.objectal; import org.robovm.apple.foundation.NSObject; import org.robovm.objc.ObjCRuntime; import org.robovm.objc.annotation.Method; import org.robovm.objc.annotation.NativeClass; import org.robovm.rt.bro.annotation.Library; /** DO NOT EDIT THIS FILE - it is machine generated */ @Library(Library.INTERNAL) @NativeClass public final class OALAudioSession extends NSObject { static { ObjCRuntime.bind(OALAudioSession.class); } @Method public native static OALAudioSession sharedInstance (); @Method public native void forceEndInterruption (); }
-1
libgdx/libgdx
7,250
chore: Update to gwt 2.10.0
I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
SimonIT
"2023-10-06T10:43:44Z"
"2023-11-12T07:23:11Z"
e688cf718d56048bd9ab3e61180b93ee46f399d7
93503b4120f2c6002c7b1ecc73fc36bef4b678a0
chore: Update to gwt 2.10.0. I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
./tests/gdx-tests/src/com/badlogic/gdx/tests/EdgeDetectionTest.java
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.tests; import java.util.Arrays; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.FPSLogger; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.PerspectiveCamera; import com.badlogic.gdx.graphics.Pixmap.Format; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.graphics.g3d.Model; import com.badlogic.gdx.graphics.g3d.ModelBatch; import com.badlogic.gdx.graphics.g3d.ModelInstance; import com.badlogic.gdx.graphics.g3d.loader.ObjLoader; import com.badlogic.gdx.graphics.glutils.FrameBuffer; import com.badlogic.gdx.graphics.glutils.ShaderProgram; import com.badlogic.gdx.math.Matrix4; import com.badlogic.gdx.tests.utils.GdxTest; public class EdgeDetectionTest extends GdxTest { FPSLogger logger; // ShaderProgram shader; Model scene; ModelInstance sceneInstance; ModelBatch modelBatch; FrameBuffer fbo; PerspectiveCamera cam; Matrix4 matrix = new Matrix4(); float angle = 0; TextureRegion fboRegion; SpriteBatch batch; ShaderProgram batchShader; float[] filter = {0, 0.25f, 0, 0.25f, -1f, 0.6f, 0, 0.25f, 0,}; float[] offsets = new float[18]; public void create () { ShaderProgram.pedantic = false; /* * shader = new ShaderProgram(Gdx.files.internal("data/shaders/default.vert").readString(), Gdx.files.internal( * "data/shaders/depthtocolor.frag").readString()); if (!shader.isCompiled()) { Gdx.app.log("EdgeDetectionTest", * "couldn't compile scene shader: " + shader.getLog()); } */ batchShader = new ShaderProgram(Gdx.files.internal("data/shaders/batch.vert").readString(), Gdx.files.internal("data/shaders/convolution.frag").readString()); if (!batchShader.isCompiled()) { Gdx.app.log("EdgeDetectionTest", "couldn't compile post-processing shader: " + batchShader.getLog()); } ObjLoader objLoader = new ObjLoader(); scene = objLoader.loadModel(Gdx.files.internal("data/scene.obj")); sceneInstance = new ModelInstance(scene); modelBatch = new ModelBatch(); fbo = new FrameBuffer(Format.RGB565, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true); cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); cam.position.set(0, 0, 10); cam.lookAt(0, 0, 0); cam.far = 30; batch = new SpriteBatch(); batch.setShader(batchShader); fboRegion = new TextureRegion(fbo.getColorBufferTexture()); fboRegion.flip(false, true); logger = new FPSLogger(); calculateOffsets(); } @Override public void dispose () { batchShader.dispose(); scene.dispose(); fbo.dispose(); batch.dispose(); } private void calculateOffsets () { int idx = 0; for (int y = -1; y <= 1; y++) { for (int x = -1; x <= 1; x++) { offsets[idx++] = x / (float)Gdx.graphics.getWidth(); offsets[idx++] = y / (float)Gdx.graphics.getHeight(); } } System.out.println(Arrays.toString(offsets)); } public void render () { angle += 45 * Gdx.graphics.getDeltaTime(); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); cam.update(); matrix.setToRotation(0, 1, 0, angle); cam.combined.mul(matrix); fbo.begin(); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); Gdx.gl.glEnable(GL20.GL_DEPTH_TEST); modelBatch.begin(cam); modelBatch.render(sceneInstance); modelBatch.end(); fbo.end(); batch.begin(); batch.disableBlending(); batchShader.setUniformi("u_filterSize", filter.length); batchShader.setUniform1fv("u_filter", filter, 0, filter.length); batchShader.setUniform2fv("u_offsets", offsets, 0, offsets.length); batch.draw(fboRegion, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); batch.end(); logger.log(); } }
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.tests; import java.util.Arrays; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.graphics.FPSLogger; import com.badlogic.gdx.graphics.GL20; import com.badlogic.gdx.graphics.PerspectiveCamera; import com.badlogic.gdx.graphics.Pixmap.Format; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.graphics.g2d.TextureRegion; import com.badlogic.gdx.graphics.g3d.Model; import com.badlogic.gdx.graphics.g3d.ModelBatch; import com.badlogic.gdx.graphics.g3d.ModelInstance; import com.badlogic.gdx.graphics.g3d.loader.ObjLoader; import com.badlogic.gdx.graphics.glutils.FrameBuffer; import com.badlogic.gdx.graphics.glutils.ShaderProgram; import com.badlogic.gdx.math.Matrix4; import com.badlogic.gdx.tests.utils.GdxTest; public class EdgeDetectionTest extends GdxTest { FPSLogger logger; // ShaderProgram shader; Model scene; ModelInstance sceneInstance; ModelBatch modelBatch; FrameBuffer fbo; PerspectiveCamera cam; Matrix4 matrix = new Matrix4(); float angle = 0; TextureRegion fboRegion; SpriteBatch batch; ShaderProgram batchShader; float[] filter = {0, 0.25f, 0, 0.25f, -1f, 0.6f, 0, 0.25f, 0,}; float[] offsets = new float[18]; public void create () { ShaderProgram.pedantic = false; /* * shader = new ShaderProgram(Gdx.files.internal("data/shaders/default.vert").readString(), Gdx.files.internal( * "data/shaders/depthtocolor.frag").readString()); if (!shader.isCompiled()) { Gdx.app.log("EdgeDetectionTest", * "couldn't compile scene shader: " + shader.getLog()); } */ batchShader = new ShaderProgram(Gdx.files.internal("data/shaders/batch.vert").readString(), Gdx.files.internal("data/shaders/convolution.frag").readString()); if (!batchShader.isCompiled()) { Gdx.app.log("EdgeDetectionTest", "couldn't compile post-processing shader: " + batchShader.getLog()); } ObjLoader objLoader = new ObjLoader(); scene = objLoader.loadModel(Gdx.files.internal("data/scene.obj")); sceneInstance = new ModelInstance(scene); modelBatch = new ModelBatch(); fbo = new FrameBuffer(Format.RGB565, Gdx.graphics.getWidth(), Gdx.graphics.getHeight(), true); cam = new PerspectiveCamera(67, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); cam.position.set(0, 0, 10); cam.lookAt(0, 0, 0); cam.far = 30; batch = new SpriteBatch(); batch.setShader(batchShader); fboRegion = new TextureRegion(fbo.getColorBufferTexture()); fboRegion.flip(false, true); logger = new FPSLogger(); calculateOffsets(); } @Override public void dispose () { batchShader.dispose(); scene.dispose(); fbo.dispose(); batch.dispose(); } private void calculateOffsets () { int idx = 0; for (int y = -1; y <= 1; y++) { for (int x = -1; x <= 1; x++) { offsets[idx++] = x / (float)Gdx.graphics.getWidth(); offsets[idx++] = y / (float)Gdx.graphics.getHeight(); } } System.out.println(Arrays.toString(offsets)); } public void render () { angle += 45 * Gdx.graphics.getDeltaTime(); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); cam.update(); matrix.setToRotation(0, 1, 0, angle); cam.combined.mul(matrix); fbo.begin(); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT | GL20.GL_DEPTH_BUFFER_BIT); Gdx.gl.glEnable(GL20.GL_DEPTH_TEST); modelBatch.begin(cam); modelBatch.render(sceneInstance); modelBatch.end(); fbo.end(); batch.begin(); batch.disableBlending(); batchShader.setUniformi("u_filterSize", filter.length); batchShader.setUniform1fv("u_filter", filter, 0, filter.length); batchShader.setUniform2fv("u_offsets", offsets, 0, offsets.length); batch.draw(fboRegion, 0, 0, Gdx.graphics.getWidth(), Gdx.graphics.getHeight()); batch.end(); logger.log(); } }
-1
libgdx/libgdx
7,250
chore: Update to gwt 2.10.0
I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
SimonIT
"2023-10-06T10:43:44Z"
"2023-11-12T07:23:11Z"
e688cf718d56048bd9ab3e61180b93ee46f399d7
93503b4120f2c6002c7b1ecc73fc36bef4b678a0
chore: Update to gwt 2.10.0. I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
./gdx/src/com/badlogic/gdx/scenes/scene2d/ui/List.java
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.scenes.scene2d.ui; import com.badlogic.gdx.Input.Keys; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.g2d.Batch; import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.GlyphLayout; import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.InputListener; import com.badlogic.gdx.scenes.scene2d.utils.ArraySelection; import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent; import com.badlogic.gdx.scenes.scene2d.utils.Cullable; import com.badlogic.gdx.scenes.scene2d.utils.Drawable; import com.badlogic.gdx.scenes.scene2d.utils.UIUtils; import com.badlogic.gdx.utils.Align; import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.Null; import com.badlogic.gdx.utils.ObjectSet; import com.badlogic.gdx.utils.Pool; import com.badlogic.gdx.utils.Pools; /** A list (aka list box) displays textual items and highlights the currently selected item. * <p> * {@link ChangeEvent} is fired when the list selection changes. * <p> * The preferred size of the list is determined by the text bounds of the items and the size of the {@link ListStyle#selection}. * @author mzechner * @author Nathan Sweet */ public class List<T> extends Widget implements Cullable { ListStyle style; final Array<T> items = new Array(); ArraySelection<T> selection = new ArraySelection(items); private Rectangle cullingArea; private float prefWidth, prefHeight; float itemHeight; private int alignment = Align.left; int pressedIndex = -1, overIndex = -1; private InputListener keyListener; boolean typeToSelect; public List (Skin skin) { this(skin.get(ListStyle.class)); } public List (Skin skin, String styleName) { this(skin.get(styleName, ListStyle.class)); } public List (ListStyle style) { selection.setActor(this); selection.setRequired(true); setStyle(style); setSize(getPrefWidth(), getPrefHeight()); addListener(keyListener = new InputListener() { long typeTimeout; String prefix; public boolean keyDown (InputEvent event, int keycode) { if (items.isEmpty()) return false; int index; switch (keycode) { case Keys.A: if (UIUtils.ctrl() && selection.getMultiple()) { selection.clear(); selection.addAll(items); return true; } break; case Keys.HOME: setSelectedIndex(0); return true; case Keys.END: setSelectedIndex(items.size - 1); return true; case Keys.DOWN: index = items.indexOf(getSelected(), false) + 1; if (index >= items.size) index = 0; setSelectedIndex(index); return true; case Keys.UP: index = items.indexOf(getSelected(), false) - 1; if (index < 0) index = items.size - 1; setSelectedIndex(index); return true; case Keys.ESCAPE: if (getStage() != null) getStage().setKeyboardFocus(null); return true; } return false; } public boolean keyTyped (InputEvent event, char character) { if (!typeToSelect) return false; long time = System.currentTimeMillis(); if (time > typeTimeout) prefix = ""; typeTimeout = time + 300; prefix += Character.toLowerCase(character); for (int i = 0, n = items.size; i < n; i++) { if (List.this.toString(items.get(i)).toLowerCase().startsWith(prefix)) { setSelectedIndex(i); break; } } return false; } }); addListener(new InputListener() { public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) { if (pointer != 0 || button != 0) return true; if (selection.isDisabled()) return true; if (getStage() != null) getStage().setKeyboardFocus(List.this); if (items.size == 0) return true; int index = getItemIndexAt(y); if (index == -1) return true; selection.choose(items.get(index)); pressedIndex = index; return true; } public void touchUp (InputEvent event, float x, float y, int pointer, int button) { if (pointer != 0 || button != 0) return; pressedIndex = -1; } public void touchDragged (InputEvent event, float x, float y, int pointer) { overIndex = getItemIndexAt(y); } public boolean mouseMoved (InputEvent event, float x, float y) { overIndex = getItemIndexAt(y); return false; } public void exit (InputEvent event, float x, float y, int pointer, Actor toActor) { if (pointer == 0) pressedIndex = -1; if (pointer == -1) overIndex = -1; } }); } public void setStyle (ListStyle style) { if (style == null) throw new IllegalArgumentException("style cannot be null."); this.style = style; invalidateHierarchy(); } /** Returns the list's style. Modifying the returned style may not have an effect until {@link #setStyle(ListStyle)} is * called. */ public ListStyle getStyle () { return style; } public void layout () { BitmapFont font = style.font; Drawable selectedDrawable = style.selection; itemHeight = font.getCapHeight() - font.getDescent() * 2; itemHeight += selectedDrawable.getTopHeight() + selectedDrawable.getBottomHeight(); prefWidth = 0; Pool<GlyphLayout> layoutPool = Pools.get(GlyphLayout.class); GlyphLayout layout = layoutPool.obtain(); for (int i = 0; i < items.size; i++) { layout.setText(font, toString(items.get(i))); prefWidth = Math.max(layout.width, prefWidth); } layoutPool.free(layout); prefWidth += selectedDrawable.getLeftWidth() + selectedDrawable.getRightWidth(); prefHeight = items.size * itemHeight; Drawable background = style.background; if (background != null) { prefWidth = Math.max(prefWidth + background.getLeftWidth() + background.getRightWidth(), background.getMinWidth()); prefHeight = Math.max(prefHeight + background.getTopHeight() + background.getBottomHeight(), background.getMinHeight()); } } public void draw (Batch batch, float parentAlpha) { validate(); drawBackground(batch, parentAlpha); BitmapFont font = style.font; Drawable selectedDrawable = style.selection; Color fontColorSelected = style.fontColorSelected; Color fontColorUnselected = style.fontColorUnselected; Color color = getColor(); batch.setColor(color.r, color.g, color.b, color.a * parentAlpha); float x = getX(), y = getY(), width = getWidth(), height = getHeight(); float itemY = height; Drawable background = style.background; if (background != null) { float leftWidth = background.getLeftWidth(); x += leftWidth; itemY -= background.getTopHeight(); width -= leftWidth + background.getRightWidth(); } float textOffsetX = selectedDrawable.getLeftWidth(), textWidth = width - textOffsetX - selectedDrawable.getRightWidth(); float textOffsetY = selectedDrawable.getTopHeight() - font.getDescent(); font.setColor(fontColorUnselected.r, fontColorUnselected.g, fontColorUnselected.b, fontColorUnselected.a * parentAlpha); for (int i = 0; i < items.size; i++) { if (cullingArea == null || (itemY - itemHeight <= cullingArea.y + cullingArea.height && itemY >= cullingArea.y)) { T item = items.get(i); boolean selected = selection.contains(item); Drawable drawable = null; if (pressedIndex == i && style.down != null) drawable = style.down; else if (selected) { drawable = selectedDrawable; font.setColor(fontColorSelected.r, fontColorSelected.g, fontColorSelected.b, fontColorSelected.a * parentAlpha); } else if (overIndex == i && style.over != null) // drawable = style.over; drawSelection(batch, drawable, x, y + itemY - itemHeight, width, itemHeight); drawItem(batch, font, i, item, x + textOffsetX, y + itemY - textOffsetY, textWidth); if (selected) { font.setColor(fontColorUnselected.r, fontColorUnselected.g, fontColorUnselected.b, fontColorUnselected.a * parentAlpha); } } else if (itemY < cullingArea.y) { break; } itemY -= itemHeight; } } protected void drawSelection (Batch batch, @Null Drawable drawable, float x, float y, float width, float height) { if (drawable != null) drawable.draw(batch, x, y, width, height); } /** Called to draw the background. Default implementation draws the style background drawable. */ protected void drawBackground (Batch batch, float parentAlpha) { if (style.background != null) { Color color = getColor(); batch.setColor(color.r, color.g, color.b, color.a * parentAlpha); style.background.draw(batch, getX(), getY(), getWidth(), getHeight()); } } protected GlyphLayout drawItem (Batch batch, BitmapFont font, int index, T item, float x, float y, float width) { String string = toString(item); return font.draw(batch, string, x, y, 0, string.length(), width, alignment, false, "..."); } public ArraySelection<T> getSelection () { return selection; } public void setSelection (ArraySelection<T> selection) { this.selection = selection; } /** Returns the first selected item, or null. */ public @Null T getSelected () { return selection.first(); } /** Sets the selection to only the passed item, if it is a possible choice. * @param item May be null. */ public void setSelected (@Null T item) { if (items.contains(item, false)) selection.set(item); else if (selection.getRequired() && items.size > 0) selection.set(items.first()); else selection.clear(); } /** @return The index of the first selected item. The top item has an index of 0. Nothing selected has an index of -1. */ public int getSelectedIndex () { ObjectSet<T> selected = selection.items(); return selected.size == 0 ? -1 : items.indexOf(selected.first(), false); } /** Sets the selection to only the selected index. * @param index -1 to clear the selection. */ public void setSelectedIndex (int index) { if (index < -1 || index >= items.size) throw new IllegalArgumentException("index must be >= -1 and < " + items.size + ": " + index); if (index == -1) { selection.clear(); } else { selection.set(items.get(index)); } } /** @return May be null. */ public T getOverItem () { return overIndex == -1 ? null : items.get(overIndex); } /** @return May be null. */ public T getPressedItem () { return pressedIndex == -1 ? null : items.get(pressedIndex); } /** @return null if not over an item. */ public @Null T getItemAt (float y) { int index = getItemIndexAt(y); if (index == -1) return null; return items.get(index); } /** @return -1 if not over an item. */ public int getItemIndexAt (float y) { float height = getHeight(); Drawable background = List.this.style.background; if (background != null) { height -= background.getTopHeight() + background.getBottomHeight(); y -= background.getBottomHeight(); } int index = (int)((height - y) / itemHeight); if (index < 0 || index >= items.size) return -1; return index; } public void setItems (T... newItems) { if (newItems == null) throw new IllegalArgumentException("newItems cannot be null."); float oldPrefWidth = getPrefWidth(), oldPrefHeight = getPrefHeight(); items.clear(); items.addAll(newItems); overIndex = -1; pressedIndex = -1; selection.validate(); invalidate(); if (oldPrefWidth != getPrefWidth() || oldPrefHeight != getPrefHeight()) invalidateHierarchy(); } /** Sets the items visible in the list, clearing the selection if it is no longer valid. If a selection is * {@link ArraySelection#getRequired()}, the first item is selected. This can safely be called with a (modified) array returned * from {@link #getItems()}. */ public void setItems (Array newItems) { if (newItems == null) throw new IllegalArgumentException("newItems cannot be null."); float oldPrefWidth = getPrefWidth(), oldPrefHeight = getPrefHeight(); if (newItems != items) { items.clear(); items.addAll(newItems); } overIndex = -1; pressedIndex = -1; selection.validate(); invalidate(); if (oldPrefWidth != getPrefWidth() || oldPrefHeight != getPrefHeight()) invalidateHierarchy(); } public void clearItems () { if (items.size == 0) return; items.clear(); overIndex = -1; pressedIndex = -1; selection.clear(); invalidateHierarchy(); } /** Returns the internal items array. If modified, {@link #setItems(Array)} must be called to reflect the changes. */ public Array<T> getItems () { return items; } public float getItemHeight () { return itemHeight; } public float getPrefWidth () { validate(); return prefWidth; } public float getPrefHeight () { validate(); return prefHeight; } public String toString (T object) { return object.toString(); } public void setCullingArea (@Null Rectangle cullingArea) { this.cullingArea = cullingArea; } /** @return May be null. * @see #setCullingArea(Rectangle) */ public Rectangle getCullingArea () { return cullingArea; } /** Sets the horizontal alignment of the list items. * @param alignment See {@link Align}. */ public void setAlignment (int alignment) { this.alignment = alignment; } public int getAlignment () { return alignment; } public void setTypeToSelect (boolean typeToSelect) { this.typeToSelect = typeToSelect; } public InputListener getKeyListener () { return keyListener; } /** The style for a list, see {@link List}. * @author mzechner * @author Nathan Sweet */ static public class ListStyle { public BitmapFont font; public Color fontColorSelected = new Color(1, 1, 1, 1); public Color fontColorUnselected = new Color(1, 1, 1, 1); public Drawable selection; public @Null Drawable down, over, background; public ListStyle () { } public ListStyle (BitmapFont font, Color fontColorSelected, Color fontColorUnselected, Drawable selection) { this.font = font; this.fontColorSelected.set(fontColorSelected); this.fontColorUnselected.set(fontColorUnselected); this.selection = selection; } public ListStyle (ListStyle style) { font = style.font; fontColorSelected.set(style.fontColorSelected); fontColorUnselected.set(style.fontColorUnselected); selection = style.selection; down = style.down; over = style.over; background = style.background; } } }
/******************************************************************************* * Copyright 2011 See AUTHORS file. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. ******************************************************************************/ package com.badlogic.gdx.scenes.scene2d.ui; import com.badlogic.gdx.Input.Keys; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.g2d.Batch; import com.badlogic.gdx.graphics.g2d.BitmapFont; import com.badlogic.gdx.graphics.g2d.GlyphLayout; import com.badlogic.gdx.math.Rectangle; import com.badlogic.gdx.scenes.scene2d.Actor; import com.badlogic.gdx.scenes.scene2d.InputEvent; import com.badlogic.gdx.scenes.scene2d.InputListener; import com.badlogic.gdx.scenes.scene2d.utils.ArraySelection; import com.badlogic.gdx.scenes.scene2d.utils.ChangeListener.ChangeEvent; import com.badlogic.gdx.scenes.scene2d.utils.Cullable; import com.badlogic.gdx.scenes.scene2d.utils.Drawable; import com.badlogic.gdx.scenes.scene2d.utils.UIUtils; import com.badlogic.gdx.utils.Align; import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.Null; import com.badlogic.gdx.utils.ObjectSet; import com.badlogic.gdx.utils.Pool; import com.badlogic.gdx.utils.Pools; /** A list (aka list box) displays textual items and highlights the currently selected item. * <p> * {@link ChangeEvent} is fired when the list selection changes. * <p> * The preferred size of the list is determined by the text bounds of the items and the size of the {@link ListStyle#selection}. * @author mzechner * @author Nathan Sweet */ public class List<T> extends Widget implements Cullable { ListStyle style; final Array<T> items = new Array(); ArraySelection<T> selection = new ArraySelection(items); private Rectangle cullingArea; private float prefWidth, prefHeight; float itemHeight; private int alignment = Align.left; int pressedIndex = -1, overIndex = -1; private InputListener keyListener; boolean typeToSelect; public List (Skin skin) { this(skin.get(ListStyle.class)); } public List (Skin skin, String styleName) { this(skin.get(styleName, ListStyle.class)); } public List (ListStyle style) { selection.setActor(this); selection.setRequired(true); setStyle(style); setSize(getPrefWidth(), getPrefHeight()); addListener(keyListener = new InputListener() { long typeTimeout; String prefix; public boolean keyDown (InputEvent event, int keycode) { if (items.isEmpty()) return false; int index; switch (keycode) { case Keys.A: if (UIUtils.ctrl() && selection.getMultiple()) { selection.clear(); selection.addAll(items); return true; } break; case Keys.HOME: setSelectedIndex(0); return true; case Keys.END: setSelectedIndex(items.size - 1); return true; case Keys.DOWN: index = items.indexOf(getSelected(), false) + 1; if (index >= items.size) index = 0; setSelectedIndex(index); return true; case Keys.UP: index = items.indexOf(getSelected(), false) - 1; if (index < 0) index = items.size - 1; setSelectedIndex(index); return true; case Keys.ESCAPE: if (getStage() != null) getStage().setKeyboardFocus(null); return true; } return false; } public boolean keyTyped (InputEvent event, char character) { if (!typeToSelect) return false; long time = System.currentTimeMillis(); if (time > typeTimeout) prefix = ""; typeTimeout = time + 300; prefix += Character.toLowerCase(character); for (int i = 0, n = items.size; i < n; i++) { if (List.this.toString(items.get(i)).toLowerCase().startsWith(prefix)) { setSelectedIndex(i); break; } } return false; } }); addListener(new InputListener() { public boolean touchDown (InputEvent event, float x, float y, int pointer, int button) { if (pointer != 0 || button != 0) return true; if (selection.isDisabled()) return true; if (getStage() != null) getStage().setKeyboardFocus(List.this); if (items.size == 0) return true; int index = getItemIndexAt(y); if (index == -1) return true; selection.choose(items.get(index)); pressedIndex = index; return true; } public void touchUp (InputEvent event, float x, float y, int pointer, int button) { if (pointer != 0 || button != 0) return; pressedIndex = -1; } public void touchDragged (InputEvent event, float x, float y, int pointer) { overIndex = getItemIndexAt(y); } public boolean mouseMoved (InputEvent event, float x, float y) { overIndex = getItemIndexAt(y); return false; } public void exit (InputEvent event, float x, float y, int pointer, Actor toActor) { if (pointer == 0) pressedIndex = -1; if (pointer == -1) overIndex = -1; } }); } public void setStyle (ListStyle style) { if (style == null) throw new IllegalArgumentException("style cannot be null."); this.style = style; invalidateHierarchy(); } /** Returns the list's style. Modifying the returned style may not have an effect until {@link #setStyle(ListStyle)} is * called. */ public ListStyle getStyle () { return style; } public void layout () { BitmapFont font = style.font; Drawable selectedDrawable = style.selection; itemHeight = font.getCapHeight() - font.getDescent() * 2; itemHeight += selectedDrawable.getTopHeight() + selectedDrawable.getBottomHeight(); prefWidth = 0; Pool<GlyphLayout> layoutPool = Pools.get(GlyphLayout.class); GlyphLayout layout = layoutPool.obtain(); for (int i = 0; i < items.size; i++) { layout.setText(font, toString(items.get(i))); prefWidth = Math.max(layout.width, prefWidth); } layoutPool.free(layout); prefWidth += selectedDrawable.getLeftWidth() + selectedDrawable.getRightWidth(); prefHeight = items.size * itemHeight; Drawable background = style.background; if (background != null) { prefWidth = Math.max(prefWidth + background.getLeftWidth() + background.getRightWidth(), background.getMinWidth()); prefHeight = Math.max(prefHeight + background.getTopHeight() + background.getBottomHeight(), background.getMinHeight()); } } public void draw (Batch batch, float parentAlpha) { validate(); drawBackground(batch, parentAlpha); BitmapFont font = style.font; Drawable selectedDrawable = style.selection; Color fontColorSelected = style.fontColorSelected; Color fontColorUnselected = style.fontColorUnselected; Color color = getColor(); batch.setColor(color.r, color.g, color.b, color.a * parentAlpha); float x = getX(), y = getY(), width = getWidth(), height = getHeight(); float itemY = height; Drawable background = style.background; if (background != null) { float leftWidth = background.getLeftWidth(); x += leftWidth; itemY -= background.getTopHeight(); width -= leftWidth + background.getRightWidth(); } float textOffsetX = selectedDrawable.getLeftWidth(), textWidth = width - textOffsetX - selectedDrawable.getRightWidth(); float textOffsetY = selectedDrawable.getTopHeight() - font.getDescent(); font.setColor(fontColorUnselected.r, fontColorUnselected.g, fontColorUnselected.b, fontColorUnselected.a * parentAlpha); for (int i = 0; i < items.size; i++) { if (cullingArea == null || (itemY - itemHeight <= cullingArea.y + cullingArea.height && itemY >= cullingArea.y)) { T item = items.get(i); boolean selected = selection.contains(item); Drawable drawable = null; if (pressedIndex == i && style.down != null) drawable = style.down; else if (selected) { drawable = selectedDrawable; font.setColor(fontColorSelected.r, fontColorSelected.g, fontColorSelected.b, fontColorSelected.a * parentAlpha); } else if (overIndex == i && style.over != null) // drawable = style.over; drawSelection(batch, drawable, x, y + itemY - itemHeight, width, itemHeight); drawItem(batch, font, i, item, x + textOffsetX, y + itemY - textOffsetY, textWidth); if (selected) { font.setColor(fontColorUnselected.r, fontColorUnselected.g, fontColorUnselected.b, fontColorUnselected.a * parentAlpha); } } else if (itemY < cullingArea.y) { break; } itemY -= itemHeight; } } protected void drawSelection (Batch batch, @Null Drawable drawable, float x, float y, float width, float height) { if (drawable != null) drawable.draw(batch, x, y, width, height); } /** Called to draw the background. Default implementation draws the style background drawable. */ protected void drawBackground (Batch batch, float parentAlpha) { if (style.background != null) { Color color = getColor(); batch.setColor(color.r, color.g, color.b, color.a * parentAlpha); style.background.draw(batch, getX(), getY(), getWidth(), getHeight()); } } protected GlyphLayout drawItem (Batch batch, BitmapFont font, int index, T item, float x, float y, float width) { String string = toString(item); return font.draw(batch, string, x, y, 0, string.length(), width, alignment, false, "..."); } public ArraySelection<T> getSelection () { return selection; } public void setSelection (ArraySelection<T> selection) { this.selection = selection; } /** Returns the first selected item, or null. */ public @Null T getSelected () { return selection.first(); } /** Sets the selection to only the passed item, if it is a possible choice. * @param item May be null. */ public void setSelected (@Null T item) { if (items.contains(item, false)) selection.set(item); else if (selection.getRequired() && items.size > 0) selection.set(items.first()); else selection.clear(); } /** @return The index of the first selected item. The top item has an index of 0. Nothing selected has an index of -1. */ public int getSelectedIndex () { ObjectSet<T> selected = selection.items(); return selected.size == 0 ? -1 : items.indexOf(selected.first(), false); } /** Sets the selection to only the selected index. * @param index -1 to clear the selection. */ public void setSelectedIndex (int index) { if (index < -1 || index >= items.size) throw new IllegalArgumentException("index must be >= -1 and < " + items.size + ": " + index); if (index == -1) { selection.clear(); } else { selection.set(items.get(index)); } } /** @return May be null. */ public T getOverItem () { return overIndex == -1 ? null : items.get(overIndex); } /** @return May be null. */ public T getPressedItem () { return pressedIndex == -1 ? null : items.get(pressedIndex); } /** @return null if not over an item. */ public @Null T getItemAt (float y) { int index = getItemIndexAt(y); if (index == -1) return null; return items.get(index); } /** @return -1 if not over an item. */ public int getItemIndexAt (float y) { float height = getHeight(); Drawable background = List.this.style.background; if (background != null) { height -= background.getTopHeight() + background.getBottomHeight(); y -= background.getBottomHeight(); } int index = (int)((height - y) / itemHeight); if (index < 0 || index >= items.size) return -1; return index; } public void setItems (T... newItems) { if (newItems == null) throw new IllegalArgumentException("newItems cannot be null."); float oldPrefWidth = getPrefWidth(), oldPrefHeight = getPrefHeight(); items.clear(); items.addAll(newItems); overIndex = -1; pressedIndex = -1; selection.validate(); invalidate(); if (oldPrefWidth != getPrefWidth() || oldPrefHeight != getPrefHeight()) invalidateHierarchy(); } /** Sets the items visible in the list, clearing the selection if it is no longer valid. If a selection is * {@link ArraySelection#getRequired()}, the first item is selected. This can safely be called with a (modified) array returned * from {@link #getItems()}. */ public void setItems (Array newItems) { if (newItems == null) throw new IllegalArgumentException("newItems cannot be null."); float oldPrefWidth = getPrefWidth(), oldPrefHeight = getPrefHeight(); if (newItems != items) { items.clear(); items.addAll(newItems); } overIndex = -1; pressedIndex = -1; selection.validate(); invalidate(); if (oldPrefWidth != getPrefWidth() || oldPrefHeight != getPrefHeight()) invalidateHierarchy(); } public void clearItems () { if (items.size == 0) return; items.clear(); overIndex = -1; pressedIndex = -1; selection.clear(); invalidateHierarchy(); } /** Returns the internal items array. If modified, {@link #setItems(Array)} must be called to reflect the changes. */ public Array<T> getItems () { return items; } public float getItemHeight () { return itemHeight; } public float getPrefWidth () { validate(); return prefWidth; } public float getPrefHeight () { validate(); return prefHeight; } public String toString (T object) { return object.toString(); } public void setCullingArea (@Null Rectangle cullingArea) { this.cullingArea = cullingArea; } /** @return May be null. * @see #setCullingArea(Rectangle) */ public Rectangle getCullingArea () { return cullingArea; } /** Sets the horizontal alignment of the list items. * @param alignment See {@link Align}. */ public void setAlignment (int alignment) { this.alignment = alignment; } public int getAlignment () { return alignment; } public void setTypeToSelect (boolean typeToSelect) { this.typeToSelect = typeToSelect; } public InputListener getKeyListener () { return keyListener; } /** The style for a list, see {@link List}. * @author mzechner * @author Nathan Sweet */ static public class ListStyle { public BitmapFont font; public Color fontColorSelected = new Color(1, 1, 1, 1); public Color fontColorUnselected = new Color(1, 1, 1, 1); public Drawable selection; public @Null Drawable down, over, background; public ListStyle () { } public ListStyle (BitmapFont font, Color fontColorSelected, Color fontColorUnselected, Drawable selection) { this.font = font; this.fontColorSelected.set(fontColorSelected); this.fontColorUnselected.set(fontColorUnselected); this.selection = selection; } public ListStyle (ListStyle style) { font = style.font; fontColorSelected.set(style.fontColorSelected); fontColorUnselected.set(style.fontColorUnselected); selection = style.selection; down = style.down; over = style.over; background = style.background; } } }
-1
libgdx/libgdx
7,250
chore: Update to gwt 2.10.0
I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
SimonIT
"2023-10-06T10:43:44Z"
"2023-11-12T07:23:11Z"
e688cf718d56048bd9ab3e61180b93ee46f399d7
93503b4120f2c6002c7b1ecc73fc36bef4b678a0
chore: Update to gwt 2.10.0. I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
./extensions/gdx-bullet/jni/swig-src/softbody/com/badlogic/gdx/physics/bullet/softbody/SoftBodyConfigData.java
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.softbody; import com.badlogic.gdx.physics.bullet.BulletBase; import com.badlogic.gdx.physics.bullet.linearmath.*; import com.badlogic.gdx.physics.bullet.collision.*; import com.badlogic.gdx.physics.bullet.dynamics.*; public class SoftBodyConfigData extends BulletBase { private long swigCPtr; protected SoftBodyConfigData (final String className, long cPtr, boolean cMemoryOwn) { super(className, cPtr, cMemoryOwn); swigCPtr = cPtr; } /** Construct a new SoftBodyConfigData, normally you should not need this constructor it's intended for low-level usage. */ public SoftBodyConfigData (long cPtr, boolean cMemoryOwn) { this("SoftBodyConfigData", cPtr, cMemoryOwn); construct(); } @Override protected void reset (long cPtr, boolean cMemoryOwn) { if (!destroyed) destroy(); super.reset(swigCPtr = cPtr, cMemoryOwn); } public static long getCPtr (SoftBodyConfigData obj) { return (obj == null) ? 0 : obj.swigCPtr; } @Override protected void finalize () throws Throwable { if (!destroyed) destroy(); super.finalize(); } @Override protected synchronized void delete () { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; SoftbodyJNI.delete_SoftBodyConfigData(swigCPtr); } swigCPtr = 0; } super.delete(); } public void setAeroModel (int value) { SoftbodyJNI.SoftBodyConfigData_aeroModel_set(swigCPtr, this, value); } public int getAeroModel () { return SoftbodyJNI.SoftBodyConfigData_aeroModel_get(swigCPtr, this); } public void setBaumgarte (float value) { SoftbodyJNI.SoftBodyConfigData_baumgarte_set(swigCPtr, this, value); } public float getBaumgarte () { return SoftbodyJNI.SoftBodyConfigData_baumgarte_get(swigCPtr, this); } public void setDamping (float value) { SoftbodyJNI.SoftBodyConfigData_damping_set(swigCPtr, this, value); } public float getDamping () { return SoftbodyJNI.SoftBodyConfigData_damping_get(swigCPtr, this); } public void setDrag (float value) { SoftbodyJNI.SoftBodyConfigData_drag_set(swigCPtr, this, value); } public float getDrag () { return SoftbodyJNI.SoftBodyConfigData_drag_get(swigCPtr, this); } public void setLift (float value) { SoftbodyJNI.SoftBodyConfigData_lift_set(swigCPtr, this, value); } public float getLift () { return SoftbodyJNI.SoftBodyConfigData_lift_get(swigCPtr, this); } public void setPressure (float value) { SoftbodyJNI.SoftBodyConfigData_pressure_set(swigCPtr, this, value); } public float getPressure () { return SoftbodyJNI.SoftBodyConfigData_pressure_get(swigCPtr, this); } public void setVolume (float value) { SoftbodyJNI.SoftBodyConfigData_volume_set(swigCPtr, this, value); } public float getVolume () { return SoftbodyJNI.SoftBodyConfigData_volume_get(swigCPtr, this); } public void setDynamicFriction (float value) { SoftbodyJNI.SoftBodyConfigData_dynamicFriction_set(swigCPtr, this, value); } public float getDynamicFriction () { return SoftbodyJNI.SoftBodyConfigData_dynamicFriction_get(swigCPtr, this); } public void setPoseMatch (float value) { SoftbodyJNI.SoftBodyConfigData_poseMatch_set(swigCPtr, this, value); } public float getPoseMatch () { return SoftbodyJNI.SoftBodyConfigData_poseMatch_get(swigCPtr, this); } public void setRigidContactHardness (float value) { SoftbodyJNI.SoftBodyConfigData_rigidContactHardness_set(swigCPtr, this, value); } public float getRigidContactHardness () { return SoftbodyJNI.SoftBodyConfigData_rigidContactHardness_get(swigCPtr, this); } public void setKineticContactHardness (float value) { SoftbodyJNI.SoftBodyConfigData_kineticContactHardness_set(swigCPtr, this, value); } public float getKineticContactHardness () { return SoftbodyJNI.SoftBodyConfigData_kineticContactHardness_get(swigCPtr, this); } public void setSoftContactHardness (float value) { SoftbodyJNI.SoftBodyConfigData_softContactHardness_set(swigCPtr, this, value); } public float getSoftContactHardness () { return SoftbodyJNI.SoftBodyConfigData_softContactHardness_get(swigCPtr, this); } public void setAnchorHardness (float value) { SoftbodyJNI.SoftBodyConfigData_anchorHardness_set(swigCPtr, this, value); } public float getAnchorHardness () { return SoftbodyJNI.SoftBodyConfigData_anchorHardness_get(swigCPtr, this); } public void setSoftRigidClusterHardness (float value) { SoftbodyJNI.SoftBodyConfigData_softRigidClusterHardness_set(swigCPtr, this, value); } public float getSoftRigidClusterHardness () { return SoftbodyJNI.SoftBodyConfigData_softRigidClusterHardness_get(swigCPtr, this); } public void setSoftKineticClusterHardness (float value) { SoftbodyJNI.SoftBodyConfigData_softKineticClusterHardness_set(swigCPtr, this, value); } public float getSoftKineticClusterHardness () { return SoftbodyJNI.SoftBodyConfigData_softKineticClusterHardness_get(swigCPtr, this); } public void setSoftSoftClusterHardness (float value) { SoftbodyJNI.SoftBodyConfigData_softSoftClusterHardness_set(swigCPtr, this, value); } public float getSoftSoftClusterHardness () { return SoftbodyJNI.SoftBodyConfigData_softSoftClusterHardness_get(swigCPtr, this); } public void setSoftRigidClusterImpulseSplit (float value) { SoftbodyJNI.SoftBodyConfigData_softRigidClusterImpulseSplit_set(swigCPtr, this, value); } public float getSoftRigidClusterImpulseSplit () { return SoftbodyJNI.SoftBodyConfigData_softRigidClusterImpulseSplit_get(swigCPtr, this); } public void setSoftKineticClusterImpulseSplit (float value) { SoftbodyJNI.SoftBodyConfigData_softKineticClusterImpulseSplit_set(swigCPtr, this, value); } public float getSoftKineticClusterImpulseSplit () { return SoftbodyJNI.SoftBodyConfigData_softKineticClusterImpulseSplit_get(swigCPtr, this); } public void setSoftSoftClusterImpulseSplit (float value) { SoftbodyJNI.SoftBodyConfigData_softSoftClusterImpulseSplit_set(swigCPtr, this, value); } public float getSoftSoftClusterImpulseSplit () { return SoftbodyJNI.SoftBodyConfigData_softSoftClusterImpulseSplit_get(swigCPtr, this); } public void setMaxVolume (float value) { SoftbodyJNI.SoftBodyConfigData_maxVolume_set(swigCPtr, this, value); } public float getMaxVolume () { return SoftbodyJNI.SoftBodyConfigData_maxVolume_get(swigCPtr, this); } public void setTimeScale (float value) { SoftbodyJNI.SoftBodyConfigData_timeScale_set(swigCPtr, this, value); } public float getTimeScale () { return SoftbodyJNI.SoftBodyConfigData_timeScale_get(swigCPtr, this); } public void setVelocityIterations (int value) { SoftbodyJNI.SoftBodyConfigData_velocityIterations_set(swigCPtr, this, value); } public int getVelocityIterations () { return SoftbodyJNI.SoftBodyConfigData_velocityIterations_get(swigCPtr, this); } public void setPositionIterations (int value) { SoftbodyJNI.SoftBodyConfigData_positionIterations_set(swigCPtr, this, value); } public int getPositionIterations () { return SoftbodyJNI.SoftBodyConfigData_positionIterations_get(swigCPtr, this); } public void setDriftIterations (int value) { SoftbodyJNI.SoftBodyConfigData_driftIterations_set(swigCPtr, this, value); } public int getDriftIterations () { return SoftbodyJNI.SoftBodyConfigData_driftIterations_get(swigCPtr, this); } public void setClusterIterations (int value) { SoftbodyJNI.SoftBodyConfigData_clusterIterations_set(swigCPtr, this, value); } public int getClusterIterations () { return SoftbodyJNI.SoftBodyConfigData_clusterIterations_get(swigCPtr, this); } public void setCollisionFlags (int value) { SoftbodyJNI.SoftBodyConfigData_collisionFlags_set(swigCPtr, this, value); } public int getCollisionFlags () { return SoftbodyJNI.SoftBodyConfigData_collisionFlags_get(swigCPtr, this); } public SoftBodyConfigData () { this(SoftbodyJNI.new_SoftBodyConfigData(), true); } }
/* ---------------------------------------------------------------------------- * This file was automatically generated by SWIG (http://www.swig.org). * Version 3.0.11 * * Do not make changes to this file unless you know what you are doing--modify * the SWIG interface file instead. * ----------------------------------------------------------------------------- */ package com.badlogic.gdx.physics.bullet.softbody; import com.badlogic.gdx.physics.bullet.BulletBase; import com.badlogic.gdx.physics.bullet.linearmath.*; import com.badlogic.gdx.physics.bullet.collision.*; import com.badlogic.gdx.physics.bullet.dynamics.*; public class SoftBodyConfigData extends BulletBase { private long swigCPtr; protected SoftBodyConfigData (final String className, long cPtr, boolean cMemoryOwn) { super(className, cPtr, cMemoryOwn); swigCPtr = cPtr; } /** Construct a new SoftBodyConfigData, normally you should not need this constructor it's intended for low-level usage. */ public SoftBodyConfigData (long cPtr, boolean cMemoryOwn) { this("SoftBodyConfigData", cPtr, cMemoryOwn); construct(); } @Override protected void reset (long cPtr, boolean cMemoryOwn) { if (!destroyed) destroy(); super.reset(swigCPtr = cPtr, cMemoryOwn); } public static long getCPtr (SoftBodyConfigData obj) { return (obj == null) ? 0 : obj.swigCPtr; } @Override protected void finalize () throws Throwable { if (!destroyed) destroy(); super.finalize(); } @Override protected synchronized void delete () { if (swigCPtr != 0) { if (swigCMemOwn) { swigCMemOwn = false; SoftbodyJNI.delete_SoftBodyConfigData(swigCPtr); } swigCPtr = 0; } super.delete(); } public void setAeroModel (int value) { SoftbodyJNI.SoftBodyConfigData_aeroModel_set(swigCPtr, this, value); } public int getAeroModel () { return SoftbodyJNI.SoftBodyConfigData_aeroModel_get(swigCPtr, this); } public void setBaumgarte (float value) { SoftbodyJNI.SoftBodyConfigData_baumgarte_set(swigCPtr, this, value); } public float getBaumgarte () { return SoftbodyJNI.SoftBodyConfigData_baumgarte_get(swigCPtr, this); } public void setDamping (float value) { SoftbodyJNI.SoftBodyConfigData_damping_set(swigCPtr, this, value); } public float getDamping () { return SoftbodyJNI.SoftBodyConfigData_damping_get(swigCPtr, this); } public void setDrag (float value) { SoftbodyJNI.SoftBodyConfigData_drag_set(swigCPtr, this, value); } public float getDrag () { return SoftbodyJNI.SoftBodyConfigData_drag_get(swigCPtr, this); } public void setLift (float value) { SoftbodyJNI.SoftBodyConfigData_lift_set(swigCPtr, this, value); } public float getLift () { return SoftbodyJNI.SoftBodyConfigData_lift_get(swigCPtr, this); } public void setPressure (float value) { SoftbodyJNI.SoftBodyConfigData_pressure_set(swigCPtr, this, value); } public float getPressure () { return SoftbodyJNI.SoftBodyConfigData_pressure_get(swigCPtr, this); } public void setVolume (float value) { SoftbodyJNI.SoftBodyConfigData_volume_set(swigCPtr, this, value); } public float getVolume () { return SoftbodyJNI.SoftBodyConfigData_volume_get(swigCPtr, this); } public void setDynamicFriction (float value) { SoftbodyJNI.SoftBodyConfigData_dynamicFriction_set(swigCPtr, this, value); } public float getDynamicFriction () { return SoftbodyJNI.SoftBodyConfigData_dynamicFriction_get(swigCPtr, this); } public void setPoseMatch (float value) { SoftbodyJNI.SoftBodyConfigData_poseMatch_set(swigCPtr, this, value); } public float getPoseMatch () { return SoftbodyJNI.SoftBodyConfigData_poseMatch_get(swigCPtr, this); } public void setRigidContactHardness (float value) { SoftbodyJNI.SoftBodyConfigData_rigidContactHardness_set(swigCPtr, this, value); } public float getRigidContactHardness () { return SoftbodyJNI.SoftBodyConfigData_rigidContactHardness_get(swigCPtr, this); } public void setKineticContactHardness (float value) { SoftbodyJNI.SoftBodyConfigData_kineticContactHardness_set(swigCPtr, this, value); } public float getKineticContactHardness () { return SoftbodyJNI.SoftBodyConfigData_kineticContactHardness_get(swigCPtr, this); } public void setSoftContactHardness (float value) { SoftbodyJNI.SoftBodyConfigData_softContactHardness_set(swigCPtr, this, value); } public float getSoftContactHardness () { return SoftbodyJNI.SoftBodyConfigData_softContactHardness_get(swigCPtr, this); } public void setAnchorHardness (float value) { SoftbodyJNI.SoftBodyConfigData_anchorHardness_set(swigCPtr, this, value); } public float getAnchorHardness () { return SoftbodyJNI.SoftBodyConfigData_anchorHardness_get(swigCPtr, this); } public void setSoftRigidClusterHardness (float value) { SoftbodyJNI.SoftBodyConfigData_softRigidClusterHardness_set(swigCPtr, this, value); } public float getSoftRigidClusterHardness () { return SoftbodyJNI.SoftBodyConfigData_softRigidClusterHardness_get(swigCPtr, this); } public void setSoftKineticClusterHardness (float value) { SoftbodyJNI.SoftBodyConfigData_softKineticClusterHardness_set(swigCPtr, this, value); } public float getSoftKineticClusterHardness () { return SoftbodyJNI.SoftBodyConfigData_softKineticClusterHardness_get(swigCPtr, this); } public void setSoftSoftClusterHardness (float value) { SoftbodyJNI.SoftBodyConfigData_softSoftClusterHardness_set(swigCPtr, this, value); } public float getSoftSoftClusterHardness () { return SoftbodyJNI.SoftBodyConfigData_softSoftClusterHardness_get(swigCPtr, this); } public void setSoftRigidClusterImpulseSplit (float value) { SoftbodyJNI.SoftBodyConfigData_softRigidClusterImpulseSplit_set(swigCPtr, this, value); } public float getSoftRigidClusterImpulseSplit () { return SoftbodyJNI.SoftBodyConfigData_softRigidClusterImpulseSplit_get(swigCPtr, this); } public void setSoftKineticClusterImpulseSplit (float value) { SoftbodyJNI.SoftBodyConfigData_softKineticClusterImpulseSplit_set(swigCPtr, this, value); } public float getSoftKineticClusterImpulseSplit () { return SoftbodyJNI.SoftBodyConfigData_softKineticClusterImpulseSplit_get(swigCPtr, this); } public void setSoftSoftClusterImpulseSplit (float value) { SoftbodyJNI.SoftBodyConfigData_softSoftClusterImpulseSplit_set(swigCPtr, this, value); } public float getSoftSoftClusterImpulseSplit () { return SoftbodyJNI.SoftBodyConfigData_softSoftClusterImpulseSplit_get(swigCPtr, this); } public void setMaxVolume (float value) { SoftbodyJNI.SoftBodyConfigData_maxVolume_set(swigCPtr, this, value); } public float getMaxVolume () { return SoftbodyJNI.SoftBodyConfigData_maxVolume_get(swigCPtr, this); } public void setTimeScale (float value) { SoftbodyJNI.SoftBodyConfigData_timeScale_set(swigCPtr, this, value); } public float getTimeScale () { return SoftbodyJNI.SoftBodyConfigData_timeScale_get(swigCPtr, this); } public void setVelocityIterations (int value) { SoftbodyJNI.SoftBodyConfigData_velocityIterations_set(swigCPtr, this, value); } public int getVelocityIterations () { return SoftbodyJNI.SoftBodyConfigData_velocityIterations_get(swigCPtr, this); } public void setPositionIterations (int value) { SoftbodyJNI.SoftBodyConfigData_positionIterations_set(swigCPtr, this, value); } public int getPositionIterations () { return SoftbodyJNI.SoftBodyConfigData_positionIterations_get(swigCPtr, this); } public void setDriftIterations (int value) { SoftbodyJNI.SoftBodyConfigData_driftIterations_set(swigCPtr, this, value); } public int getDriftIterations () { return SoftbodyJNI.SoftBodyConfigData_driftIterations_get(swigCPtr, this); } public void setClusterIterations (int value) { SoftbodyJNI.SoftBodyConfigData_clusterIterations_set(swigCPtr, this, value); } public int getClusterIterations () { return SoftbodyJNI.SoftBodyConfigData_clusterIterations_get(swigCPtr, this); } public void setCollisionFlags (int value) { SoftbodyJNI.SoftBodyConfigData_collisionFlags_set(swigCPtr, this, value); } public int getCollisionFlags () { return SoftbodyJNI.SoftBodyConfigData_collisionFlags_get(swigCPtr, this); } public SoftBodyConfigData () { this(SoftbodyJNI.new_SoftBodyConfigData(), true); } }
-1
libgdx/libgdx
7,250
chore: Update to gwt 2.10.0
I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
SimonIT
"2023-10-06T10:43:44Z"
"2023-11-12T07:23:11Z"
e688cf718d56048bd9ab3e61180b93ee46f399d7
93503b4120f2c6002c7b1ecc73fc36bef4b678a0
chore: Update to gwt 2.10.0. I don't know why there's no dtd for 2.10.0, so I chose the dtd from 2.9.0
./extensions/gdx-box2d/gdx-box2d-gwt/src/com/badlogic/gdx/physics/box2d/gwt/emu/org/jbox2d/dynamics/contacts/EdgeAndCircleContact.java
/******************************************************************************* * Copyright (c) 2013, Daniel Murphy * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. ******************************************************************************/ package org.jbox2d.dynamics.contacts; import org.jbox2d.collision.Manifold; import org.jbox2d.collision.shapes.CircleShape; import org.jbox2d.collision.shapes.EdgeShape; import org.jbox2d.collision.shapes.ShapeType; import org.jbox2d.common.Transform; import org.jbox2d.dynamics.Fixture; import org.jbox2d.pooling.IWorldPool; public class EdgeAndCircleContact extends Contact { public EdgeAndCircleContact (IWorldPool argPool) { super(argPool); } @Override public void init (Fixture fA, int indexA, Fixture fB, int indexB) { super.init(fA, indexA, fB, indexB); assert (m_fixtureA.getType() == ShapeType.EDGE); assert (m_fixtureB.getType() == ShapeType.CIRCLE); } @Override public void evaluate (Manifold manifold, Transform xfA, Transform xfB) { pool.getCollision().collideEdgeAndCircle(manifold, (EdgeShape)m_fixtureA.getShape(), xfA, (CircleShape)m_fixtureB.getShape(), xfB); } }
/******************************************************************************* * Copyright (c) 2013, Daniel Murphy * All rights reserved. * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * * Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * * Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. * IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. ******************************************************************************/ package org.jbox2d.dynamics.contacts; import org.jbox2d.collision.Manifold; import org.jbox2d.collision.shapes.CircleShape; import org.jbox2d.collision.shapes.EdgeShape; import org.jbox2d.collision.shapes.ShapeType; import org.jbox2d.common.Transform; import org.jbox2d.dynamics.Fixture; import org.jbox2d.pooling.IWorldPool; public class EdgeAndCircleContact extends Contact { public EdgeAndCircleContact (IWorldPool argPool) { super(argPool); } @Override public void init (Fixture fA, int indexA, Fixture fB, int indexB) { super.init(fA, indexA, fB, indexB); assert (m_fixtureA.getType() == ShapeType.EDGE); assert (m_fixtureB.getType() == ShapeType.CIRCLE); } @Override public void evaluate (Manifold manifold, Transform xfA, Transform xfB) { pool.getCollision().collideEdgeAndCircle(manifold, (EdgeShape)m_fixtureA.getShape(), xfA, (CircleShape)m_fixtureB.getShape(), xfB); } }
-1