You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
409 lines
71 KiB
409 lines
71 KiB
3 years ago
|
<html>
|
||
|
<head>
|
||
|
<title>main.rs</title>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
|
||
|
<style type="text/css">
|
||
|
.s0 { color: #ed864a;}
|
||
|
.s1 { color: #ebebeb;}
|
||
|
.s2 { color: #ffffff;}
|
||
|
.s3 { color: #ed864a; font-weight: bold;}
|
||
|
.s4 { color: #54b33e;}
|
||
|
.s5 { color: #7ec3e6;}
|
||
|
.s6 { color: #20999d; font-style: italic;}
|
||
|
.s7 { color: #33ccff; font-weight: bold;}
|
||
|
.ln { color: #999999; font-weight: normal; font-style: normal; }
|
||
|
</style>
|
||
|
</head>
|
||
|
<body bgcolor="#131314">
|
||
|
<table CELLSPACING=0 CELLPADDING=5 COLS=1 WIDTH="100%" BGCOLOR="#606060" >
|
||
|
<tr><td><center>
|
||
|
<font face="Arial, Helvetica" color="#000000">
|
||
|
main.rs</font>
|
||
|
</center></td></tr></table>
|
||
|
<pre><a name="l1"><span class="ln">1 </span></a><span class="s0">extern crate </span><span class="s2">env_logger</span><span class="s3">;</span>
|
||
|
<a name="l2"><span class="ln">2 </span></a><span class="s0">extern crate </span><span class="s2">imgui</span><span class="s3">;</span>
|
||
|
<a name="l3"><span class="ln">3 </span></a><span class="s0">extern crate </span><span class="s2">imgui_wgpu</span><span class="s3">;</span>
|
||
|
<a name="l4"><span class="ln">4 </span></a><span class="s1">#[</span><span class="s2">macro_use</span><span class="s1">]</span>
|
||
|
<a name="l5"><span class="ln">5 </span></a><span class="s0">extern crate </span><span class="s2">lazy_static</span><span class="s3">;</span>
|
||
|
<a name="l6"><span class="ln">6 </span></a><span class="s1">#[</span><span class="s2">macro_use</span><span class="s1">]</span>
|
||
|
<a name="l7"><span class="ln">7 </span></a><span class="s0">extern crate </span><span class="s2">serde_derive</span><span class="s3">;</span>
|
||
|
<a name="l8"><span class="ln">8 </span></a><span class="s0">extern crate </span><span class="s2">tobj</span><span class="s3">;</span>
|
||
|
<a name="l9"><span class="ln">9 </span></a><span class="s0">extern crate </span><span class="s2">toml</span><span class="s3">;</span>
|
||
|
<a name="l10"><span class="ln">10 </span></a><span class="s0">extern crate </span><span class="s2">winit_24</span><span class="s3">;</span>
|
||
|
<a name="l11"><span class="ln">11 </span></a>
|
||
|
<a name="l12"><span class="ln">12 </span></a><span class="s0">use </span><span class="s2">std</span><span class="s1">::</span><span class="s2">collections</span><span class="s1">::</span><span class="s2">HashMap</span><span class="s3">;</span>
|
||
|
<a name="l13"><span class="ln">13 </span></a><span class="s0">use </span><span class="s2">std</span><span class="s1">::</span><span class="s2">f32</span><span class="s1">::</span><span class="s2">consts</span><span class="s1">::</span><span class="s2">PI</span><span class="s3">;</span>
|
||
|
<a name="l14"><span class="ln">14 </span></a><span class="s0">use </span><span class="s2">std</span><span class="s1">::</span><span class="s2">fs</span><span class="s3">;</span>
|
||
|
<a name="l15"><span class="ln">15 </span></a><span class="s0">use </span><span class="s2">std</span><span class="s1">::</span><span class="s2">sync</span><span class="s1">::{</span><span class="s2">Arc</span><span class="s3">, </span><span class="s2">Mutex</span><span class="s1">}</span><span class="s3">;</span>
|
||
|
<a name="l16"><span class="ln">16 </span></a><span class="s1">#[</span><span class="s2">cfg</span><span class="s1">(</span><span class="s2">not</span><span class="s1">(</span><span class="s2">target_arch </span><span class="s1">= </span><span class="s4">"wasm32"</span><span class="s1">))]</span>
|
||
|
<a name="l17"><span class="ln">17 </span></a><span class="s0">use </span><span class="s2">std</span><span class="s1">::</span><span class="s2">time</span><span class="s1">::{</span><span class="s2">Duration</span><span class="s3">, </span><span class="s2">Instant</span><span class="s1">}</span><span class="s3">;</span>
|
||
|
<a name="l18"><span class="ln">18 </span></a>
|
||
|
<a name="l19"><span class="ln">19 </span></a><span class="s0">use </span><span class="s2">cgmath</span><span class="s1">::{</span>
|
||
|
<a name="l20"><span class="ln">20 </span></a> <span class="s2">Decomposed</span><span class="s3">, </span><span class="s2">Deg</span><span class="s3">, </span><span class="s2">Euler</span><span class="s3">, </span><span class="s2">InnerSpace</span><span class="s3">, </span><span class="s2">Point3</span><span class="s3">, </span><span class="s2">Quaternion</span><span class="s3">, </span><span class="s2">Rad</span><span class="s3">, </span><span class="s2">Rotation3</span><span class="s3">, </span><span class="s2">SquareMatrix</span><span class="s3">,</span>
|
||
|
<a name="l21"><span class="ln">21 </span></a><span class="s1">}</span><span class="s3">;</span>
|
||
|
<a name="l22"><span class="ln">22 </span></a><span class="s0">use </span><span class="s2">futures</span><span class="s1">::</span><span class="s2">executor</span><span class="s1">::</span><span class="s2">block_on</span><span class="s3">;</span>
|
||
|
<a name="l23"><span class="ln">23 </span></a><span class="s0">use </span><span class="s2">futures</span><span class="s1">::</span><span class="s2">task</span><span class="s1">::</span><span class="s2">LocalSpawn</span><span class="s3">;</span>
|
||
|
<a name="l24"><span class="ln">24 </span></a><span class="s0">use </span><span class="s2">futures</span><span class="s1">::</span><span class="s2">FutureExt</span><span class="s3">;</span>
|
||
|
<a name="l25"><span class="ln">25 </span></a><span class="s0">use </span><span class="s2">gilrs</span><span class="s1">::</span><span class="s2">Event </span><span class="s0">as </span><span class="s2">GilEvent</span><span class="s3">;</span>
|
||
|
<a name="l26"><span class="ln">26 </span></a><span class="s0">use </span><span class="s2">gilrs</span><span class="s1">::{</span><span class="s2">Gamepad</span><span class="s3">, </span><span class="s2">Gilrs</span><span class="s1">}</span><span class="s3">;</span>
|
||
|
<a name="l27"><span class="ln">27 </span></a><span class="s0">use </span><span class="s2">imgui</span><span class="s1">::</span><span class="s2">FontSource</span><span class="s3">;</span>
|
||
|
<a name="l28"><span class="ln">28 </span></a><span class="s0">use </span><span class="s2">imgui</span><span class="s1">::</span><span class="s2">__core</span><span class="s1">::</span><span class="s2">convert</span><span class="s1">::</span><span class="s2">TryInto</span><span class="s3">;</span>
|
||
|
<a name="l29"><span class="ln">29 </span></a><span class="s0">use </span><span class="s2">imgui</span><span class="s1">::*</span><span class="s3">;</span>
|
||
|
<a name="l30"><span class="ln">30 </span></a><span class="s0">use </span><span class="s2">imgui_wgpu</span><span class="s1">::{</span><span class="s2">Renderer </span><span class="s0">as </span><span class="s2">ImguiRenderer</span><span class="s3">, </span><span class="s2">RendererConfig </span><span class="s0">as </span><span class="s2">ImguiRendererConfig</span><span class="s1">}</span><span class="s3">;</span>
|
||
|
<a name="l31"><span class="ln">31 </span></a><span class="s0">use </span><span class="s2">legion</span><span class="s1">::</span><span class="s2">systems</span><span class="s1">::{</span><span class="s2">SyncResources</span><span class="s3">, </span><span class="s2">UnsafeResources</span><span class="s1">}</span><span class="s3">;</span>
|
||
|
<a name="l32"><span class="ln">32 </span></a><span class="s0">use </span><span class="s2">legion</span><span class="s1">::*</span><span class="s3">;</span>
|
||
|
<a name="l33"><span class="ln">33 </span></a><span class="s0">use </span><span class="s2">log</span><span class="s1">::</span><span class="s2">LevelFilter</span><span class="s3">;</span>
|
||
|
<a name="l34"><span class="ln">34 </span></a><span class="s0">use </span><span class="s2">rapier3d</span><span class="s1">::</span><span class="s2">counters</span><span class="s1">::</span><span class="s2">Timer</span><span class="s3">;</span>
|
||
|
<a name="l35"><span class="ln">35 </span></a><span class="s0">use </span><span class="s2">rapier3d</span><span class="s1">::</span><span class="s2">dynamics</span><span class="s1">::{</span>
|
||
|
<a name="l36"><span class="ln">36 </span></a> <span class="s2">IntegrationParameters</span><span class="s3">, </span><span class="s2">JointSet</span><span class="s3">, </span><span class="s2">RigidBody</span><span class="s3">, </span><span class="s2">RigidBodyBuilder</span><span class="s3">, </span><span class="s2">RigidBodyHandle</span><span class="s3">, </span><span class="s2">RigidBodySet</span><span class="s3">,</span>
|
||
|
<a name="l37"><span class="ln">37 </span></a><span class="s1">}</span><span class="s3">;</span>
|
||
|
<a name="l38"><span class="ln">38 </span></a><span class="s0">use </span><span class="s2">rapier3d</span><span class="s1">::</span><span class="s2">geometry</span><span class="s1">::{</span><span class="s2">BroadPhase</span><span class="s3">, </span><span class="s2">ColliderBuilder</span><span class="s3">, </span><span class="s2">ColliderHandle</span><span class="s3">, </span><span class="s2">ColliderSet</span><span class="s3">, </span><span class="s2">NarrowPhase</span><span class="s1">}</span><span class="s3">;</span>
|
||
|
<a name="l39"><span class="ln">39 </span></a><span class="s0">use </span><span class="s2">rapier3d</span><span class="s1">::</span><span class="s2">math</span><span class="s3">;</span>
|
||
|
<a name="l40"><span class="ln">40 </span></a><span class="s0">use </span><span class="s2">rapier3d</span><span class="s1">::</span><span class="s2">math</span><span class="s1">::</span><span class="s2">Point</span><span class="s3">;</span>
|
||
|
<a name="l41"><span class="ln">41 </span></a><span class="s0">use </span><span class="s2">rapier3d</span><span class="s1">::</span><span class="s2">na</span><span class="s1">::{</span><span class="s2">Isometry</span><span class="s3">, </span><span class="s2">Isometry3</span><span class="s3">, </span><span class="s2">Vector</span><span class="s3">, </span><span class="s2">Vector3</span><span class="s1">}</span><span class="s3">;</span>
|
||
|
<a name="l42"><span class="ln">42 </span></a><span class="s0">use </span><span class="s2">rapier3d</span><span class="s1">::</span><span class="s2">pipeline</span><span class="s1">::</span><span class="s2">PhysicsPipeline</span><span class="s3">;</span>
|
||
|
<a name="l43"><span class="ln">43 </span></a><span class="s0">use </span><span class="s2">wgpu</span><span class="s1">::{</span><span class="s2">BindGroup</span><span class="s3">, </span><span class="s2">Buffer</span><span class="s3">, </span><span class="s2">TextureView</span><span class="s1">}</span><span class="s3">;</span>
|
||
|
<a name="l44"><span class="ln">44 </span></a><span class="s0">use </span><span class="s2">wgpu_subscriber</span><span class="s3">;</span>
|
||
|
<a name="l45"><span class="ln">45 </span></a><span class="s0">use </span><span class="s2">winit_24</span><span class="s1">::</span><span class="s2">event</span><span class="s1">::</span><span class="s2">DeviceEvent</span><span class="s1">::</span><span class="s2">MouseMotion</span><span class="s3">;</span>
|
||
|
<a name="l46"><span class="ln">46 </span></a><span class="s0">use </span><span class="s2">winit_24</span><span class="s1">::</span><span class="s2">event</span><span class="s1">::{</span><span class="s2">ElementState</span><span class="s3">, </span><span class="s2">VirtualKeyCode</span><span class="s1">}</span><span class="s3">;</span>
|
||
|
<a name="l47"><span class="ln">47 </span></a><span class="s0">use </span><span class="s2">winit_24</span><span class="s1">::</span><span class="s2">event_loop</span><span class="s1">::</span><span class="s2">EventLoopProxy</span><span class="s3">;</span>
|
||
|
<a name="l48"><span class="ln">48 </span></a><span class="s0">use </span><span class="s2">winit_24</span><span class="s1">::</span><span class="s2">platform</span><span class="s1">::</span><span class="s2">unix</span><span class="s1">::</span><span class="s2">x11</span><span class="s1">::</span><span class="s2">ffi</span><span class="s1">::</span><span class="s2">Time</span><span class="s3">;</span>
|
||
|
<a name="l49"><span class="ln">49 </span></a><span class="s0">use </span><span class="s2">winit_24</span><span class="s1">::</span><span class="s2">window</span><span class="s1">::</span><span class="s2">Window</span><span class="s3">;</span>
|
||
|
<a name="l50"><span class="ln">50 </span></a><span class="s0">use </span><span class="s2">winit_24</span><span class="s1">::{</span>
|
||
|
<a name="l51"><span class="ln">51 </span></a> <span class="s2">event</span><span class="s1">::{</span><span class="s0">self</span><span class="s3">, </span><span class="s2">WindowEvent</span><span class="s1">}</span><span class="s3">,</span>
|
||
|
<a name="l52"><span class="ln">52 </span></a> <span class="s2">event_loop</span><span class="s1">::{</span><span class="s2">ControlFlow</span><span class="s3">, </span><span class="s2">EventLoop</span><span class="s1">}</span><span class="s3">,</span>
|
||
|
<a name="l53"><span class="ln">53 </span></a><span class="s1">}</span><span class="s3">;</span>
|
||
|
<a name="l54"><span class="ln">54 </span></a>
|
||
|
<a name="l55"><span class="ln">55 </span></a><span class="s0">use crate</span><span class="s1">::</span><span class="s2">camera</span><span class="s1">::{</span><span class="s2">Camera</span><span class="s3">, </span><span class="s2">CameraController</span><span class="s1">}</span><span class="s3">;</span>
|
||
|
<a name="l56"><span class="ln">56 </span></a><span class="s0">use crate</span><span class="s1">::</span><span class="s2">components</span><span class="s1">::{</span><span class="s2">Collider</span><span class="s3">, </span><span class="s2">ImguiWindow</span><span class="s3">, </span><span class="s2">LoopState</span><span class="s3">, </span><span class="s2">Physics</span><span class="s3">, </span><span class="s2">Position</span><span class="s1">}</span><span class="s3">;</span>
|
||
|
<a name="l57"><span class="ln">57 </span></a><span class="s0">use crate</span><span class="s1">::</span><span class="s2">geometry</span><span class="s1">::{</span><span class="s2">load_obj</span><span class="s3">, </span><span class="s2">RawMesh</span><span class="s1">}</span><span class="s3">;</span>
|
||
|
<a name="l58"><span class="ln">58 </span></a><span class="s0">use crate</span><span class="s1">::</span><span class="s2">imgui_supp</span><span class="s1">::</span><span class="s2">extended_winit_imgui_support</span><span class="s3">;</span>
|
||
|
<a name="l59"><span class="ln">59 </span></a><span class="s0">use crate</span><span class="s1">::</span><span class="s2">imgui_supp</span><span class="s1">::</span><span class="s2">imgui_support</span><span class="s1">::{</span><span class="s2">ImguiContext</span><span class="s3">, </span><span class="s2">ImguiPlatform</span><span class="s1">}</span><span class="s3">;</span>
|
||
|
<a name="l60"><span class="ln">60 </span></a><span class="s0">use crate</span><span class="s1">::</span><span class="s2">owned_event</span><span class="s1">::{</span><span class="s2">OwnedEvent</span><span class="s3">, </span><span class="s2">OwnedEventExtension</span><span class="s1">}</span><span class="s3">;</span>
|
||
|
<a name="l61"><span class="ln">61 </span></a><span class="s0">use crate</span><span class="s1">::</span><span class="s2">physics</span><span class="s1">::</span><span class="s2">state</span><span class="s1">::</span><span class="s2">PhysicsState</span><span class="s3">;</span>
|
||
|
<a name="l62"><span class="ln">62 </span></a><span class="s0">use crate</span><span class="s1">::</span><span class="s2">render</span><span class="s1">::</span><span class="s2">system</span><span class="s1">::</span><span class="s2">ImguiPerformanceProfilerLine</span><span class="s3">;</span>
|
||
|
<a name="l63"><span class="ln">63 </span></a><span class="s0">use crate</span><span class="s1">::</span><span class="s2">runtime</span><span class="s1">::</span><span class="s2">state</span><span class="s1">::</span><span class="s2">RuntimeState</span><span class="s3">;</span>
|
||
|
<a name="l64"><span class="ln">64 </span></a><span class="s0">use </span><span class="s2">winit_24</span><span class="s1">::</span><span class="s2">dpi</span><span class="s1">::</span><span class="s2">PhysicalSize</span><span class="s3">;</span>
|
||
|
<a name="l65"><span class="ln">65 </span></a>
|
||
|
<a name="l66"><span class="ln">66 </span></a><span class="s0">mod </span><span class="s2">camera</span><span class="s3">;</span>
|
||
|
<a name="l67"><span class="ln">67 </span></a><span class="s0">mod </span><span class="s2">components</span><span class="s3">;</span>
|
||
|
<a name="l68"><span class="ln">68 </span></a><span class="s0">mod </span><span class="s2">geometry</span><span class="s3">;</span>
|
||
|
<a name="l69"><span class="ln">69 </span></a><span class="s0">mod </span><span class="s2">imgui_supp</span><span class="s3">;</span>
|
||
|
<a name="l70"><span class="ln">70 </span></a><span class="s0">mod </span><span class="s2">light</span><span class="s3">;</span>
|
||
|
<a name="l71"><span class="ln">71 </span></a><span class="s0">mod </span><span class="s2">owned_event</span><span class="s3">;</span>
|
||
|
<a name="l72"><span class="ln">72 </span></a><span class="s0">mod </span><span class="s2">physics</span><span class="s3">;</span>
|
||
|
<a name="l73"><span class="ln">73 </span></a><span class="s0">mod </span><span class="s2">render</span><span class="s3">;</span>
|
||
|
<a name="l74"><span class="ln">74 </span></a><span class="s0">mod </span><span class="s2">runtime</span><span class="s3">;</span>
|
||
|
<a name="l75"><span class="ln">75 </span></a>
|
||
|
<a name="l76"><span class="ln">76 </span></a><span class="s5">/*
|
||
|
<a name="l77"><span class="ln">77 </span></a>
|
||
|
<a name="l78"><span class="ln">78 </span></a>Collision detection
|
||
|
<a name="l79"><span class="ln">79 </span></a>https://nphysics.org/rigid_body_simulations_with_contacts/
|
||
|
<a name="l80"><span class="ln">80 </span></a>
|
||
|
<a name="l81"><span class="ln">81 </span></a>Obj file format
|
||
|
<a name="l82"><span class="ln">82 </span></a>http://paulbourke.net/dataformats/obj/
|
||
|
<a name="l83"><span class="ln">83 </span></a>
|
||
|
<a name="l84"><span class="ln">84 </span></a>tobj obj loader
|
||
|
<a name="l85"><span class="ln">85 </span></a>https://docs.rs/tobj/2.0.3/tobj/index.html
|
||
|
<a name="l86"><span class="ln">86 </span></a>
|
||
|
<a name="l87"><span class="ln">87 </span></a>mesh generator lib, might be useful
|
||
|
<a name="l88"><span class="ln">88 </span></a>https://docs.rs/genmesh/0.6.2/genmesh/
|
||
|
<a name="l89"><span class="ln">89 </span></a>
|
||
|
<a name="l90"><span class="ln">90 </span></a>legion ECS
|
||
|
<a name="l91"><span class="ln">91 </span></a>https://github.com/amethyst/legion
|
||
|
<a name="l92"><span class="ln">92 </span></a>
|
||
|
<a name="l93"><span class="ln">93 </span></a>
|
||
|
<a name="l94"><span class="ln">94 </span></a>ECS
|
||
|
<a name="l95"><span class="ln">95 </span></a> animation
|
||
|
<a name="l96"><span class="ln">96 </span></a> config / save loading (sorta!)
|
||
|
<a name="l97"><span class="ln">97 </span></a> render 3d (good!)
|
||
|
<a name="l98"><span class="ln">98 </span></a> input/io (yep!)
|
||
|
<a name="l99"><span class="ln">99 </span></a> collision / physics (yep!)
|
||
|
<a name="l100"><span class="ln">100 </span></a> entities & behaviours (got the entities!)
|
||
|
<a name="l101"><span class="ln">101 </span></a> scripting!
|
||
|
<a name="l102"><span class="ln">102 </span></a>
|
||
|
<a name="l103"><span class="ln">103 </span></a>
|
||
|
<a name="l104"><span class="ln">104 </span></a>Todo:
|
||
|
<a name="l105"><span class="ln">105 </span></a> Load scene imgui interface w/ toml files
|
||
|
<a name="l106"><span class="ln">106 </span></a> FPS graph port from voxel raycaster
|
||
|
<a name="l107"><span class="ln">107 </span></a> better imgui interface with components & systems
|
||
|
<a name="l108"><span class="ln">108 </span></a> Figure out eventing, GameInput, passing all events, etc.
|
||
|
<a name="l109"><span class="ln">109 </span></a> + texturing
|
||
|
<a name="l110"><span class="ln">110 </span></a>
|
||
|
<a name="l111"><span class="ln">111 </span></a>I need to figure out the way that I want to do 2d graphics in a 3d engine...
|
||
|
<a name="l112"><span class="ln">112 </span></a>I suppose I will need sprites. And those are just 2 polygons which are textured
|
||
|
<a name="l113"><span class="ln">113 </span></a>
|
||
|
<a name="l114"><span class="ln">114 </span></a>
|
||
|
<a name="l115"><span class="ln">115 </span></a>
|
||
|
<a name="l116"><span class="ln">116 </span></a> */</span>
|
||
|
<a name="l117"><span class="ln">117 </span></a>
|
||
|
<a name="l118"><span class="ln">118 </span></a><span class="s5">//log::info!("");</span>
|
||
|
<a name="l119"><span class="ln">119 </span></a>
|
||
|
<a name="l120"><span class="ln">120 </span></a><span class="s5">// ImGUI works on more or less an unsafe global state. which is MegaLame</span>
|
||
|
<a name="l121"><span class="ln">121 </span></a><span class="s0">static mut </span><span class="s2">CURRENT_UI</span><span class="s1">: </span><span class="s2">Option</span><span class="s1"><</span><span class="s2">imgui</span><span class="s1">::</span><span class="s2">Ui</span><span class="s1"><</span><span class="s6">'static</span><span class="s1">>> = </span><span class="s2">None</span><span class="s3">;</span>
|
||
|
<a name="l122"><span class="ln">122 </span></a><span class="s0">pub unsafe fn </span><span class="s2">current_ui</span><span class="s1"><</span><span class="s6">'a</span><span class="s1">>() -> </span><span class="s2">Option</span><span class="s1"><&</span><span class="s6">'a </span><span class="s2">imgui</span><span class="s1">::</span><span class="s2">Ui</span><span class="s1"><</span><span class="s6">'a</span><span class="s1">>> {</span>
|
||
|
<a name="l123"><span class="ln">123 </span></a> <span class="s2">CURRENT_UI</span><span class="s1">.</span><span class="s2">as_ref</span><span class="s1">()</span>
|
||
|
<a name="l124"><span class="ln">124 </span></a><span class="s1">}</span>
|
||
|
<a name="l125"><span class="ln">125 </span></a>
|
||
|
<a name="l126"><span class="ln">126 </span></a>
|
||
|
<a name="l127"><span class="ln">127 </span></a>
|
||
|
<a name="l128"><span class="ln">128 </span></a><span class="s0">fn </span><span class="s2">main</span><span class="s1">() {</span>
|
||
|
<a name="l129"><span class="ln">129 </span></a> <span class="s0">let </span><span class="s2">logger </span><span class="s1">= </span><span class="s2">env_logger</span><span class="s1">::</span><span class="s2">builder</span><span class="s1">()</span>
|
||
|
<a name="l130"><span class="ln">130 </span></a> <span class="s1">.</span><span class="s2">filter</span><span class="s1">(</span><span class="s2">Some</span><span class="s1">(</span><span class="s4">"minimal_viable_game_engine"</span><span class="s1">)</span><span class="s3">, </span><span class="s2">LevelFilter</span><span class="s1">::</span><span class="s2">Info</span><span class="s1">)</span>
|
||
|
<a name="l131"><span class="ln">131 </span></a> <span class="s1">.</span><span class="s2">init</span><span class="s1">()</span><span class="s3">;</span>
|
||
|
<a name="l132"><span class="ln">132 </span></a>
|
||
|
<a name="l133"><span class="ln">133 </span></a> <span class="s0">let mut </span><span class="s2">world </span><span class="s1">= </span><span class="s2">World</span><span class="s1">::</span><span class="s2">default</span><span class="s1">()</span><span class="s3">;</span>
|
||
|
<a name="l134"><span class="ln">134 </span></a>
|
||
|
<a name="l135"><span class="ln">135 </span></a> <span class="s0">let mut </span><span class="s2">imgui_prepare_schedule </span><span class="s1">= </span><span class="s2">Schedule</span><span class="s1">::</span><span class="s2">builder</span><span class="s1">()</span>
|
||
|
<a name="l136"><span class="ln">136 </span></a> <span class="s1">.</span><span class="s2">add_system</span><span class="s1">(</span><span class="s2">render</span><span class="s1">::</span><span class="s2">system</span><span class="s1">::</span><span class="s2">imgui_prepare_system</span><span class="s1">())</span>
|
||
|
<a name="l137"><span class="ln">137 </span></a> <span class="s1">.</span><span class="s2">build</span><span class="s1">()</span><span class="s3">;</span>
|
||
|
<a name="l138"><span class="ln">138 </span></a>
|
||
|
<a name="l139"><span class="ln">139 </span></a> <span class="s0">let mut </span><span class="s2">load_schedule </span><span class="s1">= </span><span class="s2">Schedule</span><span class="s1">::</span><span class="s2">builder</span><span class="s1">()</span>
|
||
|
<a name="l140"><span class="ln">140 </span></a> <span class="s1">.</span><span class="s2">add_system</span><span class="s1">(</span><span class="s2">runtime</span><span class="s1">::</span><span class="s2">system</span><span class="s1">::</span><span class="s2">runtime_load_system</span><span class="s1">())</span>
|
||
|
<a name="l141"><span class="ln">141 </span></a> <span class="s1">.</span><span class="s2">add_system</span><span class="s1">(</span><span class="s2">runtime</span><span class="s1">::</span><span class="s2">system</span><span class="s1">::</span><span class="s2">runtime_spawn_system</span><span class="s1">())</span>
|
||
|
<a name="l142"><span class="ln">142 </span></a> <span class="s1">.</span><span class="s2">flush</span><span class="s1">()</span>
|
||
|
<a name="l143"><span class="ln">143 </span></a> <span class="s1">.</span><span class="s2">build</span><span class="s1">()</span><span class="s3">;</span>
|
||
|
<a name="l144"><span class="ln">144 </span></a>
|
||
|
<a name="l145"><span class="ln">145 </span></a> <span class="s0">let mut </span><span class="s2">render_schedule </span><span class="s1">= </span><span class="s2">Schedule</span><span class="s1">::</span><span class="s2">builder</span><span class="s1">()</span>
|
||
|
<a name="l146"><span class="ln">146 </span></a> <span class="s1">.</span><span class="s2">add_system</span><span class="s1">(</span><span class="s2">render</span><span class="s1">::</span><span class="s2">system</span><span class="s1">::</span><span class="s2">render_imgui_system</span><span class="s1">())</span>
|
||
|
<a name="l147"><span class="ln">147 </span></a> <span class="s1">.</span><span class="s2">add_system</span><span class="s1">(</span><span class="s2">render</span><span class="s1">::</span><span class="s2">system</span><span class="s1">::</span><span class="s2">render_test_system</span><span class="s1">())</span>
|
||
|
<a name="l148"><span class="ln">148 </span></a> <span class="s1">.</span><span class="s2">add_system</span><span class="s1">(</span><span class="s2">render</span><span class="s1">::</span><span class="s2">system</span><span class="s1">::</span><span class="s2">render_performance_flag_system</span><span class="s1">())</span>
|
||
|
<a name="l149"><span class="ln">149 </span></a> <span class="s1">.</span><span class="s2">build</span><span class="s1">()</span><span class="s3">;</span>
|
||
|
<a name="l150"><span class="ln">150 </span></a>
|
||
|
<a name="l151"><span class="ln">151 </span></a> <span class="s0">let mut </span><span class="s2">update_schedule </span><span class="s1">= </span><span class="s2">Schedule</span><span class="s1">::</span><span class="s2">builder</span><span class="s1">()</span>
|
||
|
<a name="l152"><span class="ln">152 </span></a> <span class="s1">.</span><span class="s2">add_system</span><span class="s1">(</span><span class="s2">physics</span><span class="s1">::</span><span class="s2">system</span><span class="s1">::</span><span class="s2">update_camera_system</span><span class="s1">())</span>
|
||
|
<a name="l153"><span class="ln">153 </span></a> <span class="s1">.</span><span class="s2">add_system</span><span class="s1">(</span><span class="s2">physics</span><span class="s1">::</span><span class="s2">system</span><span class="s1">::</span><span class="s2">run_physics_system</span><span class="s1">())</span>
|
||
|
<a name="l154"><span class="ln">154 </span></a> <span class="s1">.</span><span class="s2">add_system</span><span class="s1">(</span><span class="s2">physics</span><span class="s1">::</span><span class="s2">system</span><span class="s1">::</span><span class="s2">update_models_system</span><span class="s1">())</span>
|
||
|
<a name="l155"><span class="ln">155 </span></a> <span class="s5">// next system here, gamelogic update system?</span>
|
||
|
<a name="l156"><span class="ln">156 </span></a> <span class="s1">.</span><span class="s2">build</span><span class="s1">()</span><span class="s3">;</span>
|
||
|
<a name="l157"><span class="ln">157 </span></a>
|
||
|
<a name="l158"><span class="ln">158 </span></a> <span class="s0">let mut </span><span class="s2">event_schedule </span><span class="s1">= </span><span class="s2">Schedule</span><span class="s1">::</span><span class="s2">builder</span><span class="s1">()</span>
|
||
|
<a name="l159"><span class="ln">159 </span></a> <span class="s1">.</span><span class="s2">add_system</span><span class="s1">(</span><span class="s2">owned_event</span><span class="s1">::</span><span class="s2">event_dispatch_system</span><span class="s1">())</span>
|
||
|
<a name="l160"><span class="ln">160 </span></a> <span class="s1">.</span><span class="s2">build</span><span class="s1">()</span><span class="s3">;</span>
|
||
|
<a name="l161"><span class="ln">161 </span></a>
|
||
|
<a name="l162"><span class="ln">162 </span></a> <span class="s0">let </span><span class="s2">event_loop </span><span class="s1">= </span><span class="s2">EventLoop</span><span class="s1">::<</span><span class="s2">OwnedEventExtension</span><span class="s1">>::</span><span class="s2">with_user_event</span><span class="s1">()</span><span class="s3">;</span>
|
||
|
<a name="l163"><span class="ln">163 </span></a> <span class="s0">let mut </span><span class="s2">builder </span><span class="s1">= </span><span class="s2">winit_24</span><span class="s1">::</span><span class="s2">window</span><span class="s1">::</span><span class="s2">WindowBuilder</span><span class="s1">::</span><span class="s2">new</span><span class="s1">()</span><span class="s3">;</span>
|
||
|
<a name="l164"><span class="ln">164 </span></a> <span class="s2">builder </span><span class="s1">= </span><span class="s2">builder</span><span class="s1">.</span><span class="s2">with_title</span><span class="s1">(</span><span class="s4">"MVGE"</span><span class="s1">)</span><span class="s3">;</span>
|
||
|
<a name="l165"><span class="ln">165 </span></a> <span class="s2">builder </span><span class="s1">= </span><span class="s2">builder</span><span class="s1">.</span><span class="s2">with_inner_size</span><span class="s1">(</span><span class="s2">PhysicalSize</span><span class="s1">::</span><span class="s2">new</span><span class="s1">(</span><span class="s7">1200</span><span class="s3">,</span><span class="s7">900</span><span class="s1">))</span><span class="s3">;</span>
|
||
|
<a name="l166"><span class="ln">166 </span></a>
|
||
|
<a name="l167"><span class="ln">167 </span></a> <span class="s0">let </span><span class="s2">window </span><span class="s1">= </span><span class="s2">builder</span><span class="s1">.</span><span class="s2">build</span><span class="s1">(&</span><span class="s2">event_loop</span><span class="s1">).</span><span class="s2">unwrap</span><span class="s1">()</span><span class="s3">;</span>
|
||
|
<a name="l168"><span class="ln">168 </span></a>
|
||
|
<a name="l169"><span class="ln">169 </span></a> <span class="s0">let mut </span><span class="s2">resources </span><span class="s1">= </span><span class="s2">Resources</span><span class="s1">::</span><span class="s2">default</span><span class="s1">()</span><span class="s3">;</span>
|
||
|
<a name="l170"><span class="ln">170 </span></a>
|
||
|
<a name="l171"><span class="ln">171 </span></a>
|
||
|
<a name="l172"><span class="ln">172 </span></a>
|
||
|
<a name="l173"><span class="ln">173 </span></a> <span class="s5">// Load up all the resources</span>
|
||
|
<a name="l174"><span class="ln">174 </span></a> <span class="s1">{</span>
|
||
|
<a name="l175"><span class="ln">175 </span></a> <span class="s0">let mut </span><span class="s2">imgui_context </span><span class="s1">= </span><span class="s2">imgui</span><span class="s1">::</span><span class="s2">Context</span><span class="s1">::</span><span class="s2">create</span><span class="s1">()</span><span class="s3">;</span>
|
||
|
<a name="l176"><span class="ln">176 </span></a> <span class="s0">let mut </span><span class="s2">platform </span><span class="s1">= </span><span class="s2">extended_winit_imgui_support</span><span class="s1">::</span><span class="s2">WinitPlatform</span><span class="s1">::</span><span class="s2">init</span><span class="s1">(&</span><span class="s0">mut </span><span class="s2">imgui_context</span><span class="s1">)</span><span class="s3">;</span>
|
||
|
<a name="l177"><span class="ln">177 </span></a> <span class="s2">platform</span><span class="s1">.</span><span class="s2">attach_window</span><span class="s1">(</span>
|
||
|
<a name="l178"><span class="ln">178 </span></a> <span class="s2">imgui_context</span><span class="s1">.</span><span class="s2">io_mut</span><span class="s1">()</span><span class="s3">,</span>
|
||
|
<a name="l179"><span class="ln">179 </span></a> <span class="s1">&</span><span class="s2">window</span><span class="s3">,</span>
|
||
|
<a name="l180"><span class="ln">180 </span></a> <span class="s2">extended_winit_imgui_support</span><span class="s1">::</span><span class="s2">HiDpiMode</span><span class="s1">::</span><span class="s2">Default</span><span class="s3">,</span>
|
||
|
<a name="l181"><span class="ln">181 </span></a> <span class="s1">)</span><span class="s3">;</span>
|
||
|
<a name="l182"><span class="ln">182 </span></a>
|
||
|
<a name="l183"><span class="ln">183 </span></a> <span class="s5">// imgui_supp rendering context</span>
|
||
|
<a name="l184"><span class="ln">184 </span></a> <span class="s0">let mut </span><span class="s2">imgui_context </span><span class="s1">= </span><span class="s2">ImguiContext </span><span class="s1">{</span>
|
||
|
<a name="l185"><span class="ln">185 </span></a> <span class="s2">context</span><span class="s1">: </span><span class="s2">imgui_context</span><span class="s3">,</span>
|
||
|
<a name="l186"><span class="ln">186 </span></a> <span class="s1">}</span><span class="s3">;</span>
|
||
|
<a name="l187"><span class="ln">187 </span></a> <span class="s0">let mut </span><span class="s2">imgui_platform </span><span class="s1">= </span><span class="s2">ImguiPlatform </span><span class="s1">{ </span><span class="s2">platform</span><span class="s1">: </span><span class="s2">platform </span><span class="s1">}</span><span class="s3">;</span>
|
||
|
<a name="l188"><span class="ln">188 </span></a> <span class="s0">let </span><span class="s2">font_size </span><span class="s1">= </span><span class="s7">20</span><span class="s1">.</span><span class="s7">0 </span><span class="s0">as </span><span class="s2">f32</span><span class="s3">;</span>
|
||
|
<a name="l189"><span class="ln">189 </span></a> <span class="s2">imgui_context</span><span class="s1">.</span><span class="s2">context</span><span class="s1">.</span><span class="s2">io_mut</span><span class="s1">().</span><span class="s2">font_global_scale </span><span class="s1">= </span><span class="s7">1</span><span class="s1">.</span><span class="s7">0 </span><span class="s0">as </span><span class="s2">f32</span><span class="s3">;</span>
|
||
|
<a name="l190"><span class="ln">190 </span></a> <span class="s2">imgui_context</span>
|
||
|
<a name="l191"><span class="ln">191 </span></a> <span class="s1">.</span><span class="s2">context</span>
|
||
|
<a name="l192"><span class="ln">192 </span></a> <span class="s1">.</span><span class="s2">fonts</span><span class="s1">()</span>
|
||
|
<a name="l193"><span class="ln">193 </span></a> <span class="s1">.</span><span class="s2">add_font</span><span class="s1">(&[</span><span class="s2">FontSource</span><span class="s1">::</span><span class="s2">DefaultFontData </span><span class="s1">{</span>
|
||
|
<a name="l194"><span class="ln">194 </span></a> <span class="s2">config</span><span class="s1">: </span><span class="s2">Some</span><span class="s1">(</span><span class="s2">imgui</span><span class="s1">::</span><span class="s2">FontConfig </span><span class="s1">{</span>
|
||
|
<a name="l195"><span class="ln">195 </span></a> <span class="s2">oversample_h</span><span class="s1">: </span><span class="s7">1</span><span class="s3">,</span>
|
||
|
<a name="l196"><span class="ln">196 </span></a> <span class="s2">pixel_snap_h</span><span class="s1">: </span><span class="s0">true</span><span class="s3">,</span>
|
||
|
<a name="l197"><span class="ln">197 </span></a> <span class="s2">size_pixels</span><span class="s1">: </span><span class="s2">font_size</span><span class="s3">,</span>
|
||
|
<a name="l198"><span class="ln">198 </span></a> <span class="s1">..</span><span class="s2">Default</span><span class="s1">::</span><span class="s2">default</span><span class="s1">()</span>
|
||
|
<a name="l199"><span class="ln">199 </span></a> <span class="s1">})</span><span class="s3">,</span>
|
||
|
<a name="l200"><span class="ln">200 </span></a> <span class="s1">}])</span><span class="s3">;</span>
|
||
|
<a name="l201"><span class="ln">201 </span></a> <span class="s2">imgui_context</span><span class="s1">.</span><span class="s2">context</span><span class="s1">.</span><span class="s2">set_ini_filename</span><span class="s1">(</span><span class="s2">None</span><span class="s1">)</span><span class="s3">;</span>
|
||
|
<a name="l202"><span class="ln">202 </span></a>
|
||
|
<a name="l203"><span class="ln">203 </span></a> <span class="s5">// The renderer</span>
|
||
|
<a name="l204"><span class="ln">204 </span></a> <span class="s0">let mut </span><span class="s2">renderer </span><span class="s1">= </span><span class="s2">render</span><span class="s1">::</span><span class="s2">state</span><span class="s1">::</span><span class="s2">RenderState</span><span class="s1">::</span><span class="s2">init</span><span class="s1">(&</span><span class="s2">window</span><span class="s3">, </span><span class="s1">&</span><span class="s0">mut </span><span class="s2">imgui_context</span><span class="s1">)</span><span class="s3">;</span>
|
||
|
<a name="l205"><span class="ln">205 </span></a>
|
||
|
<a name="l206"><span class="ln">206 </span></a> <span class="s2">resources</span><span class="s1">.</span><span class="s2">insert</span><span class="s1">(</span><span class="s2">renderer</span><span class="s1">)</span><span class="s3">;</span>
|
||
|
<a name="l207"><span class="ln">207 </span></a> <span class="s2">resources</span><span class="s1">.</span><span class="s2">insert</span><span class="s1">(</span><span class="s2">Arc</span><span class="s1">::</span><span class="s2">new</span><span class="s1">(</span><span class="s2">Mutex</span><span class="s1">::</span><span class="s2">new</span><span class="s1">(</span><span class="s2">imgui_context</span><span class="s1">)))</span><span class="s3">;</span>
|
||
|
<a name="l208"><span class="ln">208 </span></a> <span class="s2">resources</span><span class="s1">.</span><span class="s2">insert</span><span class="s1">(</span><span class="s2">Arc</span><span class="s1">::</span><span class="s2">new</span><span class="s1">(</span><span class="s2">Mutex</span><span class="s1">::</span><span class="s2">new</span><span class="s1">(</span><span class="s2">imgui_platform</span><span class="s1">)))</span><span class="s3">;</span>
|
||
|
<a name="l209"><span class="ln">209 </span></a> <span class="s2">resources</span><span class="s1">.</span><span class="s2">insert</span><span class="s1">(</span><span class="s2">window</span><span class="s1">)</span><span class="s3">;</span>
|
||
|
<a name="l210"><span class="ln">210 </span></a>
|
||
|
<a name="l211"><span class="ln">211 </span></a> <span class="s5">// Physics</span>
|
||
|
<a name="l212"><span class="ln">212 </span></a> <span class="s0">let </span><span class="s1">(</span><span class="s2">physics_state</span><span class="s3">, </span><span class="s2">physics_pipeline</span><span class="s1">) =</span>
|
||
|
<a name="l213"><span class="ln">213 </span></a> <span class="s2">PhysicsState</span><span class="s1">::</span><span class="s2">build</span><span class="s1">(</span><span class="s2">rapier3d</span><span class="s1">::</span><span class="s2">math</span><span class="s1">::</span><span class="s2">Vector</span><span class="s1">::</span><span class="s2">new</span><span class="s1">(</span><span class="s7">0</span><span class="s1">.</span><span class="s7">0</span><span class="s3">, </span><span class="s1">-</span><span class="s7">9</span><span class="s1">.</span><span class="s7">81</span><span class="s3">, </span><span class="s7">0</span><span class="s1">.</span><span class="s7">0</span><span class="s1">))</span><span class="s3">;</span>
|
||
|
<a name="l214"><span class="ln">214 </span></a> <span class="s2">resources</span><span class="s1">.</span><span class="s2">insert</span><span class="s1">(</span><span class="s2">physics_state</span><span class="s1">)</span><span class="s3">;</span>
|
||
|
<a name="l215"><span class="ln">215 </span></a> <span class="s2">resources</span><span class="s1">.</span><span class="s2">insert</span><span class="s1">(</span><span class="s2">physics_pipeline</span><span class="s1">)</span><span class="s3">;</span>
|
||
|
<a name="l216"><span class="ln">216 </span></a>
|
||
|
<a name="l217"><span class="ln">217 </span></a> <span class="s5">// Loop data</span>
|
||
|
<a name="l218"><span class="ln">218 </span></a> <span class="s2">resources</span><span class="s1">.</span><span class="s2">insert</span><span class="s1">(</span><span class="s2">LoopState </span><span class="s1">{</span>
|
||
|
<a name="l219"><span class="ln">219 </span></a> <span class="s2">delta_time</span><span class="s1">: </span><span class="s2">Default</span><span class="s1">::</span><span class="s2">default</span><span class="s1">()</span><span class="s3">,</span>
|
||
|
<a name="l220"><span class="ln">220 </span></a> <span class="s2">start_time</span><span class="s1">: </span><span class="s2">Instant</span><span class="s1">::</span><span class="s2">now</span><span class="s1">()</span><span class="s3">,</span>
|
||
|
<a name="l221"><span class="ln">221 </span></a> <span class="s2">step_size</span><span class="s1">: </span><span class="s7">0</span><span class="s1">.</span><span class="s7">01666</span><span class="s3">, </span><span class="s5">// 60hz</span>
|
||
|
<a name="l222"><span class="ln">222 </span></a> <span class="s1">})</span><span class="s3">;</span>
|
||
|
<a name="l223"><span class="ln">223 </span></a>
|
||
|
<a name="l224"><span class="ln">224 </span></a> <span class="s5">// And our event stack</span>
|
||
|
<a name="l225"><span class="ln">225 </span></a> <span class="s2">resources</span><span class="s1">.</span><span class="s2">insert</span><span class="s1">(</span><span class="s2">Vec</span><span class="s1">::<</span><span class="s2">OwnedEvent</span><span class="s1"><</span><span class="s2">OwnedEventExtension</span><span class="s1">>>::</span><span class="s2">new</span><span class="s1">())</span><span class="s3">;</span>
|
||
|
<a name="l226"><span class="ln">226 </span></a>
|
||
|
<a name="l227"><span class="ln">227 </span></a> <span class="s5">// Our init and runtime data</span>
|
||
|
<a name="l228"><span class="ln">228 </span></a> <span class="s2">resources</span><span class="s1">.</span><span class="s2">insert</span><span class="s1">(</span><span class="s2">RuntimeState</span><span class="s1">::</span><span class="s2">new</span><span class="s1">())</span>
|
||
|
<a name="l229"><span class="ln">229 </span></a> <span class="s1">}</span><span class="s3">;</span>
|
||
|
<a name="l230"><span class="ln">230 </span></a>
|
||
|
<a name="l231"><span class="ln">231 </span></a> <span class="s2">setup_gamepad</span><span class="s1">(&</span><span class="s2">event_loop</span><span class="s1">)</span><span class="s3">;</span>
|
||
|
<a name="l232"><span class="ln">232 </span></a>
|
||
|
<a name="l233"><span class="ln">233 </span></a> <span class="s0">let mut </span><span class="s2">elapsed_time</span><span class="s1">: </span><span class="s2">f32 </span><span class="s1">= {</span>
|
||
|
<a name="l234"><span class="ln">234 </span></a> <span class="s5">// deltatime since last frame</span>
|
||
|
<a name="l235"><span class="ln">235 </span></a> <span class="s0">let </span><span class="s2">loop_state </span><span class="s1">= </span><span class="s2">resources</span><span class="s1">.</span><span class="s2">get</span><span class="s1">::<</span><span class="s2">LoopState</span><span class="s1">>().</span><span class="s2">unwrap</span><span class="s1">()</span><span class="s3">;</span>
|
||
|
<a name="l236"><span class="ln">236 </span></a> <span class="s2">loop_state</span><span class="s1">.</span><span class="s2">start_time</span><span class="s1">.</span><span class="s2">elapsed</span><span class="s1">()</span>
|
||
|
<a name="l237"><span class="ln">237 </span></a> <span class="s1">}</span>
|
||
|
<a name="l238"><span class="ln">238 </span></a> <span class="s1">.</span><span class="s2">as_secs_f32</span><span class="s1">()</span><span class="s3">;</span>
|
||
|
<a name="l239"><span class="ln">239 </span></a>
|
||
|
<a name="l240"><span class="ln">240 </span></a> <span class="s0">let mut </span><span class="s2">delta_time</span><span class="s1">: </span><span class="s2">f32 </span><span class="s1">= </span><span class="s7">0</span><span class="s1">.</span><span class="s7">0</span><span class="s3">;</span>
|
||
|
<a name="l241"><span class="ln">241 </span></a> <span class="s0">let mut </span><span class="s2">accumulator_time</span><span class="s1">: </span><span class="s2">f32 </span><span class="s1">= </span><span class="s7">0</span><span class="s1">.</span><span class="s7">0</span><span class="s3">;</span>
|
||
|
<a name="l242"><span class="ln">242 </span></a> <span class="s0">let mut </span><span class="s2">current_time</span><span class="s1">: </span><span class="s2">f32 </span><span class="s1">= </span><span class="s2">elapsed_time</span><span class="s3">;</span>
|
||
|
<a name="l243"><span class="ln">243 </span></a>
|
||
|
<a name="l244"><span class="ln">244 </span></a> <span class="s2">event_loop</span><span class="s1">.</span><span class="s2">run</span><span class="s1">(</span><span class="s0">move </span><span class="s1">|</span><span class="s2">event</span><span class="s3">, </span><span class="s2">_</span><span class="s3">, </span><span class="s2">control_flow</span><span class="s1">| {</span>
|
||
|
<a name="l245"><span class="ln">245 </span></a> <span class="s1">*</span><span class="s2">control_flow </span><span class="s1">= </span><span class="s2">ControlFlow</span><span class="s1">::</span><span class="s2">Poll</span><span class="s3">;</span>
|
||
|
<a name="l246"><span class="ln">246 </span></a> <span class="s0">match </span><span class="s2">event </span><span class="s1">{</span>
|
||
|
<a name="l247"><span class="ln">247 </span></a> <span class="s2">event</span><span class="s1">::</span><span class="s2">Event</span><span class="s1">::</span><span class="s2">NewEvents</span><span class="s1">(</span><span class="s2">cause</span><span class="s1">) => {</span>
|
||
|
<a name="l248"><span class="ln">248 </span></a> <span class="s0">if </span><span class="s2">cause </span><span class="s1">== </span><span class="s2">winit_24</span><span class="s1">::</span><span class="s2">event</span><span class="s1">::</span><span class="s2">StartCause</span><span class="s1">::</span><span class="s2">Init </span><span class="s1">{</span>
|
||
|
<a name="l249"><span class="ln">249 </span></a> <span class="s2">load_schedule</span><span class="s1">.</span><span class="s2">execute</span><span class="s1">(&</span><span class="s0">mut </span><span class="s2">world</span><span class="s3">, </span><span class="s1">&</span><span class="s0">mut </span><span class="s2">resources</span><span class="s1">)</span><span class="s3">;</span>
|
||
|
<a name="l250"><span class="ln">250 </span></a> <span class="s1">}</span>
|
||
|
<a name="l251"><span class="ln">251 </span></a> <span class="s1">}</span>
|
||
|
<a name="l252"><span class="ln">252 </span></a>
|
||
|
<a name="l253"><span class="ln">253 </span></a> <span class="s5">// This is the big boy section of the event loop</span>
|
||
|
<a name="l254"><span class="ln">254 </span></a> <span class="s5">// We : dispatch events and clear the queue, query the loops</span>
|
||
|
<a name="l255"><span class="ln">255 </span></a> <span class="s5">// time data and prep the dt data. Loop the dt locked</span>
|
||
|
<a name="l256"><span class="ln">256 </span></a> <span class="s5">// conditionally, and run the fps locked renderer</span>
|
||
|
<a name="l257"><span class="ln">257 </span></a> <span class="s2">event</span><span class="s1">::</span><span class="s2">Event</span><span class="s1">::</span><span class="s2">MainEventsCleared </span><span class="s1">=> {</span>
|
||
|
<a name="l258"><span class="ln">258 </span></a> <span class="s2">event_schedule</span><span class="s1">.</span><span class="s2">execute</span><span class="s1">(&</span><span class="s0">mut </span><span class="s2">world</span><span class="s3">, </span><span class="s1">&</span><span class="s0">mut </span><span class="s2">resources</span><span class="s1">)</span><span class="s3">;</span>
|
||
|
<a name="l259"><span class="ln">259 </span></a> <span class="s2">resources</span>
|
||
|
<a name="l260"><span class="ln">260 </span></a> <span class="s1">.</span><span class="s2">get_mut</span><span class="s1">::<</span><span class="s2">Vec</span><span class="s1"><</span><span class="s2">OwnedEvent</span><span class="s1"><</span><span class="s2">OwnedEventExtension</span><span class="s1">>>>()</span>
|
||
|
<a name="l261"><span class="ln">261 </span></a> <span class="s1">.</span><span class="s2">unwrap</span><span class="s1">()</span>
|
||
|
<a name="l262"><span class="ln">262 </span></a> <span class="s1">.</span><span class="s2">clear</span><span class="s1">()</span><span class="s3">;</span>
|
||
|
<a name="l263"><span class="ln">263 </span></a>
|
||
|
<a name="l264"><span class="ln">264 </span></a> <span class="s2">imgui_prepare_schedule</span><span class="s1">.</span><span class="s2">execute</span><span class="s1">(&</span><span class="s0">mut </span><span class="s2">world</span><span class="s3">, </span><span class="s1">&</span><span class="s0">mut </span><span class="s2">resources</span><span class="s1">)</span><span class="s3">;</span>
|
||
|
<a name="l265"><span class="ln">265 </span></a>
|
||
|
<a name="l266"><span class="ln">266 </span></a> <span class="s0">let </span><span class="s1">(</span><span class="s2">step_size</span><span class="s3">, </span><span class="s2">elapsed_time</span><span class="s1">) = {</span>
|
||
|
<a name="l267"><span class="ln">267 </span></a> <span class="s0">let mut </span><span class="s2">loop_state </span><span class="s1">= </span><span class="s2">resources</span><span class="s1">.</span><span class="s2">get_mut</span><span class="s1">::<</span><span class="s2">LoopState</span><span class="s1">>().</span><span class="s2">unwrap</span><span class="s1">()</span><span class="s3">;</span>
|
||
|
<a name="l268"><span class="ln">268 </span></a> <span class="s1">(</span>
|
||
|
<a name="l269"><span class="ln">269 </span></a> <span class="s2">loop_state</span><span class="s1">.</span><span class="s2">step_size</span><span class="s3">,</span>
|
||
|
<a name="l270"><span class="ln">270 </span></a> <span class="s2">loop_state</span><span class="s1">.</span><span class="s2">start_time</span><span class="s1">.</span><span class="s2">elapsed</span><span class="s1">().</span><span class="s2">as_secs_f32</span><span class="s1">()</span><span class="s3">,</span>
|
||
|
<a name="l271"><span class="ln">271 </span></a> <span class="s1">)</span>
|
||
|
<a name="l272"><span class="ln">272 </span></a> <span class="s1">}</span><span class="s3">;</span>
|
||
|
<a name="l273"><span class="ln">273 </span></a> <span class="s2">delta_time </span><span class="s1">= </span><span class="s2">elapsed_time </span><span class="s1">- </span><span class="s2">current_time</span><span class="s3">;</span>
|
||
|
<a name="l274"><span class="ln">274 </span></a>
|
||
|
<a name="l275"><span class="ln">275 </span></a> <span class="s1">{</span>
|
||
|
<a name="l276"><span class="ln">276 </span></a> <span class="s0">let mut </span><span class="s2">loop_state </span><span class="s1">= </span><span class="s2">resources</span><span class="s1">.</span><span class="s2">get_mut</span><span class="s1">::<</span><span class="s2">LoopState</span><span class="s1">>().</span><span class="s2">unwrap</span><span class="s1">()</span><span class="s3">;</span>
|
||
|
<a name="l277"><span class="ln">277 </span></a> <span class="s2">loop_state</span><span class="s1">.</span><span class="s2">delta_time </span><span class="s1">= </span><span class="s2">Duration</span><span class="s1">::</span><span class="s2">from_secs_f32</span><span class="s1">(</span><span class="s2">delta_time</span><span class="s1">)</span><span class="s3">;</span>
|
||
|
<a name="l278"><span class="ln">278 </span></a> <span class="s1">}</span>
|
||
|
<a name="l279"><span class="ln">279 </span></a> <span class="s2">current_time </span><span class="s1">= </span><span class="s2">elapsed_time</span><span class="s3">;</span>
|
||
|
<a name="l280"><span class="ln">280 </span></a> <span class="s0">if </span><span class="s2">delta_time </span><span class="s1">> </span><span class="s7">0</span><span class="s1">.</span><span class="s7">02 </span><span class="s1">{</span>
|
||
|
<a name="l281"><span class="ln">281 </span></a> <span class="s2">delta_time </span><span class="s1">= </span><span class="s7">0</span><span class="s1">.</span><span class="s7">02</span><span class="s3">;</span>
|
||
|
<a name="l282"><span class="ln">282 </span></a> <span class="s1">}</span>
|
||
|
<a name="l283"><span class="ln">283 </span></a> <span class="s2">accumulator_time </span><span class="s1">+= </span><span class="s2">delta_time</span><span class="s3">;</span>
|
||
|
<a name="l284"><span class="ln">284 </span></a>
|
||
|
<a name="l285"><span class="ln">285 </span></a> <span class="s0">while </span><span class="s2">accumulator_time </span><span class="s1">- </span><span class="s2">step_size </span><span class="s1">>= </span><span class="s2">step_size </span><span class="s1">{</span>
|
||
|
<a name="l286"><span class="ln">286 </span></a> <span class="s2">accumulator_time </span><span class="s1">-= </span><span class="s2">step_size</span><span class="s3">;</span>
|
||
|
<a name="l287"><span class="ln">287 </span></a>
|
||
|
<a name="l288"><span class="ln">288 </span></a> <span class="s5">// ==== DELTA TIME LOCKED ====</span>
|
||
|
<a name="l289"><span class="ln">289 </span></a> <span class="s2">update_schedule</span><span class="s1">.</span><span class="s2">execute</span><span class="s1">(&</span><span class="s0">mut </span><span class="s2">world</span><span class="s3">, </span><span class="s1">&</span><span class="s0">mut </span><span class="s2">resources</span><span class="s1">)</span><span class="s3">;</span>
|
||
|
<a name="l290"><span class="ln">290 </span></a> <span class="s1">}</span>
|
||
|
<a name="l291"><span class="ln">291 </span></a> <span class="s5">// ==== FPS LOCKED ====</span>
|
||
|
<a name="l292"><span class="ln">292 </span></a> <span class="s2">render_schedule</span><span class="s1">.</span><span class="s2">execute</span><span class="s1">(&</span><span class="s0">mut </span><span class="s2">world</span><span class="s3">, </span><span class="s1">&</span><span class="s0">mut </span><span class="s2">resources</span><span class="s1">)</span><span class="s3">;</span>
|
||
|
<a name="l293"><span class="ln">293 </span></a> <span class="s1">}</span>
|
||
|
<a name="l294"><span class="ln">294 </span></a> <span class="s5">// Resizing will queue a request_redraw</span>
|
||
|
<a name="l295"><span class="ln">295 </span></a> <span class="s2">event</span><span class="s1">::</span><span class="s2">Event</span><span class="s1">::</span><span class="s2">WindowEvent </span><span class="s1">{</span>
|
||
|
<a name="l296"><span class="ln">296 </span></a> <span class="s2">event</span><span class="s1">: </span><span class="s2">WindowEvent</span><span class="s1">::</span><span class="s2">Resized</span><span class="s1">(</span><span class="s2">size</span><span class="s1">)</span><span class="s3">,</span>
|
||
|
<a name="l297"><span class="ln">297 </span></a> <span class="s1">..</span>
|
||
|
<a name="l298"><span class="ln">298 </span></a> <span class="s1">} => {</span>
|
||
|
<a name="l299"><span class="ln">299 </span></a> <span class="s0">let </span><span class="s2">width </span><span class="s1">= </span><span class="s2">size</span><span class="s1">.</span><span class="s2">width</span><span class="s3">;</span>
|
||
|
<a name="l300"><span class="ln">300 </span></a> <span class="s0">let </span><span class="s2">height </span><span class="s1">= </span><span class="s2">size</span><span class="s1">.</span><span class="s2">height</span><span class="s3">;</span>
|
||
|
<a name="l301"><span class="ln">301 </span></a>
|
||
|
<a name="l302"><span class="ln">302 </span></a> <span class="s2">resources</span>
|
||
|
<a name="l303"><span class="ln">303 </span></a> <span class="s1">.</span><span class="s2">get_mut</span><span class="s1">::<</span><span class="s2">render</span><span class="s1">::</span><span class="s2">state</span><span class="s1">::</span><span class="s2">RenderState</span><span class="s1">>()</span>
|
||
|
<a name="l304"><span class="ln">304 </span></a> <span class="s1">.</span><span class="s2">unwrap</span><span class="s1">()</span>
|
||
|
<a name="l305"><span class="ln">305 </span></a> <span class="s1">.</span><span class="s2">resize</span><span class="s1">(</span><span class="s2">width</span><span class="s3">, </span><span class="s2">height</span><span class="s1">)</span><span class="s3">;</span>
|
||
|
<a name="l306"><span class="ln">306 </span></a> <span class="s1">}</span>
|
||
|
<a name="l307"><span class="ln">307 </span></a> <span class="s2">event</span><span class="s1">::</span><span class="s2">Event</span><span class="s1">::</span><span class="s2">DeviceEvent </span><span class="s1">{</span>
|
||
|
<a name="l308"><span class="ln">308 </span></a> <span class="s2">event</span><span class="s1">: </span><span class="s2">winit_24</span><span class="s1">::</span><span class="s2">event</span><span class="s1">::</span><span class="s2">DeviceEvent</span><span class="s1">::</span><span class="s2">Key</span><span class="s1">(</span><span class="s2">keyboard_input</span><span class="s1">)</span><span class="s3">,</span>
|
||
|
<a name="l309"><span class="ln">309 </span></a> <span class="s1">..</span>
|
||
|
<a name="l310"><span class="ln">310 </span></a> <span class="s1">} => {</span>
|
||
|
<a name="l311"><span class="ln">311 </span></a> <span class="s0">if </span><span class="s2">keyboard_input</span><span class="s1">.</span><span class="s2">virtual_keycode</span><span class="s1">.</span><span class="s2">is_some</span><span class="s1">() {</span>
|
||
|
<a name="l312"><span class="ln">312 </span></a> <span class="s0">match </span><span class="s2">keyboard_input</span><span class="s1">.</span><span class="s2">virtual_keycode</span><span class="s1">.</span><span class="s2">unwrap</span><span class="s1">() {</span>
|
||
|
<a name="l313"><span class="ln">313 </span></a> <span class="s2">VirtualKeyCode</span><span class="s1">::</span><span class="s2">Escape </span><span class="s1">=> {</span>
|
||
|
<a name="l314"><span class="ln">314 </span></a> <span class="s0">if </span><span class="s2">keyboard_input</span><span class="s1">.</span><span class="s2">state </span><span class="s1">== </span><span class="s2">ElementState</span><span class="s1">::</span><span class="s2">Pressed </span><span class="s1">{</span>
|
||
|
<a name="l315"><span class="ln">315 </span></a> <span class="s1">*</span><span class="s2">control_flow </span><span class="s1">= </span><span class="s2">ControlFlow</span><span class="s1">::</span><span class="s2">Exit</span><span class="s3">;</span>
|
||
|
<a name="l316"><span class="ln">316 </span></a> <span class="s1">} </span><span class="s0">else </span><span class="s1">{</span>
|
||
|
<a name="l317"><span class="ln">317 </span></a> <span class="s5">//d</span>
|
||
|
<a name="l318"><span class="ln">318 </span></a> <span class="s1">}</span>
|
||
|
<a name="l319"><span class="ln">319 </span></a> <span class="s1">}</span>
|
||
|
<a name="l320"><span class="ln">320 </span></a> <span class="s2">_ </span><span class="s1">=> ()</span><span class="s3">,</span>
|
||
|
<a name="l321"><span class="ln">321 </span></a> <span class="s1">}</span>
|
||
|
<a name="l322"><span class="ln">322 </span></a> <span class="s1">}</span>
|
||
|
<a name="l323"><span class="ln">323 </span></a> <span class="s1">}</span>
|
||
|
<a name="l324"><span class="ln">324 </span></a> <span class="s2">event</span><span class="s1">::</span><span class="s2">Event</span><span class="s1">::</span><span class="s2">WindowEvent </span><span class="s1">{</span>
|
||
|
<a name="l325"><span class="ln">325 </span></a> <span class="s2">event</span><span class="s1">: </span><span class="s2">WindowEvent</span><span class="s1">::</span><span class="s2">CloseRequested</span><span class="s3">,</span>
|
||
|
<a name="l326"><span class="ln">326 </span></a> <span class="s1">..</span>
|
||
|
<a name="l327"><span class="ln">327 </span></a> <span class="s1">} => *</span><span class="s2">control_flow </span><span class="s1">= </span><span class="s2">ControlFlow</span><span class="s1">::</span><span class="s2">Exit</span><span class="s3">,</span>
|
||
|
<a name="l328"><span class="ln">328 </span></a> <span class="s2">event</span><span class="s1">::</span><span class="s2">Event</span><span class="s1">::</span><span class="s2">RedrawRequested</span><span class="s1">(</span><span class="s2">_</span><span class="s1">) => {</span>
|
||
|
<a name="l329"><span class="ln">329 </span></a> <span class="s5">// Call the render system</span>
|
||
|
<a name="l330"><span class="ln">330 </span></a> <span class="s5">// imgui_prepare_schedule.execute(&mut world, &mut resources);</span>
|
||
|
<a name="l331"><span class="ln">331 </span></a> <span class="s5">// render_schedule.execute(&mut world, &mut resources);</span>
|
||
|
<a name="l332"><span class="ln">332 </span></a> <span class="s1">}</span>
|
||
|
<a name="l333"><span class="ln">333 </span></a> <span class="s2">_ </span><span class="s1">=> {}</span>
|
||
|
<a name="l334"><span class="ln">334 </span></a> <span class="s1">}</span>
|
||
|
<a name="l335"><span class="ln">335 </span></a>
|
||
|
<a name="l336"><span class="ln">336 </span></a> <span class="s2">resources</span>
|
||
|
<a name="l337"><span class="ln">337 </span></a> <span class="s1">.</span><span class="s2">get_mut</span><span class="s1">::<</span><span class="s2">Vec</span><span class="s1"><</span><span class="s2">OwnedEvent</span><span class="s1"><</span><span class="s2">OwnedEventExtension</span><span class="s1">>>>()</span>
|
||
|
<a name="l338"><span class="ln">338 </span></a> <span class="s1">.</span><span class="s2">unwrap</span><span class="s1">()</span>
|
||
|
<a name="l339"><span class="ln">339 </span></a> <span class="s1">.</span><span class="s2">push</span><span class="s1">(</span><span class="s2">event</span><span class="s1">.</span><span class="s2">into</span><span class="s1">())</span><span class="s3">;</span>
|
||
|
<a name="l340"><span class="ln">340 </span></a> <span class="s1">})</span><span class="s3">;</span>
|
||
|
<a name="l341"><span class="ln">341 </span></a><span class="s1">}</span>
|
||
|
<a name="l342"><span class="ln">342 </span></a>
|
||
|
<a name="l343"><span class="ln">343 </span></a><span class="s0">pub fn </span><span class="s2">setup_gamepad</span><span class="s1">(</span><span class="s2">event_loop</span><span class="s1">: &</span><span class="s2">EventLoop</span><span class="s1"><</span><span class="s2">OwnedEventExtension</span><span class="s1">>) {</span>
|
||
|
<a name="l344"><span class="ln">344 </span></a> <span class="s0">let </span><span class="s2">event_loop_proxy </span><span class="s1">= </span><span class="s2">event_loop</span><span class="s1">.</span><span class="s2">create_proxy</span><span class="s1">()</span><span class="s3">;</span>
|
||
|
<a name="l345"><span class="ln">345 </span></a>
|
||
|
<a name="l346"><span class="ln">346 </span></a> <span class="s2">std</span><span class="s1">::</span><span class="s2">thread</span><span class="s1">::</span><span class="s2">spawn</span><span class="s1">(</span><span class="s0">move </span><span class="s1">|| {</span>
|
||
|
<a name="l347"><span class="ln">347 </span></a> <span class="s0">let mut </span><span class="s2">gilrs </span><span class="s1">= </span><span class="s2">Gilrs</span><span class="s1">::</span><span class="s2">new</span><span class="s1">().</span><span class="s2">unwrap</span><span class="s1">()</span><span class="s3">;</span>
|
||
|
<a name="l348"><span class="ln">348 </span></a> <span class="s5">// Iterate over all connected gamepads</span>
|
||
|
<a name="l349"><span class="ln">349 </span></a> <span class="s0">let mut </span><span class="s2">gamepad</span><span class="s1">: </span><span class="s2">Option</span><span class="s1"><</span><span class="s2">Gamepad</span><span class="s1">> = </span><span class="s2">None</span><span class="s3">;</span>
|
||
|
<a name="l350"><span class="ln">350 </span></a> <span class="s0">for </span><span class="s1">(</span><span class="s2">_id</span><span class="s3">, </span><span class="s2">gamepad_</span><span class="s1">) </span><span class="s0">in </span><span class="s2">gilrs</span><span class="s1">.</span><span class="s2">gamepads</span><span class="s1">() {</span>
|
||
|
<a name="l351"><span class="ln">351 </span></a> <span class="s0">if </span><span class="s2">gamepad_</span><span class="s1">.</span><span class="s2">name</span><span class="s1">() == </span><span class="s4">"PS4" </span><span class="s1">{</span>
|
||
|
<a name="l352"><span class="ln">352 </span></a> <span class="s2">gamepad </span><span class="s1">= </span><span class="s2">Some</span><span class="s1">(</span><span class="s2">gamepad_</span><span class="s1">)</span><span class="s3">;</span>
|
||
|
<a name="l353"><span class="ln">353 </span></a> <span class="s1">}</span>
|
||
|
<a name="l354"><span class="ln">354 </span></a> <span class="s5">// println!(</span>
|
||
|
<a name="l355"><span class="ln">355 </span></a> <span class="s5">// "{} is {:?} {:?}",</span>
|
||
|
<a name="l356"><span class="ln">356 </span></a> <span class="s5">// gamepad_.name(),</span>
|
||
|
<a name="l357"><span class="ln">357 </span></a> <span class="s5">// gamepad_.power_info(),</span>
|
||
|
<a name="l358"><span class="ln">358 </span></a> <span class="s5">// gamepad_.id()</span>
|
||
|
<a name="l359"><span class="ln">359 </span></a> <span class="s5">// );</span>
|
||
|
<a name="l360"><span class="ln">360 </span></a> <span class="s1">}</span>
|
||
|
<a name="l361"><span class="ln">361 </span></a> <span class="s0">let mut </span><span class="s2">active_gamepad </span><span class="s1">= </span><span class="s2">None</span><span class="s3">;</span>
|
||
|
<a name="l362"><span class="ln">362 </span></a>
|
||
|
<a name="l363"><span class="ln">363 </span></a> <span class="s0">loop </span><span class="s1">{</span>
|
||
|
<a name="l364"><span class="ln">364 </span></a> <span class="s0">while let </span><span class="s2">Some</span><span class="s1">(</span><span class="s2">GilEvent </span><span class="s1">{ </span><span class="s2">id</span><span class="s3">, </span><span class="s2">event</span><span class="s3">, </span><span class="s2">time </span><span class="s1">}) = </span><span class="s2">gilrs</span><span class="s1">.</span><span class="s2">next_event</span><span class="s1">() {</span>
|
||
|
<a name="l365"><span class="ln">365 </span></a> <span class="s5">//println!("{:?} New event from {}: {:?}", time, id, event);</span>
|
||
|
<a name="l366"><span class="ln">366 </span></a> <span class="s2">active_gamepad </span><span class="s1">= </span><span class="s2">Some</span><span class="s1">(</span><span class="s2">id</span><span class="s1">)</span><span class="s3">;</span>
|
||
|
<a name="l367"><span class="ln">367 </span></a> <span class="s2">event_loop_proxy</span>
|
||
|
<a name="l368"><span class="ln">368 </span></a> <span class="s1">.</span><span class="s2">send_event</span><span class="s1">(</span><span class="s2">OwnedEventExtension</span><span class="s1">::</span><span class="s2">GamepadEvent </span><span class="s1">{</span>
|
||
|
<a name="l369"><span class="ln">369 </span></a> <span class="s2">gil_event</span><span class="s1">: </span><span class="s2">GilEvent </span><span class="s1">{ </span><span class="s2">id</span><span class="s3">, </span><span class="s2">event</span><span class="s3">, </span><span class="s2">time </span><span class="s1">}</span><span class="s3">,</span>
|
||
|
<a name="l370"><span class="ln">370 </span></a> <span class="s1">})</span>
|
||
|
<a name="l371"><span class="ln">371 </span></a> <span class="s1">.</span><span class="s2">ok</span><span class="s1">()</span><span class="s3">;</span>
|
||
|
<a name="l372"><span class="ln">372 </span></a> <span class="s1">}</span>
|
||
|
<a name="l373"><span class="ln">373 </span></a>
|
||
|
<a name="l374"><span class="ln">374 </span></a> <span class="s5">// // You can also use cached gamepad state</span>
|
||
|
<a name="l375"><span class="ln">375 </span></a> <span class="s5">// if let Some(gamepad) = active_gamepad.map(|id| gilrs.gamepad(id)) {</span>
|
||
|
<a name="l376"><span class="ln">376 </span></a> <span class="s5">// if gamepad.is_pressed(Button::South) {</span>
|
||
|
<a name="l377"><span class="ln">377 </span></a> <span class="s5">// println!("Button South is pressed (XBox - A, PS - X)");</span>
|
||
|
<a name="l378"><span class="ln">378 </span></a> <span class="s5">// }</span>
|
||
|
<a name="l379"><span class="ln">379 </span></a> <span class="s5">// }</span>
|
||
|
<a name="l380"><span class="ln">380 </span></a>
|
||
|
<a name="l381"><span class="ln">381 </span></a> <span class="s2">std</span><span class="s1">::</span><span class="s2">thread</span><span class="s1">::</span><span class="s2">sleep</span><span class="s1">(</span><span class="s2">std</span><span class="s1">::</span><span class="s2">time</span><span class="s1">::</span><span class="s2">Duration</span><span class="s1">::</span><span class="s2">from_millis</span><span class="s1">(</span><span class="s7">50</span><span class="s1">))</span><span class="s3">;</span>
|
||
|
<a name="l382"><span class="ln">382 </span></a> <span class="s1">}</span>
|
||
|
<a name="l383"><span class="ln">383 </span></a> <span class="s1">})</span><span class="s3">;</span>
|
||
|
<a name="l384"><span class="ln">384 </span></a><span class="s1">}</span>
|
||
|
<a name="l385"><span class="ln">385 </span></a></pre>
|
||
|
</body>
|
||
|
</html>
|