From 35fedba2c654454f954f8d3191caaedb0cd6003f Mon Sep 17 00:00:00 2001 From: OneAvargeCoder193 <85588535+OneAvargeCoder193@users.noreply.github.com> Date: Wed, 12 Mar 2025 13:27:28 -0400 Subject: [PATCH] Change branches so that the textures can be rotated (#1183) * add pipes, which are like branches but you can have different textures on each mode * fix formatting * remove testing block * fix more formatting issues * fix more formatting issues * simplify fromRelPos * fix fromRelPos and give pipe same properties as branch * fix flashing dots caused by floating point inaccuracies * remove debug object * fix formatting issues * fix a couple things * remove debug textures * fix formatting and also make dir an enum * fix more formatting issues * remove branches * rename pipe to branch * remove floating point fix * remove branch model * Add back branches and add temporary textures * add back the branches * fix some stuff * small changes * fix compiler error --------- Co-authored-by: Carrie --- assets/cubyz/blocks/baobab_branch.zig.zon | 11 +- assets/cubyz/blocks/birch_branch.zig.zon | 11 +- assets/cubyz/blocks/cactus_arm.zig.zon | 11 +- assets/cubyz/blocks/mahogany_branch.zig.zon | 11 +- assets/cubyz/blocks/oak_branch.zig.zon | 11 +- assets/cubyz/blocks/pine_branch.zig.zon | 11 +- .../blocks/textures/branch/baobab/bend.png | Bin 0 -> 331 bytes .../blocks/textures/branch/baobab/cross.png | Bin 0 -> 407 bytes .../blocks/textures/branch/baobab/dot.png | Bin 0 -> 226 bytes .../textures/branch/baobab/half_line.png | Bin 0 -> 280 bytes .../textures/branch/baobab/intersection.png | Bin 0 -> 360 bytes .../blocks/textures/branch/baobab/line.png | Bin 0 -> 327 bytes .../blocks/textures/branch/birch/bend.png | Bin 0 -> 341 bytes .../blocks/textures/branch/birch/cross.png | Bin 0 -> 420 bytes .../blocks/textures/branch/birch/dot.png | Bin 0 -> 248 bytes .../textures/branch/birch/half_line.png | Bin 0 -> 292 bytes .../textures/branch/birch/intersection.png | Bin 0 -> 377 bytes .../blocks/textures/branch/birch/line.png | Bin 0 -> 351 bytes .../blocks/textures/branch/cactus/bend.png | Bin 0 -> 322 bytes .../blocks/textures/branch/cactus/cross.png | Bin 0 -> 385 bytes .../blocks/textures/branch/cactus/dot.png | Bin 0 -> 220 bytes .../textures/branch/cactus/half_line.png | Bin 0 -> 265 bytes .../textures/branch/cactus/intersection.png | Bin 0 -> 345 bytes .../blocks/textures/branch/cactus/line.png | Bin 0 -> 299 bytes .../blocks/textures/branch/mahogany/bend.png | Bin 0 -> 372 bytes .../blocks/textures/branch/mahogany/cross.png | Bin 0 -> 459 bytes .../blocks/textures/branch/mahogany/dot.png | Bin 0 -> 244 bytes .../textures/branch/mahogany/half_line.png | Bin 0 -> 303 bytes .../textures/branch/mahogany/intersection.png | Bin 0 -> 385 bytes .../blocks/textures/branch/mahogany/line.png | Bin 0 -> 354 bytes .../cubyz/blocks/textures/branch/oak/bend.png | Bin 0 -> 357 bytes .../blocks/textures/branch/oak/cross.png | Bin 0 -> 430 bytes .../cubyz/blocks/textures/branch/oak/dot.png | Bin 0 -> 223 bytes .../blocks/textures/branch/oak/half_line.png | Bin 0 -> 266 bytes .../textures/branch/oak/intersection.png | Bin 0 -> 373 bytes .../cubyz/blocks/textures/branch/oak/line.png | Bin 0 -> 327 bytes .../blocks/textures/branch/pine/bend.png | Bin 0 -> 318 bytes .../blocks/textures/branch/pine/cross.png | Bin 0 -> 405 bytes .../cubyz/blocks/textures/branch/pine/dot.png | Bin 0 -> 226 bytes .../blocks/textures/branch/pine/half_line.png | Bin 0 -> 273 bytes .../textures/branch/pine/intersection.png | Bin 0 -> 355 bytes .../blocks/textures/branch/pine/line.png | Bin 0 -> 316 bytes .../blocks/textures/branch/willow/bend.png | Bin 0 -> 301 bytes .../blocks/textures/branch/willow/cross.png | Bin 0 -> 368 bytes .../blocks/textures/branch/willow/dot.png | Bin 0 -> 203 bytes .../textures/branch/willow/half_line.png | Bin 0 -> 244 bytes .../textures/branch/willow/intersection.png | Bin 0 -> 317 bytes .../blocks/textures/branch/willow/line.png | Bin 0 -> 287 bytes assets/cubyz/blocks/willow_branch.zig.zon | 11 +- assets/cubyz/models/branch.obj | 237 ----------------- src/chunk.zig | 20 ++ src/rotation.zig | 240 ++++++++++++++++-- src/vec.zig | 13 + 53 files changed, 315 insertions(+), 272 deletions(-) create mode 100644 assets/cubyz/blocks/textures/branch/baobab/bend.png create mode 100644 assets/cubyz/blocks/textures/branch/baobab/cross.png create mode 100644 assets/cubyz/blocks/textures/branch/baobab/dot.png create mode 100644 assets/cubyz/blocks/textures/branch/baobab/half_line.png create mode 100644 assets/cubyz/blocks/textures/branch/baobab/intersection.png create mode 100644 assets/cubyz/blocks/textures/branch/baobab/line.png create mode 100644 assets/cubyz/blocks/textures/branch/birch/bend.png create mode 100644 assets/cubyz/blocks/textures/branch/birch/cross.png create mode 100644 assets/cubyz/blocks/textures/branch/birch/dot.png create mode 100644 assets/cubyz/blocks/textures/branch/birch/half_line.png create mode 100644 assets/cubyz/blocks/textures/branch/birch/intersection.png create mode 100644 assets/cubyz/blocks/textures/branch/birch/line.png create mode 100644 assets/cubyz/blocks/textures/branch/cactus/bend.png create mode 100644 assets/cubyz/blocks/textures/branch/cactus/cross.png create mode 100644 assets/cubyz/blocks/textures/branch/cactus/dot.png create mode 100644 assets/cubyz/blocks/textures/branch/cactus/half_line.png create mode 100644 assets/cubyz/blocks/textures/branch/cactus/intersection.png create mode 100644 assets/cubyz/blocks/textures/branch/cactus/line.png create mode 100644 assets/cubyz/blocks/textures/branch/mahogany/bend.png create mode 100644 assets/cubyz/blocks/textures/branch/mahogany/cross.png create mode 100644 assets/cubyz/blocks/textures/branch/mahogany/dot.png create mode 100644 assets/cubyz/blocks/textures/branch/mahogany/half_line.png create mode 100644 assets/cubyz/blocks/textures/branch/mahogany/intersection.png create mode 100644 assets/cubyz/blocks/textures/branch/mahogany/line.png create mode 100644 assets/cubyz/blocks/textures/branch/oak/bend.png create mode 100644 assets/cubyz/blocks/textures/branch/oak/cross.png create mode 100644 assets/cubyz/blocks/textures/branch/oak/dot.png create mode 100644 assets/cubyz/blocks/textures/branch/oak/half_line.png create mode 100644 assets/cubyz/blocks/textures/branch/oak/intersection.png create mode 100644 assets/cubyz/blocks/textures/branch/oak/line.png create mode 100644 assets/cubyz/blocks/textures/branch/pine/bend.png create mode 100644 assets/cubyz/blocks/textures/branch/pine/cross.png create mode 100644 assets/cubyz/blocks/textures/branch/pine/dot.png create mode 100644 assets/cubyz/blocks/textures/branch/pine/half_line.png create mode 100644 assets/cubyz/blocks/textures/branch/pine/intersection.png create mode 100644 assets/cubyz/blocks/textures/branch/pine/line.png create mode 100644 assets/cubyz/blocks/textures/branch/willow/bend.png create mode 100644 assets/cubyz/blocks/textures/branch/willow/cross.png create mode 100644 assets/cubyz/blocks/textures/branch/willow/dot.png create mode 100644 assets/cubyz/blocks/textures/branch/willow/half_line.png create mode 100644 assets/cubyz/blocks/textures/branch/willow/intersection.png create mode 100644 assets/cubyz/blocks/textures/branch/willow/line.png delete mode 100644 assets/cubyz/models/branch.obj diff --git a/assets/cubyz/blocks/baobab_branch.zig.zon b/assets/cubyz/blocks/baobab_branch.zig.zon index 97d0afba..94d8a0f6 100644 --- a/assets/cubyz/blocks/baobab_branch.zig.zon +++ b/assets/cubyz/blocks/baobab_branch.zig.zon @@ -6,8 +6,15 @@ }, .absorbedLight = 0x202830, .rotation = .branch, - .model = "cubyz:branch", - .texture = "cubyz:baobab_log", + .model = .{ + .radius = 4, + }, + .texture_top = "cubyz:branch/baobab/dot", + .texture_bottom = "cubyz:branch/baobab/half_line", + .texture_right = "cubyz:branch/baobab/line", + .texture_left = "cubyz:branch/baobab/bend", + .texture_front = "cubyz:branch/baobab/intersection", + .texture_back = "cubyz:branch/baobab/cross", .item = .{ .material = .{ .density = 0.2, diff --git a/assets/cubyz/blocks/birch_branch.zig.zon b/assets/cubyz/blocks/birch_branch.zig.zon index e9c76b75..639b5c05 100644 --- a/assets/cubyz/blocks/birch_branch.zig.zon +++ b/assets/cubyz/blocks/birch_branch.zig.zon @@ -6,8 +6,15 @@ }, .absorbedLight = 0x202830, .rotation = .branch, - .model = "cubyz:branch", - .texture = "cubyz:birch_log", + .model = .{ + .radius = 4, + }, + .texture_top = "cubyz:branch/birch/dot", + .texture_bottom = "cubyz:branch/birch/half_line", + .texture_right = "cubyz:branch/birch/line", + .texture_left = "cubyz:branch/birch/bend", + .texture_front = "cubyz:branch/birch/intersection", + .texture_back = "cubyz:branch/birch/cross", .item = .{ .material = .{ .density = 0.3, diff --git a/assets/cubyz/blocks/cactus_arm.zig.zon b/assets/cubyz/blocks/cactus_arm.zig.zon index 01819a01..ce1857e4 100644 --- a/assets/cubyz/blocks/cactus_arm.zig.zon +++ b/assets/cubyz/blocks/cactus_arm.zig.zon @@ -6,8 +6,15 @@ }, .absorbedLight = 0x202830, .rotation = .branch, - .model = "cubyz:branch", - .texture = "cubyz:cactus", + .model = .{ + .radius = 4, + }, + .texture_top = "cubyz:branch/cactus/dot", + .texture_bottom = "cubyz:branch/cactus/half_line", + .texture_right = "cubyz:branch/cactus/line", + .texture_left = "cubyz:branch/cactus/bend", + .texture_front = "cubyz:branch/cactus/intersection", + .texture_back = "cubyz:branch/cactus/cross", .item = .{ .material = .{ .density = 0.8, diff --git a/assets/cubyz/blocks/mahogany_branch.zig.zon b/assets/cubyz/blocks/mahogany_branch.zig.zon index 74edd5d0..74074274 100644 --- a/assets/cubyz/blocks/mahogany_branch.zig.zon +++ b/assets/cubyz/blocks/mahogany_branch.zig.zon @@ -6,8 +6,15 @@ }, .absorbedLight = 0x202830, .rotation = .branch, - .model = "cubyz:branch", - .texture = "cubyz:mahogany_log", + .model = .{ + .radius = 4, + }, + .texture_top = "cubyz:branch/mahogany/dot", + .texture_bottom = "cubyz:branch/mahogany/half_line", + .texture_right = "cubyz:branch/mahogany/line", + .texture_left = "cubyz:branch/mahogany/bend", + .texture_front = "cubyz:branch/mahogany/intersection", + .texture_back = "cubyz:branch/mahogany/cross", .item = .{ .material = .{ .density = 0.5, diff --git a/assets/cubyz/blocks/oak_branch.zig.zon b/assets/cubyz/blocks/oak_branch.zig.zon index 93b8e264..dcc08545 100644 --- a/assets/cubyz/blocks/oak_branch.zig.zon +++ b/assets/cubyz/blocks/oak_branch.zig.zon @@ -6,8 +6,15 @@ }, .absorbedLight = 0x202830, .rotation = .branch, - .model = "cubyz:branch", - .texture = "cubyz:oak_log", + .model = .{ + .radius = 4, + }, + .texture_top = "cubyz:branch/oak/dot", + .texture_bottom = "cubyz:branch/oak/half_line", + .texture_right = "cubyz:branch/oak/line", + .texture_left = "cubyz:branch/oak/bend", + .texture_front = "cubyz:branch/oak/intersection", + .texture_back = "cubyz:branch/oak/cross", .item = .{ .material = .{ .density = 0.25, diff --git a/assets/cubyz/blocks/pine_branch.zig.zon b/assets/cubyz/blocks/pine_branch.zig.zon index d6000a4c..a21a878e 100644 --- a/assets/cubyz/blocks/pine_branch.zig.zon +++ b/assets/cubyz/blocks/pine_branch.zig.zon @@ -6,8 +6,15 @@ }, .absorbedLight = 0x202830, .rotation = .branch, - .model = "cubyz:branch", - .texture = "cubyz:pine_log", + .model = .{ + .radius = 4, + }, + .texture_top = "cubyz:branch/pine/dot", + .texture_bottom = "cubyz:branch/pine/half_line", + .texture_right = "cubyz:branch/pine/line", + .texture_left = "cubyz:branch/pine/bend", + .texture_front = "cubyz:branch/pine/intersection", + .texture_back = "cubyz:branch/pine/cross", .item = .{ .material = .{ .density = 0.25, diff --git a/assets/cubyz/blocks/textures/branch/baobab/bend.png b/assets/cubyz/blocks/textures/branch/baobab/bend.png new file mode 100644 index 0000000000000000000000000000000000000000..699c8b542fbf73540251efc9951a023835b0c4f8 GIT binary patch literal 331 zcmV-R0kr;!P)Ap`zq85fV$2#7ZJfq@~!6$sghZxEfpb zd(Y1U{}J6EZ_lL{L^ARu=HshgG}QgL$e&)`qIvElPAqAMU_k81 z2S9adC=cFLOw4uPP^6B!AJH&u0RTiY>b|+MWQb&lELkr~{1!kYL$za4qS_gIkvc>& zYtEDScLmd6kvapb`;n^o1VG}%>KlMOiBaXcV`9uA0N%jY7XfgS<8#@U_i~jzc7SMI zczn1!w?nXeGIF}Y^XvO!=4K7h4#CV)?aag?b(CKAJ(x#zY8G;Q4X-0~&r@ dpPzE?jNgrog4&IEM*08%002ovPDHLkV1kj8kGKE; literal 0 HcmV?d00001 diff --git a/assets/cubyz/blocks/textures/branch/baobab/cross.png b/assets/cubyz/blocks/textures/branch/baobab/cross.png new file mode 100644 index 0000000000000000000000000000000000000000..822fe5f470ed4ffa270eed6777dc485dda39e04b GIT binary patch literal 407 zcmV;I0cie-P)u~k2lgjG)And<7N8`h z$`n6i-9>=S zgRvfHFcz)HlcLyWc>9>6cuzW~}Aw2dEU@NgZvBhisbaA=d8`nJjL_c#)|KCL!N}-N`cPU z&L>?OP3i>KJwK0N58f=O5#h&D7JB8D^SM zXVZYeIz%c&Le<4dod&3mUcD(ZM5@4D5^%e?*q`b8ZvZ4O{QO^lnP#sn0#JKb+eV^* zTVN1AC8iz)yuUVxb&Ks)kbkxCvK>S9tLM z?|a7Zzjkjg$7@pwB9=1GI9=T8fScxDqPj2~o@-7QhmkB#KL#I?(clBBBh9`7Ky^%p zZkjpVHKr~M0BzUP?5mU_lHJr(7X~-YXz(ZTbZVpm1gG12S7AYzkAnP;@!yh@Z3L}6W+6`}3V07#anx`?Ii&oq_X49Yx16*PDt zPh=5N?AW|$5{*pk_%inGdwrE9JthL!ZD;)P{(2pJNc-jZGToQ5QV=~AOV`-O}dCUSkKUl^ai~}_dOAcRI)J{fh8lg3u>qQ6ylvN`YKQFy08E|$#Qpon=i%@DWDWojDG&kGZt^(5HUV|hqTY?5G{fWxCQmq@%v!A_ zpn5KW64j2nRbYf%uJ$oNkPT3kg6)Uc!b1R&f@79)a~{?1SJ4!_2{>jcm#d9cZQo+@ z1lteMn@zyY`9%tF_huI`p8=6#qHY%u9**({>h=q`N4g8J{SYgQK#26eG!}qh7))DP ztG)_2pA6#sD0?=}YbiX<4{pv!vsAliqRA7gQuYN*kTnULQlsyWHJY^t5hsHyfbTmtC z;-tL+Z}ao}eeW;)Tk`Y0bwydRUM*>@B~=O`H2}xMp4M7`;7=wh=>x6-7V}vYUM&%);B&2v0NFH;99|@P z883-L1wPPcN|g$tqO90%zb*n2*IC!pCK_N<8;Y{x_3a&i`@1OsFV9chK0HQSNV=VI zt+n`8`epZ_K`>Zj^Z@8~#`Q%_ZKD5S1y@5rYb{M}LM7QW4{I*UYCMCX!*$jT*X98L nlbd{ei9-`olS0)0rCay~rILq$l;C#m00000NkvXXu0mjfa{-TK literal 0 HcmV?d00001 diff --git a/assets/cubyz/blocks/textures/branch/birch/cross.png b/assets/cubyz/blocks/textures/branch/birch/cross.png new file mode 100644 index 0000000000000000000000000000000000000000..f14bd85cbc6f2b04bd9db8e4a361fe3f2f535b22 GIT binary patch literal 420 zcmV;V0bBlwP)y;rzruj{0R|*yJ^&$vkh(A@U`8oJ@|T*q!(bO96Clm#9hpRrn(0D!a82mo+*zwrJA=ys}Wn+gCd>f{?7$2P#% z=dw$)9P`-}wNh5iZBv2zVfu;P?ag)H1FFqU4w!&s;s;16$S6jd<(h#{iA4GR?G@wE z5FzIzf7xYb2@y!m?OCjev z(AC7%<%K@mrs@IA?#q2SX_n(@@nXG3$w@MSjAFD+1&^dlrI@r`8M`b4CjM3;*`_S4 z|0m~(m2>0*)JkDf7Mh8SVm)Sa{$zhj+1*GoSIP(52=pTiakvX6DA_j^Aj(Y+1Z}$j O0000yF1g967xVKD~}j~iS~8&m`&gv1U=b>+`82{jcJ4QSLXGSI!S@GaMlqDjTi_I-aK zf4b(xWe;w5#t$`jcBD%(tee8&o_KT9p%R~i<~lO2=L6*f6|-{-Eakt{m>rwCDJ-kp z{Vngc)vAkrY|Rrf?p2;5v_Np3s7hgr_EYIk%>w6ln{m~ZE%@xCUf3ev@}^&%LG3Uj w!|u0j|4I_Ka(yznl=}8liRb}~$MzqXw10YDYMyra4A3hKp00i_>zopr03f?x^Z)<= literal 0 HcmV?d00001 diff --git a/assets/cubyz/blocks/textures/branch/birch/half_line.png b/assets/cubyz/blocks/textures/branch/birch/half_line.png new file mode 100644 index 0000000000000000000000000000000000000000..75d137d13c8d917c03fe7f4af5d6b0041fdf819b GIT binary patch literal 292 zcmV+<0o(qGP)zgLcQ#BP8@C2sFhv60a zXv+l{Im!Rc{PPdI%ds0}A+_rT09?*TPD%mb3xVqeI0I4B^liYS*!2QNUT_E9V4WNM z{qFUA_K7b_f51ZUGektNu@(e>VeLaS1d9}=ut=sz zvngY-JIPGePw+MwChy*N-@60<7=3@N+c-&CEf-W;<9i-LDgc_gq|zF|xi9jJyZc9O zZ>|{w%%+pQqNXkpQV~ei3u#RdM#M?lIT#xvfRKu}*B55f3BKpi)Ma;XgbY5va)eY{ z0U;Gdo)JjJYPmq{ivJu1Sg+rE2SFG)OEDy2bu?uAe0mc0BbY+d$@jdjFiujZDGyK2PB%lI&(8_Mh^8(XZGN)0+HKc%GmO;0b}6J{!~mP0thGr+ zo;m-I&*l#2U?@;&O_67vlOT+`nC<)x_8hbu-P*B1|4sl7k0OUN-jie-p%2ddLs5fY X;9jGENYeB900000NkvXXu0mjfvj3r% literal 0 HcmV?d00001 diff --git a/assets/cubyz/blocks/textures/branch/birch/line.png b/assets/cubyz/blocks/textures/branch/birch/line.png new file mode 100644 index 0000000000000000000000000000000000000000..b2a9501db1ecba8a4d30c4a9209ea00909b9a68e GIT binary patch literal 351 zcmV-l0igbgP)S2Pu5KzqG660$+$;(1R3iuCH)^U+tsvZweX&7#!{e$Wns(5!nDH z37P*4Uq1bVYkvC@!S^>VW8mTY3+H14Ov2(21HXJ?W?*1oV0iI_5pLtgvt116@)!n~ zOT;3=o=^s?X zKZY-#m>GEZ5Efv#09^oKBSb@(Z8TgC7NvL%fY`_cH|*q##rP8vx&W?}hbtig00(Sy UD4#R5(f|Me07*qoM6N<$f-OUcF8}}l literal 0 HcmV?d00001 diff --git a/assets/cubyz/blocks/textures/branch/cactus/cross.png b/assets/cubyz/blocks/textures/branch/cactus/cross.png new file mode 100644 index 0000000000000000000000000000000000000000..56577e68c722634539cb28fde50a1a28fda0c765 GIT binary patch literal 385 zcmV-{0e=38P)~sn?%kakB70s-x3fuYAsn8PZa}?S#HlCgNpRN3Mxt! z3##PtoHyChYj#tK`$GG}Vki9z@g4xc%i`njztAzZ4=&HHe2lL4QGn7U!JN1GIvDZ4 f0P*Hg;6D2Sp}3w+$#k8C00000NkvXXu0mjfj;gGC literal 0 HcmV?d00001 diff --git a/assets/cubyz/blocks/textures/branch/cactus/dot.png b/assets/cubyz/blocks/textures/branch/cactus/dot.png new file mode 100644 index 0000000000000000000000000000000000000000..92b64f83b519f78298b60e86f63fbe0c05bbb0e6 GIT binary patch literal 220 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`i#=T&Lo9le6C_xBUNF7g{Pmyx zp0h^|0D;2#U;T{7o<011T0!UBiGZ0^oUZ)ByBPE1|E2%<^irM~2%7g7N;31`kGGJQ zK49?RsIc3PUg`5?h8*3_KjQ5Sh0_^ajGZE4y126#%EA*Q4jewt68`7g(|Qr+v#Lp* zh7a`p)aTc1oUwt?Gw!KIT*c2f(rw)zq&9ra5x>IvU!vuxq~RVzE(1meo%1$p7X|K# Q2RfI*)78&qol`;+0J$qv^Z)<= literal 0 HcmV?d00001 diff --git a/assets/cubyz/blocks/textures/branch/cactus/half_line.png b/assets/cubyz/blocks/textures/branch/cactus/half_line.png new file mode 100644 index 0000000000000000000000000000000000000000..05e6106865c59fde04ec8d0cb3e9d3f9437dcc25 GIT binary patch literal 265 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`7d%}YLo9le6C_xBUNF7g{Pmyx zp0h^|0D;2#U;T{7o<011T0!UBiGZ0^oUZ)ByBPE1|E2%<^irM~2%7g7N;31`kGGJQ zK49?RsIc3PUg`5?h8*3_KjQ5Sh0_^ajGZE4y126#%EA*Q4jewt68`7g(|Qr+v#Lp* zh7a`p)aTc1oUwt?Gw!KIT*c2f(rw)zq&9ra5x>IvU!vuxq~RXN3k);TX0++gpCMWC zW5$CxHZXIm~w=;Ig=y-jUV%RL0cH^XYx2Lzqjv%>pEi4S@uZ5p^9js>v^c#bx LtDnm{r-UW|WqfKX literal 0 HcmV?d00001 diff --git a/assets/cubyz/blocks/textures/branch/cactus/intersection.png b/assets/cubyz/blocks/textures/branch/cactus/intersection.png new file mode 100644 index 0000000000000000000000000000000000000000..dab42f07c9b95897a575db5030160820ca3269a9 GIT binary patch literal 345 zcmV-f0jB1pzZ}QI1FG=JOLOy$%QvS-VhfmU8mlq31|W8d_csl|e9?rnu{E(%xY>l=bA_>* z`JzEjk6Oy23B!5T=V!;a7+Z%NAUjk-fsUO5pe!N)(hn6Fx5=7uJLo^G^-Smnh)Z!XFfcGMeEIZ` zfq{X6;qA-+a5-c)P6LpEusFgp9zN_!v5F!q{_=?#D)yH+171G+hG7VdjqDyw!*wZ&;WGjqsIzC19Ex3y785og$*Ua23ooC2!w4Ef)kh%zyw4ENo ze>ea9@6CJfANa4}>G67B=MlFPi7}SXpMtw9NsWp&L*VzJAwaX$Jz@^K4~Nec=-fqOMuz(a~#8 zl`bt|T%n|&L8$ryC7Tyq=>oQuMM*HG=}&uctLm6QHh?g$TF{|a2TBrOewzWn&E>_> z#bns&4dV*nyaiprcqA~!;_}GS#`k=ex1hz+-vB^x+IW7r-z(WjHpaFan(uM|Uf;ft z|G_E2Cd`?wx(&FDroH&A0*}BAx-}kFokt#l7j2RVRM8MP|GKnn!isI>Ipz;1JG0&%m)F=~xSOC68)YCn2wEP1BMCBV-#D*oG6u`~%w<&RB)#xeovU002ovPDHLkV1n-& B(&zvH literal 0 HcmV?d00001 diff --git a/assets/cubyz/blocks/textures/branch/mahogany/dot.png b/assets/cubyz/blocks/textures/branch/mahogany/dot.png new file mode 100644 index 0000000000000000000000000000000000000000..7ea4124bd4228e5c974abe4061f6b20c3b62b817 GIT binary patch literal 244 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`yFFbTLo9mVPW0w$G7xcHza%Nz z)3b+JwP%h+DRPui%xY zzieOfPjfd-;n}6cvZ(RVKk14Fv7&sAF6LtqZ&gIjz0!6lj&crO8{50E9Ay7Q5P z2#}|2oNCq!DAJ)?Pxno^yKPKfK{B#8brp# z_J4H%uvyQ3g&rpORe(Gl=Pr6TiOMQY;735P{Jc@q+*zV&grn%)Wk4ew+ufXiRdX^| zIS7p*#$_GdDgs2SHAZ3&BOuIQcb-NJ?1$**^9@=kX!NgAS>yl!002ovPDHLkV1l*M Bd`AEP literal 0 HcmV?d00001 diff --git a/assets/cubyz/blocks/textures/branch/mahogany/intersection.png b/assets/cubyz/blocks/textures/branch/mahogany/intersection.png new file mode 100644 index 0000000000000000000000000000000000000000..c86c5be950d42586c019b997c2c55045ad043da3 GIT binary patch literal 385 zcmV-{0e=38P)8mi8H`8p03OpLcncE~H-xw_MhdhuOf$G>TE0AjZ`arV zNB{2?{;Tu!c)e?V!RiOY* zm!|Ao$QxR0JpeDSA4eQToQ5Jn%CNeqb`DXS#Py2~D=hv}hulAfU_h$2=<+zm*pkJ*hJ$WwUV5hb)IRoRmVQK|+-PsO}xdIJeO$K0pc&+cq-9yYm;F(zpO}z)VBl6Y5)KL07*qoM6N<$f?U3y Ar2qf` literal 0 HcmV?d00001 diff --git a/assets/cubyz/blocks/textures/branch/oak/bend.png b/assets/cubyz/blocks/textures/branch/oak/bend.png new file mode 100644 index 0000000000000000000000000000000000000000..dd340bbf8b9201b2e7806a4db1b85293cc7537b2 GIT binary patch literal 357 zcmV-r0h<1aP)_)JamXEHIkdijhd(|wblIa z2HeTIvd{g_@rC~yy*%C?0j@767~7y^0KhaB0OUp8>c75!j?M+dauJgkH2~=>^pEtW zLdn1j8QZY4haQ2*i<)#E0id&zbRMCi5S^8*w|ijXMTP_}(s_g_D|A)@@bzQ7kelo* zC34&s&{^qyI+POIj$4Z~R6PQ>m0g;1@$>ox9L|a3r&|^D00000NkvXXu0mjf D4Bw)u literal 0 HcmV?d00001 diff --git a/assets/cubyz/blocks/textures/branch/oak/cross.png b/assets/cubyz/blocks/textures/branch/oak/cross.png new file mode 100644 index 0000000000000000000000000000000000000000..57e395a49c39d09077756d5241a8e3d83aca1496 GIT binary patch literal 430 zcmV;f0a5;mP)rYq$h0bk-yu zI8`Q@`RD)t%*>d?_2ucO%QfY?#ij|aFqEr?Wu|y~t+~5@o(=2wrT{igDAz46*8upY z#TACC?xv-?0bF6&gza~8=tqr*2mAj604&n^C>IGn^nYq+R~ILrg6>0)O%s-x0-&n9 z*kscLVDxR7Db(3f7HNuZX|!pA%k?OiS|56R=uuVO;R+L}y24t`q1N>Ho7iTt9c73QLsrB1loyUCF8t-Hn( zc>(wKDhAuu@()w)9gMDM(2Ef{=#=5v$`*S<-#2&#`-?S)4(vIjvLVaZRPXs?_5&%L z46R`dSA6?R=e>R_mvTiUVUr5S)brmTaF?ukdqrc*p(mQ9mp@mO22OTuI2n9u6>r0( zG(I6lmur=N)xLMXFxChLgy~-Uxp3E<|ML>&KHu>Bt_r`#!;dBxb;7=hMY-B<)Vd~K X)nv=d?K^ul(8Ua%u6{1-oD!MP$L+-uxE+ zu^JZcx9b}qFIxbj&@<;GYj`|gPS1KMpf4A7XYwfYOg@Z}0Dua7loTXc)7PZnxZlnT zM4{*8dh#!dk$?((;Mqm8blm=}O)=i{_mMgYB$ znnFoIQFkMQCk2!gsK6<jvF)@Bv1W=R*K|f89=Q%+$pn$==nbu~)O>12St^e4y8+ Q6951J07*qoM6N<$f?%L(xc~qF literal 0 HcmV?d00001 diff --git a/assets/cubyz/blocks/textures/branch/oak/intersection.png b/assets/cubyz/blocks/textures/branch/oak/intersection.png new file mode 100644 index 0000000000000000000000000000000000000000..af10a12384e55724e67aef2da13db218ea0fe99c GIT binary patch literal 373 zcmV-*0gC>KP)07ifkKRisvO6S+|nm7&-q0dByX z;>7R0@Bae-HF|lvy8x_~Q=D%xDq%4b036B&=UV`bN&tG_7Bhi(xS4S%8vtx7dyPgV z*i`n;;jZ&7&bNp|*9G=HE)3~Z8-&FvtH!cne zo4VzE`%Ro_L}=`0b-u+_HLK;cm)B?sMSZ0$YE0Q6oNuwIjF`g;s76cH8yB4%{h6ab zBWxYHvyVuR61N)WfUe z0Fx-b%I~(gY2-I@Ih@XEehUeuG_ zCr8jKLQBEnbiSNPu`C0x+>P|td2t3>MWmU-mJLr2aqoQ52tM&ped-U40=%X#4Ar$1 z^8gr6KF!=R1Gog~EwmKavbhR)6riO*tM(&>FEFMLaE0_;4yQ9)x#{+cKT?=@XcNN2 Z^$XD^e3)1IcLx9f002ovPDHLkV1hxjk#_(9 literal 0 HcmV?d00001 diff --git a/assets/cubyz/blocks/textures/branch/pine/bend.png b/assets/cubyz/blocks/textures/branch/pine/bend.png new file mode 100644 index 0000000000000000000000000000000000000000..17478cada7e562c049da5e9d07d0a722af84c535 GIT binary patch literal 318 zcmV-E0m1%>P)@5z5t+?f#=uvDmO48j!F3W6IuHeyS?D8p>>83 zN4~!M!mu#Vk4`3J7y(zL$tIO46LlL>E4u~Ablp;m%!2ytY)afy(pSURHy z*lt`B<(oR0&Yn{kC{anBOv$kEHj$4Vl`tx5yrq{Ry@p2aW#HdU^XOH1*vE%+2OgT~v%=FgQld)!_I;8>(?-R*@C&EmiC3&@psn&u`X Q&j0`b07*qoM6N<$g4L3W=l}o! literal 0 HcmV?d00001 diff --git a/assets/cubyz/blocks/textures/branch/pine/cross.png b/assets/cubyz/blocks/textures/branch/pine/cross.png new file mode 100644 index 0000000000000000000000000000000000000000..3d957af76788d9194c653bc005589f57ee5b9a7c GIT binary patch literal 405 zcmV;G0c!q;63>YVNOMPG z0T8!?)GFpu+h)U?k zD&M8;dIiG_D%Y~#grvFi0m^^b52KZz&{BMfx8bbC=hRLdDz;2O51tD$Y@_E z-35Ettx!@F8BJ{)KMj#w+lJj$1c1@b+mu{JdkygPaCZ_#!w^OK^XvPl=He<(!<)X1 ze+eR^M}bMvU+X-3UbSt2K1k`B6_(1Wi?8tqehjlK`Q+Ja00000NkvXXu0mjf=FGdO literal 0 HcmV?d00001 diff --git a/assets/cubyz/blocks/textures/branch/pine/dot.png b/assets/cubyz/blocks/textures/branch/pine/dot.png new file mode 100644 index 0000000000000000000000000000000000000000..0c1474bb143e42ae634371e1cc2c45422257b56d GIT binary patch literal 226 zcmV<803H8{P)#=3OvDLjH_^$4EAJ1B@^Nt2SItA;j-cmSQXyioJdXiSfiV)9X2 zmkcKX+B)iG?(cDn)Qku){?wS>d*PgqfFU@vD3tWR>EZ^_uu5fI9@bZGO~-mw0HCBz cw)l0u0rgBfHdlr}eE(;a0e=(qD0O(N(2jJlf*{3KxgMK&71$f4F9v3 z3WxpfUQ3VjUDURlPXHQeIiAj=9hIYAE5T|-X%x3G>Vm7Cfam9ra~<} zR;$rP=ez837T|ox`pd-k&_ymr0vKMZrH|S)&RalO3@!?*qb_agAPKgzOD;DbEjQBg z^IZU7wVwwJW0XcwOV8z2jr7?F!AU5sG_OA~3n;A4Hvg`~#8V?J@GLT1y;g$rDjVSe X`e;}(8qceL00000NkvXXu0mjf{0VV- literal 0 HcmV?d00001 diff --git a/assets/cubyz/blocks/textures/branch/pine/intersection.png b/assets/cubyz/blocks/textures/branch/pine/intersection.png new file mode 100644 index 0000000000000000000000000000000000000000..ef578165a6e59f6bb2aba3848e4c2ad76211371e GIT binary patch literal 355 zcmV-p0i6DcP)+|C!!~{U)47D$4q(^H24|gj7TItxIV(tSlA*Ni|pCYv{IGzP>4V5#5m^gg5 znQ*su05sAM1iGb>9_bR`CThm0oZ;*6lgVpeu&ms`5n{qyLnA%jnu!Hf39woDd~T#4 z6pS+nF|k`a_NNFy?TdULVnVuM(V!NV>Px*T``G8)PUQ@nmA?{bqc%0tXTs9kJgD2X z_kMeW(V@~?TIup@sN_~Uwznk!-o|WGb6GIM+so5M6^%nw>F*z(lbPk5Krs%la@RjG z#~*^y+eu(LH2)I{GcUB#0Yi|w^>`LSG?N!n`~oDVlia!oIB5U?002ovPDHLkV1f^6 Bo4Ei0 literal 0 HcmV?d00001 diff --git a/assets/cubyz/blocks/textures/branch/pine/line.png b/assets/cubyz/blocks/textures/branch/pine/line.png new file mode 100644 index 0000000000000000000000000000000000000000..f2693e2e9eb8c18e4bdfe5362a706e948c6eeaf3 GIT binary patch literal 316 zcmV-C0mJ@@P)j)}MAI=ozrJ^Ay;=%*4ycSmWfVMLMXbJ-RVFLPLzV$>uzLWA z6qQjJXpZ@t0@9`JDHAM3#&ocI3^Ye<&jIz(!C7FWX_5EeRKc- zt9e@>9YZd#>H2^9%@Kq|Ok4hqn*z@2qVsDeW=wLf1I@8(+Y>yi;s_TN@^h)@3G`$D O0000w%{L literal 0 HcmV?d00001 diff --git a/assets/cubyz/blocks/textures/branch/willow/bend.png b/assets/cubyz/blocks/textures/branch/willow/bend.png new file mode 100644 index 0000000000000000000000000000000000000000..56b0f512c7ebf16aab2a6a10991449433329722f GIT binary patch literal 301 zcmV+|0n+}7P)|IFey^x9By6u%qdeD0_k!J6Sfdy5re=f7AewN&IvM&c30B;_vbJC z*Y12e-pq_-833n3hzUPA{PYCCbq@9U?fqldHrR)_)Qja1P#czg05iKI5T`=2j9CT} zs)DLumOHApX-AMO<5YM)cwS!)^@6Gp;)1GHbsIF0g1sKFs5X{nAz@9^|s3( z!~{R|#sC1A`B^Hu>*X|y$cl0);H=2sJy;y#1d$A8f@8uV#L0k~RMXXWl~jY1WRM0$ zX96>UnIMu^thA`UiDdY};h+;fjvlWsqXC!+Ax@@UyZfQHCP^|#X_o}CZZ+-J0YCJ1 zPxS!n8H8Bmr~~Oi`F0OB0|1Kz$AsHGtXR}+bQg36A*Lch=`9ItiDijoB}3^eX0_J< zaJ`&n_4+vajrU(azx#io_PPbjlU1hnqV~T2JgqxB43_SC{NU_Iw&x#h&*F0v!FhB5 O0000@+F)%ZhiK<|0T!PUl$fvv$-|R+#(9-ItEWyKbLh*2~7Zr C4^PDa literal 0 HcmV?d00001 diff --git a/assets/cubyz/blocks/textures/branch/willow/half_line.png b/assets/cubyz/blocks/textures/branch/willow/half_line.png new file mode 100644 index 0000000000000000000000000000000000000000..313bc383f4b5ed990233913fc206e71cc23a20d6 GIT binary patch literal 244 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`yFFbTLo9mVPBP?UQWSA$$hs5UTc;#ceV%Z-66g&EPgg&ebxsLQ04`l%`~Uy| literal 0 HcmV?d00001 diff --git a/assets/cubyz/blocks/textures/branch/willow/intersection.png b/assets/cubyz/blocks/textures/branch/willow/intersection.png new file mode 100644 index 0000000000000000000000000000000000000000..8fb2407b6c188905d9d5794347990419df00d13c GIT binary patch literal 317 zcmV-D0mA-?P)9DnuL$M}Ar7$!oZ`GXol@invXzi#c4lV<|8=_G zu1{5^Xa&HFBjrL2o){(ozL(U_DX*wjL>yim=akn*G!W1l+B<-%9>_&2&JL;-D2O;j z9IEx;%9`4nY9$8GxoE|U<1$Cy-{wXTaiqK=A_w&trY2If;>`92(5BYg?neTMVQTlT z53tW5&qN}?f&EQ>%cjW4f return .dirPosX, + -1 => return .dirNegX, + else => switch(pos[1]) { + 1 => return .dirPosY, + -1 => return .dirNegY, + else => switch(pos[2]) { + 1 => return .dirUp, + -1 => return .dirDown, + else => return null, + }, + }, + }; + } + /// Index to bitMask for bitmap direction data pub inline fn bitMask(self: Neighbor) u6 { return @as(u6, 1) << @intFromEnum(self); diff --git a/src/rotation.zig b/src/rotation.zig index cd15454b..ccfcaee4 100644 --- a/src/rotation.zig +++ b/src/rotation.zig @@ -341,7 +341,7 @@ pub const RotationModes = struct { pub const Branch = struct { // MARK: Branch pub const id: []const u8 = "branch"; pub const dependsOnNeighbors = true; - var branchModels: std.StringHashMap(u16) = undefined; + var branchModels: std.AutoHashMap(u32, u16) = undefined; const BranchData = packed struct(u6) { enabledConnections: u6, @@ -374,35 +374,233 @@ pub const RotationModes = struct { branchModels.clearRetainingCapacity(); } - fn branchTransform(quad: *main.models.QuadInfo, data: BranchData) void { - for(&quad.corners) |*corner| { - if((!data.isConnected(Neighbor.dirNegX) and corner[0] == 0) or - (!data.isConnected(Neighbor.dirPosX) and corner[0] == 1) or - (!data.isConnected(Neighbor.dirNegY) and corner[1] == 0) or - (!data.isConnected(Neighbor.dirPosY) and corner[1] == 1) or - (!data.isConnected(Neighbor.dirDown) and corner[2] == 0) or - (!data.isConnected(Neighbor.dirUp) and corner[2] == 1)) return degenerateQuad(quad); + const Direction = enum(u2) { + negYDir = 0, + posXDir = 1, + posYDir = 2, + negXDir = 3, + }; + + const Pattern = union(enum) { + dot: void, + halfLine: struct { + dir: Direction, + }, + line: struct { + dir: Direction, + }, + bend: struct { + dir: Direction, + }, + intersection: struct { + dir: Direction, + }, + cross: void, + }; + + fn rotateQuad(originalCorners: [4]Vec2f, pattern: Pattern, min: f32, max: f32, side: Neighbor) main.models.QuadInfo { + var corners: [4]Vec2f = originalCorners; + + switch(pattern) { + .dot, .cross => {}, + inline else => |typ| { + const angle: f32 = @as(f32, @floatFromInt(@intFromEnum(typ.dir)))*std.math.pi/2.0; + corners = .{ + vec.rotate2d(originalCorners[0], angle, @splat(0.5)), + vec.rotate2d(originalCorners[1], angle, @splat(0.5)), + vec.rotate2d(originalCorners[2], angle, @splat(0.5)), + vec.rotate2d(originalCorners[3], angle, @splat(0.5)), + }; + }, + } + + const offX: f32 = @floatFromInt(@intFromBool(@reduce(.Add, side.textureX()) < 0)); + const offY: f32 = @floatFromInt(@intFromBool(@reduce(.Add, side.textureY()) < 0)); + + const corners3d = .{ + @as(Vec3f, @floatFromInt(side.textureX()))*@as(Vec3f, @splat(corners[0][0] - offX)) + @as(Vec3f, @floatFromInt(side.textureY()))*@as(Vec3f, @splat(corners[0][1] - offY)), + @as(Vec3f, @floatFromInt(side.textureX()))*@as(Vec3f, @splat(corners[1][0] - offX)) + @as(Vec3f, @floatFromInt(side.textureY()))*@as(Vec3f, @splat(corners[1][1] - offY)), + @as(Vec3f, @floatFromInt(side.textureX()))*@as(Vec3f, @splat(corners[2][0] - offX)) + @as(Vec3f, @floatFromInt(side.textureY()))*@as(Vec3f, @splat(corners[2][1] - offY)), + @as(Vec3f, @floatFromInt(side.textureX()))*@as(Vec3f, @splat(corners[3][0] - offX)) + @as(Vec3f, @floatFromInt(side.textureY()))*@as(Vec3f, @splat(corners[3][1] - offY)), + }; + + var offset: Vec3f = .{0.0, 0.0, 0.0}; + offset[@intFromEnum(side.vectorComponent())] = if(side.isPositive()) max else min; + + const res: main.models.QuadInfo = .{ + .corners = .{ + corners3d[0] + offset, + corners3d[1] + offset, + corners3d[2] + offset, + corners3d[3] + offset, + }, + .cornerUV = originalCorners, + .normal = @floatFromInt(side.relPos()), + .textureSlot = @intFromEnum(pattern), + }; + + return res; + } + + fn addQuads(pattern: Pattern, side: Neighbor, radius: f32, out: *main.List(main.models.QuadInfo)) void { + const min: f32 = (8.0 - radius)/16.0; + const max: f32 = (8.0 + radius)/16.0; + switch(pattern) { + .dot => { + out.append(rotateQuad(.{ + .{min, min}, + .{min, max}, + .{max, min}, + .{max, max}, + }, pattern, min, max, side)); + }, + .halfLine => { + out.append(rotateQuad(.{ + .{min, 0.0}, + .{min, max}, + .{max, 0.0}, + .{max, max}, + }, pattern, min, max, side)); + }, + .line => { + out.append(rotateQuad(.{ + .{min, 0.0}, + .{min, 1.0}, + .{max, 0.0}, + .{max, 1.0}, + }, pattern, min, max, side)); + }, + .bend => { + out.append(rotateQuad(.{ + .{0.0, 0.0}, + .{0.0, max}, + .{max, 0.0}, + .{max, max}, + }, pattern, min, max, side)); + }, + .intersection => { + out.append(rotateQuad(.{ + .{0.0, 0.0}, + .{0.0, max}, + .{1.0, 0.0}, + .{1.0, max}, + }, pattern, min, max, side)); + }, + .cross => { + out.append(rotateQuad(.{ + .{0.0, 0.0}, + .{0.0, 1.0}, + .{1.0, 0.0}, + .{1.0, 1.0}, + }, pattern, min, max, side)); + }, } } - fn degenerateQuad(quad: *main.models.QuadInfo) void { - for(&quad.corners) |*corner| { - corner.* = @splat(0.5); - } + fn getPattern(data: BranchData, side: Neighbor) ?Pattern { + const posX = Neighbor.fromRelPos(side.textureX()).?; + const negX = Neighbor.fromRelPos(side.textureX()).?.reverse(); + const posY = Neighbor.fromRelPos(side.textureY()).?; + const negY = Neighbor.fromRelPos(side.textureY()).?.reverse(); + + const connectedPosX = data.isConnected(posX); + const connectedNegX = data.isConnected(negX); + const connectedPosY = data.isConnected(posY); + const connectedNegY = data.isConnected(negY); + + const count: u6 = @as(u6, @intFromBool(connectedPosX)) + @as(u6, @intFromBool(connectedNegX)) + @as(u6, @intFromBool(connectedPosY)) + @as(u6, @intFromBool(connectedNegY)); + + return switch(count) { + 0 => { + if(data.isConnected(side)) { + return null; + } + + return .dot; + }, + 1 => { + var dir: Direction = .negXDir; + if(connectedNegY) { + dir = .negYDir; + } else if(connectedPosX) { + dir = .posXDir; + } else if(connectedPosY) { + dir = .posYDir; + } + return .{.halfLine = .{.dir = dir}}; + }, + 2 => { + if((connectedPosX and connectedNegX) or (connectedPosY and connectedNegY)) { + var dir: Direction = .negYDir; + if(connectedPosX and connectedNegX) { + dir = .posXDir; + } + + return .{.line = .{.dir = dir}}; + } + + var dir: Direction = .negXDir; + + if(connectedNegY) { + dir = .negYDir; + if(connectedPosX) { + dir = .posXDir; + } + } else if(connectedPosX) { + dir = .posXDir; + if(connectedPosY) { + dir = .posYDir; + } + } else if(connectedPosY) { + dir = .posYDir; + if(connectedNegX) { + dir = .negXDir; + } + } + + return .{.bend = .{.dir = dir}}; + }, + 3 => { + var dir: Direction = undefined; + if(!connectedPosY) dir = .negYDir; + if(!connectedNegX) dir = .posXDir; + if(!connectedNegY) dir = .posYDir; + if(!connectedPosX) dir = .negXDir; + + return .{.intersection = .{.dir = dir}}; + }, + 4 => { + return .cross; + }, + else => undefined, + }; } pub fn createBlockModel(zon: ZonElement) u16 { - const modelId = zon.as([]const u8, "cubyz:cube"); - if(branchModels.get(modelId)) |modelIndex| return modelIndex; + const radius = zon.get(f32, "radius", 4); + if(branchModels.get(@bitCast(radius))) |modelIndex| return modelIndex; - const baseModelIndex = main.models.getModelIndex(modelId); - const baseModel = main.models.models.items[baseModelIndex]; + var modelIndex: u16 = undefined; + for(0..64) |i| { + var quads = main.List(main.models.QuadInfo).init(main.stackAllocator); + defer quads.deinit(); - const modelIndex: u16 = baseModel.transformModel(branchTransform, .{BranchData.init(0)}); - for(1..64) |branchData| { - _ = baseModel.transformModel(branchTransform, .{BranchData.init(@truncate(branchData))}); + for(Neighbor.iterable) |neighbor| { + const pattern = getPattern(BranchData.init(@intCast(i)), neighbor); + + if(pattern) |pat| { + addQuads(pat, neighbor, radius, &quads); + } + } + + const index = main.models.Model.init(quads.items); + if(i == 0) { + modelIndex = index; + } } - branchModels.put(modelId, modelIndex) catch unreachable; + + branchModels.put(@bitCast(radius), modelIndex) catch unreachable; + return modelIndex; } diff --git a/src/vec.zig b/src/vec.zig index 85348cd6..460d2975 100644 --- a/src/vec.zig +++ b/src/vec.zig @@ -80,6 +80,19 @@ pub fn rotateZ(self: anytype, angle: @typeInfo(@TypeOf(self)).vector.child) @Typ }; } +pub fn rotate2d(self: anytype, angle: @typeInfo(@TypeOf(self)).vector.child, center: @TypeOf(self)) @TypeOf(self) { + if(@typeInfo(@TypeOf(self)).vector.len != 2) @compileError("Only available for vectors of length 2."); + + const sin = @sin(angle); + const cos = @cos(angle); + const pos = self - center; + + return @TypeOf(self){ + cos*pos[0] - sin*pos[1], + sin*pos[0] + cos*pos[1], + } + center; +} + pub const Mat4f = struct { // MARK: Mat4f rows: [4]Vec4f, pub fn identity() Mat4f {