Compare commits

...

9 Commits

@ -31,8 +31,8 @@ crossbeam = "0.8.0"
toml = "0.5.8" toml = "0.5.8"
cgmath = "0.18.0" cgmath = "0.18.0"
rapier3d = { version = "0.5.0", features = ["simd-nightly", "parallel"] } rapier3d = { version = "0.11.1", features = ["simd-nightly", "parallel"] }
nalgebra = "0.24.1" nalgebra = "0.29.0"
legion = "0.3.1" legion = "0.3.1"
wgpu = "0.7.0" wgpu = "0.7.0"
imgui = "0.7.0" imgui = "0.7.0"

@ -1,6 +1,6 @@
[[entities]] [[entities]]
name = "terrain.1" name = "terrain.1"
type = "Terrain" type = "StaticMesh"
mesh = "test-textured.obj" mesh = "test-textured.obj"
[[entities]] [[entities]]
@ -26,6 +26,20 @@ mesh = "ball.obj"
y = 1.0 y = 1.0
z = 1.0 z = 1.0
[[entities]]
name = "tile.1"
type = "Sprite"
texture = "test.jpg"
[entities.position]
x = 15.0
y = 15.0
z = 0.0
[entities.position.rotation]
x = 0.0
y = 0.0
[[entities]] [[entities]]
name = "camera.1" name = "camera.1"
type = "Camera" type = "Camera"

@ -0,0 +1,213 @@
<html>
<head>
<title>camera.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: #33ccff; font-weight: bold;}
.s5 { color: #7ec3e6;}
.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">
camera.rs</font>
</center></td></tr></table>
<pre><a name="l1"><span class="ln">1 </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">FRAC_PI_2</span><span class="s3">, </span><span class="s2">PI</span><span class="s1">}</span><span class="s3">;</span>
<a name="l2"><span class="ln">2 </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="l3"><span class="ln">3 </span></a>
<a name="l4"><span class="ln">4 </span></a><span class="s0">use </span><span class="s2">cgmath</span><span class="s1">::{</span><span class="s2">Decomposed</span><span class="s3">, </span><span class="s2">InnerSpace</span><span class="s3">, </span><span class="s2">Matrix4</span><span class="s3">, </span><span class="s2">Point3</span><span class="s3">, </span><span class="s2">Rad</span><span class="s3">, </span><span class="s2">Vector3</span><span class="s1">}</span><span class="s3">;</span>
<a name="l5"><span class="ln">5 </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">LogicalPosition</span><span class="s3">, </span><span class="s2">PhysicalPosition</span><span class="s1">}</span><span class="s3">;</span>
<a name="l6"><span class="ln">6 </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">MouseScrollDelta</span><span class="s3">, </span><span class="s2">VirtualKeyCode</span><span class="s1">}</span><span class="s3">;</span>
<a name="l7"><span class="ln">7 </span></a><span class="s0">use crate</span><span class="s1">::</span><span class="s2">render</span><span class="s1">::</span><span class="s2">OPENGL_TO_WGPU_MATRIX</span><span class="s3">;</span>
<a name="l8"><span class="ln">8 </span></a><span class="s0">use </span><span class="s2">imgui</span><span class="s1">::</span><span class="s2">Condition</span><span class="s3">;</span>
<a name="l9"><span class="ln">9 </span></a><span class="s0">use </span><span class="s2">imgui</span><span class="s1">::*</span><span class="s3">;</span>
<a name="l10"><span class="ln">10 </span></a>
<a name="l11"><span class="ln">11 </span></a><span class="s1">#[</span><span class="s2">derive</span><span class="s1">(</span><span class="s2">Clone</span><span class="s3">, </span><span class="s2">Copy</span><span class="s3">, </span><span class="s2">Debug</span><span class="s3">, </span><span class="s2">PartialEq</span><span class="s1">)]</span>
<a name="l12"><span class="ln">12 </span></a><span class="s0">pub struct </span><span class="s2">Camera </span><span class="s1">{</span>
<a name="l13"><span class="ln">13 </span></a> <span class="s0">pub </span><span class="s2">position</span><span class="s1">: </span><span class="s2">Point3</span><span class="s1">&lt;</span><span class="s2">f32</span><span class="s1">&gt;</span><span class="s3">,</span>
<a name="l14"><span class="ln">14 </span></a> <span class="s0">pub </span><span class="s2">yaw</span><span class="s1">: </span><span class="s2">Rad</span><span class="s1">&lt;</span><span class="s2">f32</span><span class="s1">&gt;</span><span class="s3">,</span>
<a name="l15"><span class="ln">15 </span></a> <span class="s0">pub </span><span class="s2">pitch</span><span class="s1">: </span><span class="s2">Rad</span><span class="s1">&lt;</span><span class="s2">f32</span><span class="s1">&gt;</span><span class="s3">,</span>
<a name="l16"><span class="ln">16 </span></a><span class="s1">}</span>
<a name="l17"><span class="ln">17 </span></a>
<a name="l18"><span class="ln">18 </span></a><span class="s0">impl </span><span class="s2">Camera </span><span class="s1">{</span>
<a name="l19"><span class="ln">19 </span></a> <span class="s0">pub fn </span><span class="s2">new</span><span class="s1">&lt;</span><span class="s2">V</span><span class="s1">: </span><span class="s2">Into</span><span class="s1">&lt;</span><span class="s2">Point3</span><span class="s1">&lt;</span><span class="s2">f32</span><span class="s1">&gt;&gt;</span><span class="s3">, </span><span class="s2">Y</span><span class="s1">: </span><span class="s2">Into</span><span class="s1">&lt;</span><span class="s2">Rad</span><span class="s1">&lt;</span><span class="s2">f32</span><span class="s1">&gt;&gt;</span><span class="s3">, </span><span class="s2">P</span><span class="s1">: </span><span class="s2">Into</span><span class="s1">&lt;</span><span class="s2">Rad</span><span class="s1">&lt;</span><span class="s2">f32</span><span class="s1">&gt;&gt;&gt;(</span>
<a name="l20"><span class="ln">20 </span></a> <span class="s2">position</span><span class="s1">: </span><span class="s2">V</span><span class="s3">,</span>
<a name="l21"><span class="ln">21 </span></a> <span class="s2">yaw</span><span class="s1">: </span><span class="s2">Y</span><span class="s3">,</span>
<a name="l22"><span class="ln">22 </span></a> <span class="s2">pitch</span><span class="s1">: </span><span class="s2">P</span><span class="s3">,</span>
<a name="l23"><span class="ln">23 </span></a> <span class="s1">) -&gt; </span><span class="s0">Self </span><span class="s1">{</span>
<a name="l24"><span class="ln">24 </span></a> <span class="s0">Self </span><span class="s1">{</span>
<a name="l25"><span class="ln">25 </span></a> <span class="s2">position</span><span class="s1">: </span><span class="s2">position</span><span class="s1">.</span><span class="s2">into</span><span class="s1">()</span><span class="s3">,</span>
<a name="l26"><span class="ln">26 </span></a> <span class="s2">yaw</span><span class="s1">: </span><span class="s2">yaw</span><span class="s1">.</span><span class="s2">into</span><span class="s1">()</span><span class="s3">,</span>
<a name="l27"><span class="ln">27 </span></a> <span class="s2">pitch</span><span class="s1">: </span><span class="s2">pitch</span><span class="s1">.</span><span class="s2">into</span><span class="s1">()</span><span class="s3">,</span>
<a name="l28"><span class="ln">28 </span></a> <span class="s1">}</span>
<a name="l29"><span class="ln">29 </span></a> <span class="s1">}</span>
<a name="l30"><span class="ln">30 </span></a>
<a name="l31"><span class="ln">31 </span></a> <span class="s0">pub fn </span><span class="s2">calc_matrix</span><span class="s1">(&amp;</span><span class="s0">self</span><span class="s3">, </span><span class="s2">projection</span><span class="s1">: </span><span class="s2">cgmath</span><span class="s1">::</span><span class="s2">Matrix4</span><span class="s1">&lt;</span><span class="s2">f32</span><span class="s1">&gt;) -&gt; </span><span class="s2">Matrix4</span><span class="s1">&lt;</span><span class="s2">f32</span><span class="s1">&gt; {</span>
<a name="l32"><span class="ln">32 </span></a>
<a name="l33"><span class="ln">33 </span></a> <span class="s0">let </span><span class="s2">view_vector </span><span class="s1">= </span><span class="s2">Point3</span><span class="s1">::</span><span class="s2">new</span><span class="s1">(</span>
<a name="l34"><span class="ln">34 </span></a> <span class="s1">(</span><span class="s4">1</span><span class="s1">.</span><span class="s4">0 </span><span class="s1">* </span><span class="s0">self</span><span class="s1">.</span><span class="s2">pitch</span><span class="s1">.</span><span class="s4">0</span><span class="s1">.</span><span class="s2">sin</span><span class="s1">() * </span><span class="s0">self</span><span class="s1">.</span><span class="s2">yaw</span><span class="s1">.</span><span class="s4">0</span><span class="s1">.</span><span class="s2">sin</span><span class="s1">())</span><span class="s3">,</span>
<a name="l35"><span class="ln">35 </span></a> <span class="s1">(</span><span class="s4">1</span><span class="s1">.</span><span class="s4">0 </span><span class="s1">* </span><span class="s0">self</span><span class="s1">.</span><span class="s2">pitch</span><span class="s1">.</span><span class="s4">0</span><span class="s1">.</span><span class="s2">cos</span><span class="s1">())</span><span class="s3">,</span>
<a name="l36"><span class="ln">36 </span></a> <span class="s1">(</span><span class="s4">1</span><span class="s1">.</span><span class="s4">0 </span><span class="s1">* </span><span class="s0">self</span><span class="s1">.</span><span class="s2">pitch</span><span class="s1">.</span><span class="s4">0</span><span class="s1">.</span><span class="s2">sin</span><span class="s1">() * </span><span class="s0">self</span><span class="s1">.</span><span class="s2">yaw</span><span class="s1">.</span><span class="s4">0</span><span class="s1">.</span><span class="s2">cos</span><span class="s1">())</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>
<a name="l39"><span class="ln">39 </span></a> <span class="s0">let </span><span class="s2">mx_view </span><span class="s1">= </span><span class="s2">Matrix4</span><span class="s1">::</span><span class="s2">look_at</span><span class="s1">(</span>
<a name="l40"><span class="ln">40 </span></a> <span class="s0">self</span><span class="s1">.</span><span class="s2">position</span><span class="s3">,</span>
<a name="l41"><span class="ln">41 </span></a> <span class="s2">Point3</span><span class="s1">::</span><span class="s2">new</span><span class="s1">(</span>
<a name="l42"><span class="ln">42 </span></a> <span class="s2">view_vector</span><span class="s1">.</span><span class="s2">x </span><span class="s1">+ </span><span class="s0">self</span><span class="s1">.</span><span class="s2">position</span><span class="s1">.</span><span class="s2">x</span><span class="s3">,</span>
<a name="l43"><span class="ln">43 </span></a> <span class="s2">view_vector</span><span class="s1">.</span><span class="s2">y </span><span class="s1">+ </span><span class="s0">self</span><span class="s1">.</span><span class="s2">position</span><span class="s1">.</span><span class="s2">y</span><span class="s3">,</span>
<a name="l44"><span class="ln">44 </span></a> <span class="s2">view_vector</span><span class="s1">.</span><span class="s2">z </span><span class="s1">+ </span><span class="s0">self</span><span class="s1">.</span><span class="s2">position</span><span class="s1">.</span><span class="s2">z</span><span class="s3">,</span>
<a name="l45"><span class="ln">45 </span></a> <span class="s1">)</span><span class="s3">,</span>
<a name="l46"><span class="ln">46 </span></a> <span class="s2">Vector3</span><span class="s1">::</span><span class="s2">unit_y</span><span class="s1">()</span><span class="s3">,</span>
<a name="l47"><span class="ln">47 </span></a> <span class="s1">)</span><span class="s3">;</span>
<a name="l48"><span class="ln">48 </span></a> <span class="s5">// I don't know how this works, but it limits pitching to like</span>
<a name="l49"><span class="ln">49 </span></a> <span class="s5">// 70 degrees. Lame</span>
<a name="l50"><span class="ln">50 </span></a> <span class="s5">// let mx_view = Matrix4::look_at_dir(</span>
<a name="l51"><span class="ln">51 </span></a> <span class="s5">// self.position,</span>
<a name="l52"><span class="ln">52 </span></a> <span class="s5">// Vector3::new(</span>
<a name="l53"><span class="ln">53 </span></a> <span class="s5">// self.yaw.0.cos(),</span>
<a name="l54"><span class="ln">54 </span></a> <span class="s5">// self.pitch.0.sin(),</span>
<a name="l55"><span class="ln">55 </span></a> <span class="s5">// self.yaw.0.sin(),</span>
<a name="l56"><span class="ln">56 </span></a> <span class="s5">// ).normalize(),</span>
<a name="l57"><span class="ln">57 </span></a> <span class="s5">// Vector3::unit_y(),</span>
<a name="l58"><span class="ln">58 </span></a> <span class="s5">// );</span>
<a name="l59"><span class="ln">59 </span></a> <span class="s0">let </span><span class="s2">mx_correction </span><span class="s1">= </span><span class="s2">OPENGL_TO_WGPU_MATRIX</span><span class="s3">;</span>
<a name="l60"><span class="ln">60 </span></a> <span class="s2">mx_correction </span><span class="s1">* </span><span class="s2">projection </span><span class="s1">* </span><span class="s2">mx_view</span>
<a name="l61"><span class="ln">61 </span></a> <span class="s1">}</span>
<a name="l62"><span class="ln">62 </span></a><span class="s1">}</span>
<a name="l63"><span class="ln">63 </span></a>
<a name="l64"><span class="ln">64 </span></a><span class="s1">#[</span><span class="s2">derive</span><span class="s1">(</span><span class="s2">Debug</span><span class="s1">)]</span>
<a name="l65"><span class="ln">65 </span></a><span class="s0">pub struct </span><span class="s2">CameraController </span><span class="s1">{</span>
<a name="l66"><span class="ln">66 </span></a> <span class="s2">amount_left</span><span class="s1">: </span><span class="s2">f32</span><span class="s3">,</span>
<a name="l67"><span class="ln">67 </span></a> <span class="s2">amount_right</span><span class="s1">: </span><span class="s2">f32</span><span class="s3">,</span>
<a name="l68"><span class="ln">68 </span></a> <span class="s2">amount_forward</span><span class="s1">: </span><span class="s2">f32</span><span class="s3">,</span>
<a name="l69"><span class="ln">69 </span></a> <span class="s2">amount_backward</span><span class="s1">: </span><span class="s2">f32</span><span class="s3">,</span>
<a name="l70"><span class="ln">70 </span></a> <span class="s2">amount_up</span><span class="s1">: </span><span class="s2">f32</span><span class="s3">,</span>
<a name="l71"><span class="ln">71 </span></a> <span class="s2">amount_down</span><span class="s1">: </span><span class="s2">f32</span><span class="s3">,</span>
<a name="l72"><span class="ln">72 </span></a> <span class="s2">rotate_horizontal</span><span class="s1">: </span><span class="s2">f32</span><span class="s3">,</span>
<a name="l73"><span class="ln">73 </span></a> <span class="s2">rotate_vertical</span><span class="s1">: </span><span class="s2">f32</span><span class="s3">,</span>
<a name="l74"><span class="ln">74 </span></a> <span class="s2">scroll</span><span class="s1">: </span><span class="s2">f32</span><span class="s3">,</span>
<a name="l75"><span class="ln">75 </span></a> <span class="s2">speed</span><span class="s1">: </span><span class="s2">f32</span><span class="s3">,</span>
<a name="l76"><span class="ln">76 </span></a> <span class="s2">sensitivity</span><span class="s1">: </span><span class="s2">f32</span><span class="s3">,</span>
<a name="l77"><span class="ln">77 </span></a> <span class="s2">active</span><span class="s1">: </span><span class="s2">bool</span><span class="s3">,</span>
<a name="l78"><span class="ln">78 </span></a><span class="s1">}</span>
<a name="l79"><span class="ln">79 </span></a>
<a name="l80"><span class="ln">80 </span></a><span class="s0">impl </span><span class="s2">CameraController </span><span class="s1">{</span>
<a name="l81"><span class="ln">81 </span></a> <span class="s0">pub fn </span><span class="s2">new</span><span class="s1">(</span><span class="s2">speed</span><span class="s1">: </span><span class="s2">f32</span><span class="s3">, </span><span class="s2">sensitivity</span><span class="s1">: </span><span class="s2">f32</span><span class="s1">) -&gt; </span><span class="s0">Self </span><span class="s1">{</span>
<a name="l82"><span class="ln">82 </span></a> <span class="s0">Self </span><span class="s1">{</span>
<a name="l83"><span class="ln">83 </span></a> <span class="s2">amount_left</span><span class="s1">: </span><span class="s4">0</span><span class="s1">.</span><span class="s4">0</span><span class="s3">,</span>
<a name="l84"><span class="ln">84 </span></a> <span class="s2">amount_right</span><span class="s1">: </span><span class="s4">0</span><span class="s1">.</span><span class="s4">0</span><span class="s3">,</span>
<a name="l85"><span class="ln">85 </span></a> <span class="s2">amount_forward</span><span class="s1">: </span><span class="s4">0</span><span class="s1">.</span><span class="s4">0</span><span class="s3">,</span>
<a name="l86"><span class="ln">86 </span></a> <span class="s2">amount_backward</span><span class="s1">: </span><span class="s4">0</span><span class="s1">.</span><span class="s4">0</span><span class="s3">,</span>
<a name="l87"><span class="ln">87 </span></a> <span class="s2">amount_up</span><span class="s1">: </span><span class="s4">0</span><span class="s1">.</span><span class="s4">0</span><span class="s3">,</span>
<a name="l88"><span class="ln">88 </span></a> <span class="s2">amount_down</span><span class="s1">: </span><span class="s4">0</span><span class="s1">.</span><span class="s4">0</span><span class="s3">,</span>
<a name="l89"><span class="ln">89 </span></a> <span class="s2">rotate_horizontal</span><span class="s1">: </span><span class="s4">0</span><span class="s1">.</span><span class="s4">0</span><span class="s3">,</span>
<a name="l90"><span class="ln">90 </span></a> <span class="s2">rotate_vertical</span><span class="s1">: </span><span class="s4">0</span><span class="s1">.</span><span class="s4">0</span><span class="s3">,</span>
<a name="l91"><span class="ln">91 </span></a> <span class="s2">scroll</span><span class="s1">: </span><span class="s4">0</span><span class="s1">.</span><span class="s4">0</span><span class="s3">,</span>
<a name="l92"><span class="ln">92 </span></a> <span class="s2">speed</span><span class="s3">,</span>
<a name="l93"><span class="ln">93 </span></a> <span class="s2">sensitivity</span><span class="s3">,</span>
<a name="l94"><span class="ln">94 </span></a> <span class="s2">active</span><span class="s1">: </span><span class="s0">true</span>
<a name="l95"><span class="ln">95 </span></a> <span class="s1">}</span>
<a name="l96"><span class="ln">96 </span></a> <span class="s1">}</span>
<a name="l97"><span class="ln">97 </span></a>
<a name="l98"><span class="ln">98 </span></a> <span class="s0">pub fn </span><span class="s2">process_keyboard</span><span class="s1">(&amp;</span><span class="s0">mut self</span><span class="s3">, </span><span class="s2">key</span><span class="s1">: </span><span class="s2">VirtualKeyCode</span><span class="s3">, </span><span class="s2">state</span><span class="s1">: </span><span class="s2">ElementState</span><span class="s1">) -&gt; </span><span class="s2">bool </span><span class="s1">{</span>
<a name="l99"><span class="ln">99 </span></a> <span class="s0">let </span><span class="s2">amount </span><span class="s1">= </span><span class="s0">if </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="l100"><span class="ln">100 </span></a> <span class="s4">1</span><span class="s1">.</span><span class="s4">0</span>
<a name="l101"><span class="ln">101 </span></a> <span class="s1">} </span><span class="s0">else </span><span class="s1">{</span>
<a name="l102"><span class="ln">102 </span></a> <span class="s4">0</span><span class="s1">.</span><span class="s4">0</span>
<a name="l103"><span class="ln">103 </span></a> <span class="s1">}</span><span class="s3">;</span>
<a name="l104"><span class="ln">104 </span></a> <span class="s0">let </span><span class="s2">active </span><span class="s1">= </span><span class="s0">match </span><span class="s2">key </span><span class="s1">{</span>
<a name="l105"><span class="ln">105 </span></a> <span class="s2">VirtualKeyCode</span><span class="s1">::</span><span class="s2">P </span><span class="s1">=&gt; {</span>
<a name="l106"><span class="ln">106 </span></a> <span class="s0">if </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="l107"><span class="ln">107 </span></a> <span class="s0">self</span><span class="s1">.</span><span class="s2">active </span><span class="s1">= !</span><span class="s0">self</span><span class="s1">.</span><span class="s2">active</span><span class="s3">;</span>
<a name="l108"><span class="ln">108 </span></a> <span class="s1">}</span>
<a name="l109"><span class="ln">109 </span></a> <span class="s0">self</span><span class="s1">.</span><span class="s2">active</span>
<a name="l110"><span class="ln">110 </span></a> <span class="s1">}</span><span class="s3">,</span>
<a name="l111"><span class="ln">111 </span></a> <span class="s2">_ </span><span class="s1">=&gt; {</span><span class="s0">self</span><span class="s1">.</span><span class="s2">active</span><span class="s1">}</span>
<a name="l112"><span class="ln">112 </span></a> <span class="s1">}</span><span class="s3">;</span>
<a name="l113"><span class="ln">113 </span></a> <span class="s0">if </span><span class="s2">active </span><span class="s1">{</span>
<a name="l114"><span class="ln">114 </span></a> <span class="s0">match </span><span class="s2">key </span><span class="s1">{</span>
<a name="l115"><span class="ln">115 </span></a> <span class="s2">VirtualKeyCode</span><span class="s1">::</span><span class="s2">W </span><span class="s1">| </span><span class="s2">VirtualKeyCode</span><span class="s1">::</span><span class="s2">Up </span><span class="s1">=&gt; {</span>
<a name="l116"><span class="ln">116 </span></a> <span class="s0">self</span><span class="s1">.</span><span class="s2">amount_forward </span><span class="s1">= </span><span class="s2">amount</span><span class="s3">;</span>
<a name="l117"><span class="ln">117 </span></a> <span class="s0">true</span>
<a name="l118"><span class="ln">118 </span></a> <span class="s1">}</span>
<a name="l119"><span class="ln">119 </span></a> <span class="s2">VirtualKeyCode</span><span class="s1">::</span><span class="s2">S </span><span class="s1">| </span><span class="s2">VirtualKeyCode</span><span class="s1">::</span><span class="s2">Down </span><span class="s1">=&gt; {</span>
<a name="l120"><span class="ln">120 </span></a> <span class="s0">self</span><span class="s1">.</span><span class="s2">amount_backward </span><span class="s1">= </span><span class="s2">amount</span><span class="s3">;</span>
<a name="l121"><span class="ln">121 </span></a> <span class="s0">true</span>
<a name="l122"><span class="ln">122 </span></a> <span class="s1">}</span>
<a name="l123"><span class="ln">123 </span></a> <span class="s2">VirtualKeyCode</span><span class="s1">::</span><span class="s2">A </span><span class="s1">| </span><span class="s2">VirtualKeyCode</span><span class="s1">::</span><span class="s2">Left </span><span class="s1">=&gt; {</span>
<a name="l124"><span class="ln">124 </span></a> <span class="s0">self</span><span class="s1">.</span><span class="s2">amount_left </span><span class="s1">= </span><span class="s2">amount</span><span class="s3">;</span>
<a name="l125"><span class="ln">125 </span></a> <span class="s0">true</span>
<a name="l126"><span class="ln">126 </span></a> <span class="s1">}</span>
<a name="l127"><span class="ln">127 </span></a> <span class="s2">VirtualKeyCode</span><span class="s1">::</span><span class="s2">D </span><span class="s1">| </span><span class="s2">VirtualKeyCode</span><span class="s1">::</span><span class="s2">Right </span><span class="s1">=&gt; {</span>
<a name="l128"><span class="ln">128 </span></a> <span class="s0">self</span><span class="s1">.</span><span class="s2">amount_right </span><span class="s1">= </span><span class="s2">amount</span><span class="s3">;</span>
<a name="l129"><span class="ln">129 </span></a> <span class="s0">true</span>
<a name="l130"><span class="ln">130 </span></a> <span class="s1">}</span>
<a name="l131"><span class="ln">131 </span></a> <span class="s2">VirtualKeyCode</span><span class="s1">::</span><span class="s2">Space </span><span class="s1">=&gt; {</span>
<a name="l132"><span class="ln">132 </span></a> <span class="s0">self</span><span class="s1">.</span><span class="s2">amount_up </span><span class="s1">= </span><span class="s2">amount</span><span class="s3">;</span>
<a name="l133"><span class="ln">133 </span></a> <span class="s0">true</span>
<a name="l134"><span class="ln">134 </span></a> <span class="s1">}</span>
<a name="l135"><span class="ln">135 </span></a> <span class="s2">VirtualKeyCode</span><span class="s1">::</span><span class="s2">LShift </span><span class="s1">=&gt; {</span>
<a name="l136"><span class="ln">136 </span></a> <span class="s0">self</span><span class="s1">.</span><span class="s2">amount_down </span><span class="s1">= </span><span class="s2">amount</span><span class="s3">;</span>
<a name="l137"><span class="ln">137 </span></a> <span class="s0">true</span>
<a name="l138"><span class="ln">138 </span></a> <span class="s1">}</span>
<a name="l139"><span class="ln">139 </span></a> <span class="s2">_ </span><span class="s1">=&gt; </span><span class="s0">false</span><span class="s3">,</span>
<a name="l140"><span class="ln">140 </span></a> <span class="s1">}</span>
<a name="l141"><span class="ln">141 </span></a> <span class="s1">} </span><span class="s0">else </span><span class="s1">{</span>
<a name="l142"><span class="ln">142 </span></a> <span class="s0">false</span>
<a name="l143"><span class="ln">143 </span></a> <span class="s1">}</span>
<a name="l144"><span class="ln">144 </span></a> <span class="s1">}</span>
<a name="l145"><span class="ln">145 </span></a>
<a name="l146"><span class="ln">146 </span></a> <span class="s0">pub fn </span><span class="s2">process_mouse</span><span class="s1">(&amp;</span><span class="s0">mut self</span><span class="s3">, </span><span class="s2">mouse_dx</span><span class="s1">: </span><span class="s2">f64</span><span class="s3">, </span><span class="s2">mouse_dy</span><span class="s1">: </span><span class="s2">f64</span><span class="s1">) {</span>
<a name="l147"><span class="ln">147 </span></a> <span class="s0">if self</span><span class="s1">.</span><span class="s2">active </span><span class="s1">{</span>
<a name="l148"><span class="ln">148 </span></a> <span class="s0">self</span><span class="s1">.</span><span class="s2">rotate_horizontal </span><span class="s1">= -</span><span class="s2">mouse_dx </span><span class="s0">as </span><span class="s2">f32</span><span class="s3">;</span>
<a name="l149"><span class="ln">149 </span></a> <span class="s0">self</span><span class="s1">.</span><span class="s2">rotate_vertical </span><span class="s1">= </span><span class="s2">mouse_dy </span><span class="s0">as </span><span class="s2">f32</span><span class="s3">;</span>
<a name="l150"><span class="ln">150 </span></a> <span class="s1">}</span>
<a name="l151"><span class="ln">151 </span></a> <span class="s1">}</span>
<a name="l152"><span class="ln">152 </span></a>
<a name="l153"><span class="ln">153 </span></a> <span class="s0">pub fn </span><span class="s2">update_camera</span><span class="s1">(&amp;</span><span class="s0">mut self</span><span class="s3">, </span><span class="s2">camera</span><span class="s1">: &amp;</span><span class="s0">mut </span><span class="s2">Camera</span><span class="s3">, </span><span class="s2">dt</span><span class="s1">: </span><span class="s2">f32</span><span class="s1">) {</span>
<a name="l154"><span class="ln">154 </span></a>
<a name="l155"><span class="ln">155 </span></a> <span class="s5">// Move forward/backward and left/right</span>
<a name="l156"><span class="ln">156 </span></a> <span class="s0">let </span><span class="s2">view_vector </span><span class="s1">= </span><span class="s2">Vector3</span><span class="s1">::</span><span class="s2">new</span><span class="s1">(</span>
<a name="l157"><span class="ln">157 </span></a> <span class="s1">(</span><span class="s4">1</span><span class="s1">.</span><span class="s4">0 </span><span class="s1">* </span><span class="s2">camera</span><span class="s1">.</span><span class="s2">pitch</span><span class="s1">.</span><span class="s4">0</span><span class="s1">.</span><span class="s2">sin</span><span class="s1">() * </span><span class="s2">camera</span><span class="s1">.</span><span class="s2">yaw</span><span class="s1">.</span><span class="s4">0</span><span class="s1">.</span><span class="s2">sin</span><span class="s1">())</span><span class="s3">,</span>
<a name="l158"><span class="ln">158 </span></a> <span class="s1">(</span><span class="s4">1</span><span class="s1">.</span><span class="s4">0 </span><span class="s1">* </span><span class="s2">camera</span><span class="s1">.</span><span class="s2">pitch</span><span class="s1">.</span><span class="s4">0</span><span class="s1">.</span><span class="s2">cos</span><span class="s1">())</span><span class="s3">,</span>
<a name="l159"><span class="ln">159 </span></a> <span class="s1">(</span><span class="s4">1</span><span class="s1">.</span><span class="s4">0 </span><span class="s1">* </span><span class="s2">camera</span><span class="s1">.</span><span class="s2">pitch</span><span class="s1">.</span><span class="s4">0</span><span class="s1">.</span><span class="s2">sin</span><span class="s1">() * </span><span class="s2">camera</span><span class="s1">.</span><span class="s2">yaw</span><span class="s1">.</span><span class="s4">0</span><span class="s1">.</span><span class="s2">cos</span><span class="s1">())</span><span class="s3">,</span>
<a name="l160"><span class="ln">160 </span></a> <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="s5">// Offset the yaw 90 degrees and set the pitch to level for our</span>
<a name="l163"><span class="ln">163 </span></a> <span class="s5">// right / left hand translation vectors</span>
<a name="l164"><span class="ln">164 </span></a> <span class="s0">let </span><span class="s2">offset </span><span class="s1">= </span><span class="s2">camera</span><span class="s1">.</span><span class="s2">yaw</span><span class="s1">.</span><span class="s4">0 </span><span class="s1">+ </span><span class="s2">PI</span><span class="s1">/</span><span class="s4">2</span><span class="s1">.</span><span class="s4">0</span><span class="s3">;</span>
<a name="l165"><span class="ln">165 </span></a> <span class="s0">let </span><span class="s2">pitch </span><span class="s1">= </span><span class="s2">PI</span><span class="s1">/</span><span class="s4">2</span><span class="s1">.</span><span class="s4">0</span><span class="s3">;</span>
<a name="l166"><span class="ln">166 </span></a> <span class="s0">let </span><span class="s2">left_vector </span><span class="s1">= </span><span class="s2">Vector3</span><span class="s1">::</span><span class="s2">new</span><span class="s1">(</span>
<a name="l167"><span class="ln">167 </span></a> <span class="s1">(</span><span class="s4">1</span><span class="s1">.</span><span class="s4">0 </span><span class="s1">* </span><span class="s2">pitch</span><span class="s1">.</span><span class="s2">sin</span><span class="s1">() * </span><span class="s2">offset</span><span class="s1">.</span><span class="s2">sin</span><span class="s1">())</span><span class="s3">,</span>
<a name="l168"><span class="ln">168 </span></a> <span class="s1">(</span><span class="s4">1</span><span class="s1">.</span><span class="s4">0 </span><span class="s1">* </span><span class="s2">pitch</span><span class="s1">.</span><span class="s2">cos</span><span class="s1">())</span><span class="s3">,</span>
<a name="l169"><span class="ln">169 </span></a> <span class="s1">(</span><span class="s4">1</span><span class="s1">.</span><span class="s4">0 </span><span class="s1">* </span><span class="s2">pitch</span><span class="s1">.</span><span class="s2">sin</span><span class="s1">() * </span><span class="s2">offset</span><span class="s1">.</span><span class="s2">cos</span><span class="s1">())</span><span class="s3">,</span>
<a name="l170"><span class="ln">170 </span></a> <span class="s1">)</span><span class="s3">;</span>
<a name="l171"><span class="ln">171 </span></a>
<a name="l172"><span class="ln">172 </span></a> <span class="s2">camera</span><span class="s1">.</span><span class="s2">position </span><span class="s1">+= </span><span class="s2">view_vector </span><span class="s1">* (</span><span class="s0">self</span><span class="s1">.</span><span class="s2">amount_forward </span><span class="s1">- </span><span class="s0">self</span><span class="s1">.</span><span class="s2">amount_backward</span><span class="s1">) * </span><span class="s0">self</span><span class="s1">.</span><span class="s2">speed </span><span class="s1">* </span><span class="s2">dt</span><span class="s3">;</span>
<a name="l173"><span class="ln">173 </span></a> <span class="s2">camera</span><span class="s1">.</span><span class="s2">position </span><span class="s1">+= </span><span class="s2">left_vector </span><span class="s1">* (</span><span class="s0">self</span><span class="s1">.</span><span class="s2">amount_left </span><span class="s1">- </span><span class="s0">self</span><span class="s1">.</span><span class="s2">amount_right</span><span class="s1">) * </span><span class="s0">self</span><span class="s1">.</span><span class="s2">speed </span><span class="s1">* </span><span class="s2">dt</span><span class="s3">;</span>
<a name="l174"><span class="ln">174 </span></a> <span class="s2">camera</span><span class="s1">.</span><span class="s2">position</span><span class="s1">.</span><span class="s2">y </span><span class="s1">+= (</span><span class="s0">self</span><span class="s1">.</span><span class="s2">amount_up </span><span class="s1">- </span><span class="s0">self</span><span class="s1">.</span><span class="s2">amount_down</span><span class="s1">) * </span><span class="s0">self</span><span class="s1">.</span><span class="s2">speed </span><span class="s1">* </span><span class="s2">dt</span><span class="s3">;</span>
<a name="l175"><span class="ln">175 </span></a>
<a name="l176"><span class="ln">176 </span></a> <span class="s5">// Rotate</span>
<a name="l177"><span class="ln">177 </span></a> <span class="s2">camera</span><span class="s1">.</span><span class="s2">yaw </span><span class="s1">+= </span><span class="s2">Rad</span><span class="s1">(</span><span class="s0">self</span><span class="s1">.</span><span class="s2">rotate_horizontal</span><span class="s1">) * </span><span class="s0">self</span><span class="s1">.</span><span class="s2">sensitivity </span><span class="s1">* </span><span class="s2">dt</span><span class="s3">;</span>
<a name="l178"><span class="ln">178 </span></a> <span class="s2">camera</span><span class="s1">.</span><span class="s2">pitch </span><span class="s1">+= </span><span class="s2">Rad</span><span class="s1">(</span><span class="s0">self</span><span class="s1">.</span><span class="s2">rotate_vertical</span><span class="s1">) * </span><span class="s0">self</span><span class="s1">.</span><span class="s2">sensitivity </span><span class="s1">* </span><span class="s2">dt</span><span class="s3">;</span>
<a name="l179"><span class="ln">179 </span></a>
<a name="l180"><span class="ln">180 </span></a> <span class="s0">self</span><span class="s1">.</span><span class="s2">rotate_horizontal </span><span class="s1">= </span><span class="s4">0</span><span class="s1">.</span><span class="s4">0</span><span class="s3">;</span>
<a name="l181"><span class="ln">181 </span></a> <span class="s0">self</span><span class="s1">.</span><span class="s2">rotate_vertical </span><span class="s1">= </span><span class="s4">0</span><span class="s1">.</span><span class="s4">0</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">// Keep the camera's angle from going too high/low.</span>
<a name="l184"><span class="ln">184 </span></a> <span class="s0">if </span><span class="s2">camera</span><span class="s1">.</span><span class="s2">pitch </span><span class="s1">&lt; -</span><span class="s2">Rad</span><span class="s1">(</span><span class="s4">0</span><span class="s1">.</span><span class="s4">001</span><span class="s1">) {</span>
<a name="l185"><span class="ln">185 </span></a> <span class="s2">camera</span><span class="s1">.</span><span class="s2">pitch </span><span class="s1">= -</span><span class="s2">Rad</span><span class="s1">(</span><span class="s4">0</span><span class="s1">.</span><span class="s4">001</span><span class="s1">)</span><span class="s3">;</span>
<a name="l186"><span class="ln">186 </span></a> <span class="s1">} </span><span class="s0">else if </span><span class="s2">camera</span><span class="s1">.</span><span class="s2">pitch </span><span class="s1">&gt; </span><span class="s2">Rad</span><span class="s1">(</span><span class="s2">PI </span><span class="s1">- </span><span class="s4">0</span><span class="s1">.</span><span class="s4">001</span><span class="s1">) {</span>
<a name="l187"><span class="ln">187 </span></a> <span class="s2">camera</span><span class="s1">.</span><span class="s2">pitch </span><span class="s1">= </span><span class="s2">Rad</span><span class="s1">(</span><span class="s2">PI </span><span class="s1">- </span><span class="s4">0</span><span class="s1">.</span><span class="s4">001</span><span class="s1">)</span><span class="s3">;</span>
<a name="l188"><span class="ln">188 </span></a> <span class="s1">}</span>
<a name="l189"><span class="ln">189 </span></a> <span class="s1">}</span>
<a name="l190"><span class="ln">190 </span></a><span class="s1">}</span>
<a name="l191"><span class="ln">191 </span></a></pre>
</body>
</html>

@ -0,0 +1,142 @@
<html>
<head>
<title>components.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: #7ec3e6;}
.s5 { color: #20999d; font-style: italic;}
.s6 { 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">
components.rs</font>
</center></td></tr></table>
<pre><a name="l1"><span class="ln">1 </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>
<a name="l2"><span class="ln">2 </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="l3"><span class="ln">3 </span></a>
<a name="l4"><span class="ln">4 </span></a><span class="s0">use </span><span class="s2">cgmath</span><span class="s1">::{</span><span class="s2">Deg</span><span class="s3">, </span><span class="s2">Euler</span><span class="s1">}</span><span class="s3">;</span>
<a name="l5"><span class="ln">5 </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><span class="s2">RigidBody</span><span class="s3">, </span><span class="s2">RigidBodyHandle</span><span class="s1">}</span><span class="s3">;</span>
<a name="l6"><span class="ln">6 </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">Collider </span><span class="s0">as </span><span class="s2">r3dCollider</span><span class="s3">;</span>
<a name="l7"><span class="ln">7 </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">ColliderHandle</span><span class="s3">;</span>
<a name="l8"><span class="ln">8 </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="l9"><span class="ln">9 </span></a>
<a name="l10"><span class="ln">10 </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">TomlPositionDescription</span><span class="s3">, </span><span class="s2">TomlRotationDescription</span><span class="s1">}</span><span class="s3">;</span>
<a name="l11"><span class="ln">11 </span></a><span class="s0">use </span><span class="s2">imgui</span><span class="s1">::</span><span class="s2">Ui</span><span class="s3">;</span>
<a name="l12"><span class="ln">12 </span></a>
<a name="l13"><span class="ln">13 </span></a><span class="s4">// a component is any type that is 'static, sized, send and sync</span>
<a name="l14"><span class="ln">14 </span></a>
<a name="l15"><span class="ln">15 </span></a><span class="s0">pub struct </span><span class="s2">ImguiWindow</span><span class="s1">&lt;</span><span class="s5">'a</span><span class="s3">, </span><span class="s2">T</span><span class="s1">&gt; {</span>
<a name="l16"><span class="ln">16 </span></a> <span class="s0">pub </span><span class="s2">window</span><span class="s1">: </span><span class="s0">fn</span><span class="s1">() -&gt; </span><span class="s2">imgui</span><span class="s1">::</span><span class="s2">Window</span><span class="s1">&lt;</span><span class="s5">'a</span><span class="s1">&gt;</span><span class="s3">,</span>
<a name="l17"><span class="ln">17 </span></a> <span class="s0">pub </span><span class="s2">func</span><span class="s1">: </span><span class="s0">fn</span><span class="s1">(&amp;</span><span class="s2">Ui</span><span class="s3">, </span><span class="s2">Vec</span><span class="s1">&lt;&amp;</span><span class="s2">T</span><span class="s1">&gt;)</span><span class="s3">,</span>
<a name="l18"><span class="ln">18 </span></a><span class="s1">}</span>
<a name="l19"><span class="ln">19 </span></a>
<a name="l20"><span class="ln">20 </span></a><span class="s1">#[</span><span class="s2">derive</span><span class="s1">(</span><span class="s2">Clone</span><span class="s3">, </span><span class="s2">Copy</span><span class="s3">, </span><span class="s2">Debug</span><span class="s3">, </span><span class="s2">PartialEq</span><span class="s1">)]</span>
<a name="l21"><span class="ln">21 </span></a><span class="s0">pub struct </span><span class="s2">LoopState </span><span class="s1">{</span>
<a name="l22"><span class="ln">22 </span></a> <span class="s0">pub </span><span class="s2">delta_time</span><span class="s1">: </span><span class="s2">Duration</span><span class="s3">,</span>
<a name="l23"><span class="ln">23 </span></a> <span class="s0">pub </span><span class="s2">start_time</span><span class="s1">: </span><span class="s2">Instant</span><span class="s3">,</span>
<a name="l24"><span class="ln">24 </span></a> <span class="s0">pub </span><span class="s2">step_size</span><span class="s1">: </span><span class="s2">f32</span><span class="s3">,</span>
<a name="l25"><span class="ln">25 </span></a><span class="s1">}</span>
<a name="l26"><span class="ln">26 </span></a>
<a name="l27"><span class="ln">27 </span></a><span class="s1">#[</span><span class="s2">derive</span><span class="s1">(</span><span class="s2">Clone</span><span class="s3">, </span><span class="s2">Copy</span><span class="s3">, </span><span class="s2">Debug</span><span class="s3">, </span><span class="s2">PartialEq</span><span class="s1">)]</span>
<a name="l28"><span class="ln">28 </span></a><span class="s0">pub struct </span><span class="s2">Position </span><span class="s1">{</span>
<a name="l29"><span class="ln">29 </span></a> <span class="s0">pub </span><span class="s2">x</span><span class="s1">: </span><span class="s2">f32</span><span class="s3">,</span>
<a name="l30"><span class="ln">30 </span></a> <span class="s0">pub </span><span class="s2">y</span><span class="s1">: </span><span class="s2">f32</span><span class="s3">,</span>
<a name="l31"><span class="ln">31 </span></a> <span class="s0">pub </span><span class="s2">z</span><span class="s1">: </span><span class="s2">f32</span><span class="s3">,</span>
<a name="l32"><span class="ln">32 </span></a> <span class="s0">pub </span><span class="s2">rot</span><span class="s1">: </span><span class="s2">cgmath</span><span class="s1">::</span><span class="s2">Euler</span><span class="s1">&lt;</span><span class="s2">Deg</span><span class="s1">&lt;</span><span class="s2">f32</span><span class="s1">&gt;&gt;</span><span class="s3">,</span>
<a name="l33"><span class="ln">33 </span></a><span class="s1">}</span>
<a name="l34"><span class="ln">34 </span></a>
<a name="l35"><span class="ln">35 </span></a><span class="s0">impl </span><span class="s2">Default </span><span class="s0">for </span><span class="s2">Position </span><span class="s1">{</span>
<a name="l36"><span class="ln">36 </span></a> <span class="s0">fn </span><span class="s2">default</span><span class="s1">() -&gt; </span><span class="s0">Self </span><span class="s1">{</span>
<a name="l37"><span class="ln">37 </span></a> <span class="s2">Position </span><span class="s1">{</span>
<a name="l38"><span class="ln">38 </span></a> <span class="s2">x</span><span class="s1">: </span><span class="s6">0</span><span class="s1">.</span><span class="s6">0</span><span class="s3">,</span>
<a name="l39"><span class="ln">39 </span></a> <span class="s2">y</span><span class="s1">: </span><span class="s6">0</span><span class="s1">.</span><span class="s6">0</span><span class="s3">,</span>
<a name="l40"><span class="ln">40 </span></a> <span class="s2">z</span><span class="s1">: </span><span class="s6">0</span><span class="s1">.</span><span class="s6">0</span><span class="s3">,</span>
<a name="l41"><span class="ln">41 </span></a> <span class="s2">rot</span><span class="s1">: </span><span class="s2">Euler </span><span class="s1">{</span>
<a name="l42"><span class="ln">42 </span></a> <span class="s2">x</span><span class="s1">: </span><span class="s2">Deg</span><span class="s1">(</span><span class="s6">0</span><span class="s1">.</span><span class="s6">0</span><span class="s1">)</span><span class="s3">,</span>
<a name="l43"><span class="ln">43 </span></a> <span class="s2">y</span><span class="s1">: </span><span class="s2">Deg</span><span class="s1">(</span><span class="s6">0</span><span class="s1">.</span><span class="s6">0</span><span class="s1">)</span><span class="s3">,</span>
<a name="l44"><span class="ln">44 </span></a> <span class="s2">z</span><span class="s1">: </span><span class="s2">Deg</span><span class="s1">(</span><span class="s6">0</span><span class="s1">.</span><span class="s6">0</span><span class="s1">)</span><span class="s3">,</span>
<a name="l45"><span class="ln">45 </span></a> <span class="s1">}</span><span class="s3">,</span>
<a name="l46"><span class="ln">46 </span></a> <span class="s1">}</span>
<a name="l47"><span class="ln">47 </span></a> <span class="s1">}</span>
<a name="l48"><span class="ln">48 </span></a><span class="s1">}</span>
<a name="l49"><span class="ln">49 </span></a>
<a name="l50"><span class="ln">50 </span></a><span class="s0">impl </span><span class="s2">From</span><span class="s1">&lt;</span><span class="s2">TomlPositionDescription</span><span class="s1">&gt; </span><span class="s0">for </span><span class="s2">Position </span><span class="s1">{</span>
<a name="l51"><span class="ln">51 </span></a> <span class="s0">fn </span><span class="s2">from</span><span class="s1">(</span><span class="s2">pos</span><span class="s1">: </span><span class="s2">TomlPositionDescription</span><span class="s1">) -&gt; </span><span class="s0">Self </span><span class="s1">{</span>
<a name="l52"><span class="ln">52 </span></a> <span class="s0">let </span><span class="s2">euler </span><span class="s1">= </span><span class="s0">match </span><span class="s2">pos</span><span class="s1">.</span><span class="s2">rot </span><span class="s1">{</span>
<a name="l53"><span class="ln">53 </span></a> <span class="s2">None </span><span class="s1">=&gt; </span><span class="s2">Euler </span><span class="s1">{</span>
<a name="l54"><span class="ln">54 </span></a> <span class="s2">x</span><span class="s1">: </span><span class="s2">Deg</span><span class="s1">(</span><span class="s6">0</span><span class="s1">.</span><span class="s6">0</span><span class="s1">)</span><span class="s3">,</span>
<a name="l55"><span class="ln">55 </span></a> <span class="s2">y</span><span class="s1">: </span><span class="s2">Deg</span><span class="s1">(</span><span class="s6">0</span><span class="s1">.</span><span class="s6">0</span><span class="s1">)</span><span class="s3">,</span>
<a name="l56"><span class="ln">56 </span></a> <span class="s2">z</span><span class="s1">: </span><span class="s2">Deg</span><span class="s1">(</span><span class="s6">0</span><span class="s1">.</span><span class="s6">0</span><span class="s1">)</span><span class="s3">,</span>
<a name="l57"><span class="ln">57 </span></a> <span class="s1">}</span><span class="s3">,</span>
<a name="l58"><span class="ln">58 </span></a> <span class="s2">Some</span><span class="s1">(</span><span class="s2">v</span><span class="s1">) =&gt; </span><span class="s2">Euler </span><span class="s1">{</span>
<a name="l59"><span class="ln">59 </span></a> <span class="s2">x</span><span class="s1">: </span><span class="s2">Deg</span><span class="s1">(</span><span class="s2">v</span><span class="s1">.</span><span class="s2">x</span><span class="s1">)</span><span class="s3">,</span>
<a name="l60"><span class="ln">60 </span></a> <span class="s2">y</span><span class="s1">: </span><span class="s2">Deg</span><span class="s1">(</span><span class="s2">v</span><span class="s1">.</span><span class="s2">y</span><span class="s1">)</span><span class="s3">,</span>
<a name="l61"><span class="ln">61 </span></a> <span class="s2">z</span><span class="s1">: </span><span class="s2">Deg</span><span class="s1">(</span><span class="s2">v</span><span class="s1">.</span><span class="s2">z</span><span class="s1">)</span><span class="s3">,</span>
<a name="l62"><span class="ln">62 </span></a> <span class="s1">}</span><span class="s3">,</span>
<a name="l63"><span class="ln">63 </span></a> <span class="s1">}</span><span class="s3">;</span>
<a name="l64"><span class="ln">64 </span></a> <span class="s2">Position </span><span class="s1">{</span>
<a name="l65"><span class="ln">65 </span></a> <span class="s2">x</span><span class="s1">: </span><span class="s2">pos</span><span class="s1">.</span><span class="s2">x</span><span class="s3">,</span>
<a name="l66"><span class="ln">66 </span></a> <span class="s2">y</span><span class="s1">: </span><span class="s2">pos</span><span class="s1">.</span><span class="s2">y</span><span class="s3">,</span>
<a name="l67"><span class="ln">67 </span></a> <span class="s2">z</span><span class="s1">: </span><span class="s2">pos</span><span class="s1">.</span><span class="s2">z</span><span class="s3">,</span>
<a name="l68"><span class="ln">68 </span></a> <span class="s2">rot</span><span class="s1">: </span><span class="s2">euler</span><span class="s3">,</span>
<a name="l69"><span class="ln">69 </span></a> <span class="s1">}</span>
<a name="l70"><span class="ln">70 </span></a> <span class="s1">}</span>
<a name="l71"><span class="ln">71 </span></a><span class="s1">}</span>
<a name="l72"><span class="ln">72 </span></a>
<a name="l73"><span class="ln">73 </span></a><span class="s0">impl </span><span class="s2">From</span><span class="s1">&lt;</span><span class="s2">Option</span><span class="s1">&lt;</span><span class="s2">TomlPositionDescription</span><span class="s1">&gt;&gt; </span><span class="s0">for </span><span class="s2">Position </span><span class="s1">{</span>
<a name="l74"><span class="ln">74 </span></a> <span class="s0">fn </span><span class="s2">from</span><span class="s1">(</span><span class="s2">pos</span><span class="s1">: </span><span class="s2">Option</span><span class="s1">&lt;</span><span class="s2">TomlPositionDescription</span><span class="s1">&gt;) -&gt; </span><span class="s0">Self </span><span class="s1">{</span>
<a name="l75"><span class="ln">75 </span></a> <span class="s0">match </span><span class="s2">pos </span><span class="s1">{</span>
<a name="l76"><span class="ln">76 </span></a> <span class="s2">None </span><span class="s1">=&gt; </span><span class="s2">Position </span><span class="s1">{</span>
<a name="l77"><span class="ln">77 </span></a> <span class="s2">x</span><span class="s1">: </span><span class="s6">0</span><span class="s1">.</span><span class="s6">0</span><span class="s3">,</span>
<a name="l78"><span class="ln">78 </span></a> <span class="s2">y</span><span class="s1">: </span><span class="s6">0</span><span class="s1">.</span><span class="s6">0</span><span class="s3">,</span>
<a name="l79"><span class="ln">79 </span></a> <span class="s2">z</span><span class="s1">: </span><span class="s6">0</span><span class="s1">.</span><span class="s6">0</span><span class="s3">,</span>
<a name="l80"><span class="ln">80 </span></a> <span class="s2">rot</span><span class="s1">: </span><span class="s2">Euler </span><span class="s1">{</span>
<a name="l81"><span class="ln">81 </span></a> <span class="s2">x</span><span class="s1">: </span><span class="s2">Deg</span><span class="s1">(</span><span class="s6">0</span><span class="s1">.</span><span class="s6">0</span><span class="s1">)</span><span class="s3">,</span>
<a name="l82"><span class="ln">82 </span></a> <span class="s2">y</span><span class="s1">: </span><span class="s2">Deg</span><span class="s1">(</span><span class="s6">0</span><span class="s1">.</span><span class="s6">0</span><span class="s1">)</span><span class="s3">,</span>
<a name="l83"><span class="ln">83 </span></a> <span class="s2">z</span><span class="s1">: </span><span class="s2">Deg</span><span class="s1">(</span><span class="s6">0</span><span class="s1">.</span><span class="s6">0</span><span class="s1">)</span><span class="s3">,</span>
<a name="l84"><span class="ln">84 </span></a> <span class="s1">}</span><span class="s3">,</span>
<a name="l85"><span class="ln">85 </span></a> <span class="s1">}</span><span class="s3">,</span>
<a name="l86"><span class="ln">86 </span></a> <span class="s2">Some</span><span class="s1">(</span><span class="s2">v</span><span class="s1">) =&gt; </span><span class="s2">Position</span><span class="s1">::</span><span class="s2">from</span><span class="s1">(</span><span class="s2">v</span><span class="s1">)</span><span class="s3">,</span>
<a name="l87"><span class="ln">87 </span></a> <span class="s1">}</span>
<a name="l88"><span class="ln">88 </span></a> <span class="s1">}</span>
<a name="l89"><span class="ln">89 </span></a><span class="s1">}</span>
<a name="l90"><span class="ln">90 </span></a>
<a name="l91"><span class="ln">91 </span></a><span class="s1">#[</span><span class="s2">derive</span><span class="s1">(</span><span class="s2">Clone</span><span class="s3">, </span><span class="s2">Default</span><span class="s3">, </span><span class="s2">PartialEq</span><span class="s3">, </span><span class="s2">Eq</span><span class="s3">, </span><span class="s2">Hash</span><span class="s3">, </span><span class="s2">Copy</span><span class="s3">, </span><span class="s2">Debug</span><span class="s1">)]</span>
<a name="l92"><span class="ln">92 </span></a><span class="s0">pub struct </span><span class="s2">RangeCopy</span><span class="s1">&lt;</span><span class="s2">Idx</span><span class="s1">&gt; {</span>
<a name="l93"><span class="ln">93 </span></a> <span class="s0">pub </span><span class="s2">start</span><span class="s1">: </span><span class="s2">Idx</span><span class="s3">,</span>
<a name="l94"><span class="ln">94 </span></a> <span class="s0">pub </span><span class="s2">end</span><span class="s1">: </span><span class="s2">Idx</span><span class="s3">,</span>
<a name="l95"><span class="ln">95 </span></a><span class="s1">}</span>
<a name="l96"><span class="ln">96 </span></a>
<a name="l97"><span class="ln">97 </span></a><span class="s1">#[</span><span class="s2">derive</span><span class="s1">(</span><span class="s2">Clone</span><span class="s3">, </span><span class="s2">Debug</span><span class="s1">)]</span>
<a name="l98"><span class="ln">98 </span></a><span class="s0">pub struct </span><span class="s2">Mesh </span><span class="s1">{</span>
<a name="l99"><span class="ln">99 </span></a> <span class="s0">pub </span><span class="s2">index_buffer</span><span class="s1">: </span><span class="s2">Arc</span><span class="s1">&lt;</span><span class="s2">Buffer</span><span class="s1">&gt;</span><span class="s3">,</span>
<a name="l100"><span class="ln">100 </span></a> <span class="s0">pub </span><span class="s2">index_count</span><span class="s1">: </span><span class="s2">usize</span><span class="s3">,</span>
<a name="l101"><span class="ln">101 </span></a> <span class="s0">pub </span><span class="s2">index_format</span><span class="s1">: </span><span class="s2">wgpu</span><span class="s1">::</span><span class="s2">IndexFormat</span><span class="s3">,</span>
<a name="l102"><span class="ln">102 </span></a> <span class="s0">pub </span><span class="s2">vertex_buffer</span><span class="s1">: </span><span class="s2">Arc</span><span class="s1">&lt;</span><span class="s2">Buffer</span><span class="s1">&gt;</span><span class="s3">,</span>
<a name="l103"><span class="ln">103 </span></a> <span class="s0">pub </span><span class="s2">uniform_buffer</span><span class="s1">: </span><span class="s2">Arc</span><span class="s1">&lt;</span><span class="s2">Buffer</span><span class="s1">&gt;</span><span class="s3">,</span>
<a name="l104"><span class="ln">104 </span></a> <span class="s0">pub </span><span class="s2">bind_group</span><span class="s1">: </span><span class="s2">Arc</span><span class="s1">&lt;</span><span class="s2">BindGroup</span><span class="s1">&gt;</span><span class="s3">,</span>
<a name="l105"><span class="ln">105 </span></a> <span class="s0">pub </span><span class="s2">color</span><span class="s1">: </span><span class="s2">wgpu</span><span class="s1">::</span><span class="s2">Color</span><span class="s3">,</span>
<a name="l106"><span class="ln">106 </span></a><span class="s1">}</span>
<a name="l107"><span class="ln">107 </span></a>
<a name="l108"><span class="ln">108 </span></a><span class="s1">#[</span><span class="s2">derive</span><span class="s1">(</span><span class="s2">Clone</span><span class="s3">, </span><span class="s2">Debug</span><span class="s1">)]</span>
<a name="l109"><span class="ln">109 </span></a><span class="s0">pub struct </span><span class="s2">Physics </span><span class="s1">{</span>
<a name="l110"><span class="ln">110 </span></a> <span class="s0">pub </span><span class="s2">rigid_body</span><span class="s1">: </span><span class="s2">RigidBody</span><span class="s3">,</span>
<a name="l111"><span class="ln">111 </span></a> <span class="s0">pub </span><span class="s2">rigid_body_handle</span><span class="s1">: </span><span class="s2">Option</span><span class="s1">&lt;</span><span class="s2">RigidBodyHandle</span><span class="s1">&gt;</span><span class="s3">,</span>
<a name="l112"><span class="ln">112 </span></a><span class="s1">}</span>
<a name="l113"><span class="ln">113 </span></a>
<a name="l114"><span class="ln">114 </span></a><span class="s1">#[</span><span class="s2">derive</span><span class="s1">(</span><span class="s2">Clone</span><span class="s1">)]</span>
<a name="l115"><span class="ln">115 </span></a><span class="s0">pub struct </span><span class="s2">Collider </span><span class="s1">{</span>
<a name="l116"><span class="ln">116 </span></a> <span class="s0">pub </span><span class="s2">collider</span><span class="s1">: </span><span class="s2">r3dCollider</span><span class="s3">,</span>
<a name="l117"><span class="ln">117 </span></a> <span class="s0">pub </span><span class="s2">collider_handle</span><span class="s1">: </span><span class="s2">Option</span><span class="s1">&lt;</span><span class="s2">ColliderHandle</span><span class="s1">&gt;</span><span class="s3">,</span>
<a name="l118"><span class="ln">118 </span></a><span class="s1">}</span>
<a name="l119"><span class="ln">119 </span></a></pre>
</body>
</html>

File diff suppressed because it is too large Load Diff

@ -0,0 +1,164 @@
<html>
<head>
<title>geometry.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: #33ccff; font-weight: bold;}
.s5 { color: #499936; font-style: italic;}
.s6 { color: #54b33e;}
.s7 { color: #7ec3e6;}
.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">
geometry.rs</font>
</center></td></tr></table>
<pre><a name="l1"><span class="ln">1 </span></a><span class="s0">use </span><span class="s2">bytemuck</span><span class="s1">::{</span><span class="s2">Pod</span><span class="s3">, </span><span class="s2">Zeroable</span><span class="s1">}</span><span class="s3">;</span>
<a name="l2"><span class="ln">2 </span></a><span class="s0">use </span><span class="s2">nalgebra</span><span class="s1">::</span><span class="s2">Vector4</span><span class="s3">;</span>
<a name="l3"><span class="ln">3 </span></a><span class="s0">use </span><span class="s2">rapier3d</span><span class="s1">::</span><span class="s2">parry</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="l4"><span class="ln">4 </span></a><span class="s0">use </span><span class="s2">tobj</span><span class="s1">::{</span><span class="s2">LoadError</span><span class="s3">, </span><span class="s2">Model</span><span class="s3">, </span><span class="s2">Material</span><span class="s1">}</span><span class="s3">;</span>
<a name="l5"><span class="ln">5 </span></a>
<a name="l6"><span class="ln">6 </span></a>
<a name="l7"><span class="ln">7 </span></a><span class="s1">#[</span><span class="s2">repr</span><span class="s1">(</span><span class="s2">C</span><span class="s1">)]</span>
<a name="l8"><span class="ln">8 </span></a><span class="s1">#[</span><span class="s2">derive</span><span class="s1">(</span><span class="s2">Clone</span><span class="s3">, </span><span class="s2">Copy</span><span class="s3">, </span><span class="s2">Debug</span><span class="s1">)]</span>
<a name="l9"><span class="ln">9 </span></a><span class="s0">pub struct </span><span class="s2">Vertex </span><span class="s1">{</span>
<a name="l10"><span class="ln">10 </span></a> <span class="s2">pos</span><span class="s1">: [</span><span class="s2">f32</span><span class="s3">; </span><span class="s4">4</span><span class="s1">]</span><span class="s3">,</span>
<a name="l11"><span class="ln">11 </span></a> <span class="s2">normal</span><span class="s1">: [</span><span class="s2">f32</span><span class="s3">; </span><span class="s4">4</span><span class="s1">]</span><span class="s3">,</span>
<a name="l12"><span class="ln">12 </span></a> <span class="s2">uv</span><span class="s1">: [</span><span class="s2">f32</span><span class="s3">; </span><span class="s4">2</span><span class="s1">]</span><span class="s3">,</span>
<a name="l13"><span class="ln">13 </span></a><span class="s1">}</span>
<a name="l14"><span class="ln">14 </span></a>
<a name="l15"><span class="ln">15 </span></a><span class="s0">impl </span><span class="s2">Vertex </span><span class="s1">{</span>
<a name="l16"><span class="ln">16 </span></a> <span class="s0">pub fn </span><span class="s2">position</span><span class="s1">(&amp;</span><span class="s0">self</span><span class="s1">) -&gt; </span><span class="s2">Point</span><span class="s1">&lt;</span><span class="s2">f32</span><span class="s1">&gt; {</span>
<a name="l17"><span class="ln">17 </span></a> <span class="s2">Point</span><span class="s1">::&lt;</span><span class="s2">f32</span><span class="s1">&gt;::</span><span class="s2">new</span><span class="s1">(</span><span class="s0">self</span><span class="s1">.</span><span class="s2">pos</span><span class="s1">[</span><span class="s4">0</span><span class="s1">]</span><span class="s3">, </span><span class="s0">self</span><span class="s1">.</span><span class="s2">pos</span><span class="s1">[</span><span class="s4">1</span><span class="s1">]</span><span class="s3">, </span><span class="s0">self</span><span class="s1">.</span><span class="s2">pos</span><span class="s1">[</span><span class="s4">2</span><span class="s1">])</span>
<a name="l18"><span class="ln">18 </span></a> <span class="s1">}</span>
<a name="l19"><span class="ln">19 </span></a> <span class="s0">pub fn </span><span class="s2">from</span><span class="s1">(</span><span class="s2">pos</span><span class="s1">: [</span><span class="s2">f32</span><span class="s3">; </span><span class="s4">3</span><span class="s1">]</span><span class="s3">, </span><span class="s2">nor</span><span class="s1">: [</span><span class="s2">f32</span><span class="s3">; </span><span class="s4">3</span><span class="s1">]</span><span class="s3">, </span><span class="s2">uv</span><span class="s1">: [</span><span class="s2">f32</span><span class="s3">; </span><span class="s4">2</span><span class="s1">]) -&gt; </span><span class="s2">Vertex </span><span class="s1">{</span>
<a name="l20"><span class="ln">20 </span></a> <span class="s2">Vertex </span><span class="s1">{</span>
<a name="l21"><span class="ln">21 </span></a> <span class="s2">pos</span><span class="s1">: [</span><span class="s2">pos</span><span class="s1">[</span><span class="s4">0</span><span class="s1">]</span><span class="s3">, </span><span class="s2">pos</span><span class="s1">[</span><span class="s4">1</span><span class="s1">]</span><span class="s3">, </span><span class="s2">pos</span><span class="s1">[</span><span class="s4">2</span><span class="s1">]</span><span class="s3">, </span><span class="s4">1</span><span class="s1">.</span><span class="s4">0</span><span class="s1">]</span><span class="s3">,</span>
<a name="l22"><span class="ln">22 </span></a> <span class="s2">normal</span><span class="s1">: [</span><span class="s2">nor</span><span class="s1">[</span><span class="s4">0</span><span class="s1">]</span><span class="s3">, </span><span class="s2">nor</span><span class="s1">[</span><span class="s4">1</span><span class="s1">]</span><span class="s3">, </span><span class="s2">nor</span><span class="s1">[</span><span class="s4">2</span><span class="s1">]</span><span class="s3">, </span><span class="s4">0</span><span class="s1">.</span><span class="s4">0</span><span class="s1">]</span><span class="s3">,</span>
<a name="l23"><span class="ln">23 </span></a> <span class="s2">uv</span><span class="s1">: [</span><span class="s2">uv</span><span class="s1">[</span><span class="s4">0</span><span class="s1">]</span><span class="s3">, </span><span class="s2">uv</span><span class="s1">[</span><span class="s4">1</span><span class="s1">]]</span><span class="s3">,</span>
<a name="l24"><span class="ln">24 </span></a> <span class="s1">}</span>
<a name="l25"><span class="ln">25 </span></a> <span class="s1">}</span>
<a name="l26"><span class="ln">26 </span></a><span class="s1">}</span>
<a name="l27"><span class="ln">27 </span></a>
<a name="l28"><span class="ln">28 </span></a><span class="s0">unsafe impl </span><span class="s2">Pod </span><span class="s0">for </span><span class="s2">Vertex </span><span class="s1">{}</span>
<a name="l29"><span class="ln">29 </span></a><span class="s0">unsafe impl </span><span class="s2">Zeroable </span><span class="s0">for </span><span class="s2">Vertex </span><span class="s1">{}</span>
<a name="l30"><span class="ln">30 </span></a>
<a name="l31"><span class="ln">31 </span></a><span class="s1">#[</span><span class="s2">derive</span><span class="s1">(</span><span class="s2">Clone</span><span class="s3">, </span><span class="s2">Debug</span><span class="s1">)]</span>
<a name="l32"><span class="ln">32 </span></a><span class="s0">pub struct </span><span class="s2">RawMesh </span><span class="s1">{</span>
<a name="l33"><span class="ln">33 </span></a> <span class="s0">pub </span><span class="s2">vertices</span><span class="s1">: </span><span class="s2">Vec</span><span class="s1">&lt;</span><span class="s2">Vertex</span><span class="s1">&gt;</span><span class="s3">,</span>
<a name="l34"><span class="ln">34 </span></a> <span class="s0">pub </span><span class="s2">indices</span><span class="s1">: </span><span class="s2">Vec</span><span class="s1">&lt;[</span><span class="s2">u32</span><span class="s3">; </span><span class="s4">3</span><span class="s1">]&gt;</span><span class="s3">,</span>
<a name="l35"><span class="ln">35 </span></a><span class="s1">}</span>
<a name="l36"><span class="ln">36 </span></a>
<a name="l37"><span class="ln">37 </span></a>
<a name="l38"><span class="ln">38 </span></a><span class="s5">/// We use meshes in a few different places. To keep things simple, we return</span>
<a name="l39"><span class="ln">39 </span></a><span class="s5">/// the most basic, direct-to-memory version. If something fancy needs to be done</span>
<a name="l40"><span class="ln">40 </span></a><span class="s5">/// with it, the fancy stays there</span>
<a name="l41"><span class="ln">41 </span></a><span class="s0">pub fn </span><span class="s2">load_obj</span><span class="s1">(</span><span class="s2">obj_path</span><span class="s1">: &amp;</span><span class="s2">str</span><span class="s1">) -&gt; </span><span class="s2">Result</span><span class="s1">&lt;</span><span class="s2">RawMesh</span><span class="s3">, </span><span class="s2">String</span><span class="s1">&gt; {</span>
<a name="l42"><span class="ln">42 </span></a>
<a name="l43"><span class="ln">43 </span></a> <span class="s2">log</span><span class="s1">::</span><span class="s2">info</span><span class="s1">!(</span><span class="s6">&quot;Loading object {}&quot;</span><span class="s3">, </span><span class="s2">obj_path</span><span class="s1">)</span><span class="s3">;</span>
<a name="l44"><span class="ln">44 </span></a>
<a name="l45"><span class="ln">45 </span></a> <span class="s7">// Is there no better way to translate error messages?</span>
<a name="l46"><span class="ln">46 </span></a> <span class="s0">let </span><span class="s1">(</span><span class="s2">models</span><span class="s3">, </span><span class="s2">materials</span><span class="s1">) = </span><span class="s0">match </span><span class="s2">tobj</span><span class="s1">::</span><span class="s2">load_obj</span><span class="s1">(</span><span class="s2">obj_path</span><span class="s3">, </span><span class="s0">true</span><span class="s1">) {</span>
<a name="l47"><span class="ln">47 </span></a> <span class="s2">Ok</span><span class="s1">((</span><span class="s2">a</span><span class="s3">, </span><span class="s2">b</span><span class="s1">)) =&gt; {</span><span class="s2">Ok</span><span class="s1">((</span><span class="s2">a</span><span class="s3">, </span><span class="s2">b</span><span class="s1">))}</span>
<a name="l48"><span class="ln">48 </span></a> <span class="s2">Err</span><span class="s1">(</span><span class="s2">load_error</span><span class="s1">) =&gt; {</span><span class="s2">Err</span><span class="s1">(</span><span class="s2">load_error</span><span class="s1">.</span><span class="s2">to_string</span><span class="s1">())}</span>
<a name="l49"><span class="ln">49 </span></a> <span class="s1">}?</span><span class="s3">;</span>
<a name="l50"><span class="ln">50 </span></a>
<a name="l51"><span class="ln">51 </span></a> <span class="s7">// println!(&quot;# of models: {}&quot;, models.len());</span>
<a name="l52"><span class="ln">52 </span></a> <span class="s7">// println!(&quot;# of materials: {}&quot;, materials.len());</span>
<a name="l53"><span class="ln">53 </span></a> <span class="s7">// println!(&quot;{:?}&quot;, materials);</span>
<a name="l54"><span class="ln">54 </span></a>
<a name="l55"><span class="ln">55 </span></a> <span class="s0">let mut </span><span class="s2">index_data</span><span class="s1">: </span><span class="s2">Vec</span><span class="s1">&lt;[</span><span class="s2">u32</span><span class="s3">; </span><span class="s4">3</span><span class="s1">]&gt; = </span><span class="s2">Vec</span><span class="s1">::</span><span class="s2">new</span><span class="s1">()</span><span class="s3">;</span>
<a name="l56"><span class="ln">56 </span></a> <span class="s0">let mut </span><span class="s2">vertex_data </span><span class="s1">= </span><span class="s2">Vec</span><span class="s1">::</span><span class="s2">new</span><span class="s1">()</span><span class="s3">;</span>
<a name="l57"><span class="ln">57 </span></a>
<a name="l58"><span class="ln">58 </span></a> <span class="s0">for </span><span class="s2">model </span><span class="s0">in </span><span class="s2">models </span><span class="s1">{</span>
<a name="l59"><span class="ln">59 </span></a> <span class="s0">let </span><span class="s2">mesh </span><span class="s1">= &amp;</span><span class="s2">model</span><span class="s1">.</span><span class="s2">mesh</span><span class="s3">;</span>
<a name="l60"><span class="ln">60 </span></a>
<a name="l61"><span class="ln">61 </span></a> <span class="s7">// Cycle through the faces and chunk out the indices</span>
<a name="l62"><span class="ln">62 </span></a> <span class="s0">let mut </span><span class="s2">next_face </span><span class="s1">= </span><span class="s4">0</span><span class="s3">;</span>
<a name="l63"><span class="ln">63 </span></a> <span class="s0">for </span><span class="s2">f </span><span class="s0">in </span><span class="s4">0</span><span class="s1">..</span><span class="s2">mesh</span><span class="s1">.</span><span class="s2">num_face_indices</span><span class="s1">.</span><span class="s2">len</span><span class="s1">() {</span>
<a name="l64"><span class="ln">64 </span></a> <span class="s7">// calculate the next chunk</span>
<a name="l65"><span class="ln">65 </span></a> <span class="s0">let </span><span class="s2">end </span><span class="s1">= </span><span class="s2">next_face </span><span class="s1">+ </span><span class="s2">mesh</span><span class="s1">.</span><span class="s2">num_face_indices</span><span class="s1">[</span><span class="s2">f</span><span class="s1">] </span><span class="s0">as </span><span class="s2">usize</span><span class="s3">;</span>
<a name="l66"><span class="ln">66 </span></a> <span class="s0">let </span><span class="s2">face_indices</span><span class="s1">: </span><span class="s2">Vec</span><span class="s1">&lt;</span><span class="s2">_</span><span class="s1">&gt; = </span><span class="s2">mesh</span><span class="s1">.</span><span class="s2">indices</span><span class="s1">[</span><span class="s2">next_face</span><span class="s1">..</span><span class="s2">end</span><span class="s1">].</span><span class="s2">iter</span><span class="s1">().</span><span class="s2">collect</span><span class="s1">()</span><span class="s3">;</span>
<a name="l67"><span class="ln">67 </span></a>
<a name="l68"><span class="ln">68 </span></a> <span class="s0">if </span><span class="s2">face_indices</span><span class="s1">.</span><span class="s2">len</span><span class="s1">() != </span><span class="s4">3 </span><span class="s1">{</span>
<a name="l69"><span class="ln">69 </span></a> <span class="s0">return </span><span class="s2">Err</span><span class="s1">(</span><span class="s6">&quot;we only handle triangulated faces&quot;</span><span class="s1">.</span><span class="s2">to_string</span><span class="s1">())</span><span class="s3">;</span>
<a name="l70"><span class="ln">70 </span></a> <span class="s1">}</span>
<a name="l71"><span class="ln">71 </span></a> <span class="s2">index_data</span><span class="s1">.</span><span class="s2">push</span><span class="s1">([*</span><span class="s2">face_indices</span><span class="s1">[</span><span class="s4">0</span><span class="s1">]</span><span class="s3">, </span><span class="s1">*</span><span class="s2">face_indices</span><span class="s1">[</span><span class="s4">1</span><span class="s1">]</span><span class="s3">, </span><span class="s1">*</span><span class="s2">face_indices</span><span class="s1">[</span><span class="s4">2</span><span class="s1">]])</span><span class="s3">;</span>
<a name="l72"><span class="ln">72 </span></a> <span class="s2">next_face </span><span class="s1">= </span><span class="s2">end</span><span class="s3">;</span>
<a name="l73"><span class="ln">73 </span></a> <span class="s1">}</span>
<a name="l74"><span class="ln">74 </span></a>
<a name="l75"><span class="ln">75 </span></a> <span class="s0">if </span><span class="s2">mesh</span><span class="s1">.</span><span class="s2">positions</span><span class="s1">.</span><span class="s2">len</span><span class="s1">() % </span><span class="s4">3 </span><span class="s1">!= </span><span class="s4">0 </span><span class="s1">{</span>
<a name="l76"><span class="ln">76 </span></a> <span class="s0">return </span><span class="s2">Err</span><span class="s1">(</span><span class="s2">format</span><span class="s1">!(</span><span class="s6">&quot;position array not % 3 : {}&quot;</span><span class="s3">, </span><span class="s2">mesh</span><span class="s1">.</span><span class="s2">positions</span><span class="s1">.</span><span class="s2">len</span><span class="s1">()))</span>
<a name="l77"><span class="ln">77 </span></a> <span class="s1">}</span>
<a name="l78"><span class="ln">78 </span></a> <span class="s0">if </span><span class="s2">mesh</span><span class="s1">.</span><span class="s2">texcoords</span><span class="s1">.</span><span class="s2">len</span><span class="s1">() % </span><span class="s4">2 </span><span class="s1">!= </span><span class="s4">0 </span><span class="s1">{</span>
<a name="l79"><span class="ln">79 </span></a> <span class="s0">return </span><span class="s2">Err</span><span class="s1">(</span><span class="s2">format</span><span class="s1">!(</span><span class="s6">&quot;position array not % 3 : {}&quot;</span><span class="s3">, </span><span class="s2">mesh</span><span class="s1">.</span><span class="s2">positions</span><span class="s1">.</span><span class="s2">len</span><span class="s1">()))</span>
<a name="l80"><span class="ln">80 </span></a> <span class="s1">}</span>
<a name="l81"><span class="ln">81 </span></a> <span class="s0">if </span><span class="s2">mesh</span><span class="s1">.</span><span class="s2">normals</span><span class="s1">.</span><span class="s2">is_empty</span><span class="s1">() {</span>
<a name="l82"><span class="ln">82 </span></a> <span class="s0">return </span><span class="s2">Err</span><span class="s1">(</span><span class="s2">format</span><span class="s1">!(</span><span class="s6">&quot;It would be best if this had normals&quot;</span><span class="s1">))</span>
<a name="l83"><span class="ln">83 </span></a> <span class="s1">}</span>
<a name="l84"><span class="ln">84 </span></a> <span class="s0">if </span><span class="s2">mesh</span><span class="s1">.</span><span class="s2">texcoords</span><span class="s1">.</span><span class="s2">is_empty</span><span class="s1">() {</span>
<a name="l85"><span class="ln">85 </span></a> <span class="s2">log</span><span class="s1">::</span><span class="s2">info</span><span class="s1">!(</span><span class="s6">&quot;</span><span class="s0">\t</span><span class="s6">Mesh texture coordinates empty&quot;</span><span class="s1">)</span>
<a name="l86"><span class="ln">86 </span></a> <span class="s1">}</span>
<a name="l87"><span class="ln">87 </span></a>
<a name="l88"><span class="ln">88 </span></a> <span class="s0">for </span><span class="s2">v </span><span class="s0">in </span><span class="s4">0</span><span class="s1">..</span><span class="s2">mesh</span><span class="s1">.</span><span class="s2">positions</span><span class="s1">.</span><span class="s2">len</span><span class="s1">() / </span><span class="s4">3 </span><span class="s1">{</span>
<a name="l89"><span class="ln">89 </span></a> <span class="s0">let </span><span class="s2">texcoords </span><span class="s1">= </span><span class="s0">if </span><span class="s2">mesh</span><span class="s1">.</span><span class="s2">texcoords</span><span class="s1">.</span><span class="s2">len</span><span class="s1">() == </span><span class="s4">0 </span><span class="s1">{</span>
<a name="l90"><span class="ln">90 </span></a> <span class="s1">[</span><span class="s4">0</span><span class="s1">.</span><span class="s4">0</span><span class="s3">, </span><span class="s4">0</span><span class="s1">.</span><span class="s4">0</span><span class="s1">]</span>
<a name="l91"><span class="ln">91 </span></a> <span class="s1">} </span><span class="s0">else </span><span class="s1">{</span>
<a name="l92"><span class="ln">92 </span></a> <span class="s1">[</span><span class="s2">mesh</span><span class="s1">.</span><span class="s2">texcoords</span><span class="s1">[</span><span class="s4">2 </span><span class="s1">* </span><span class="s2">v</span><span class="s1">]</span><span class="s3">, </span><span class="s2">mesh</span><span class="s1">.</span><span class="s2">texcoords</span><span class="s1">[</span><span class="s4">2 </span><span class="s1">* </span><span class="s2">v </span><span class="s1">+ </span><span class="s4">1</span><span class="s1">]]</span>
<a name="l93"><span class="ln">93 </span></a> <span class="s1">}</span><span class="s3">;</span>
<a name="l94"><span class="ln">94 </span></a>
<a name="l95"><span class="ln">95 </span></a> <span class="s2">vertex_data</span><span class="s1">.</span><span class="s2">push</span><span class="s1">(</span><span class="s2">Vertex</span><span class="s1">::</span><span class="s2">from</span><span class="s1">(</span>
<a name="l96"><span class="ln">96 </span></a> <span class="s1">[</span>
<a name="l97"><span class="ln">97 </span></a> <span class="s2">mesh</span><span class="s1">.</span><span class="s2">positions</span><span class="s1">[</span><span class="s4">3 </span><span class="s1">* </span><span class="s2">v</span><span class="s1">]</span><span class="s3">,</span>
<a name="l98"><span class="ln">98 </span></a> <span class="s2">mesh</span><span class="s1">.</span><span class="s2">positions</span><span class="s1">[</span><span class="s4">3 </span><span class="s1">* </span><span class="s2">v </span><span class="s1">+ </span><span class="s4">1</span><span class="s1">]</span><span class="s3">,</span>
<a name="l99"><span class="ln">99 </span></a> <span class="s2">mesh</span><span class="s1">.</span><span class="s2">positions</span><span class="s1">[</span><span class="s4">3 </span><span class="s1">* </span><span class="s2">v </span><span class="s1">+ </span><span class="s4">2</span><span class="s1">]</span><span class="s3">,</span>
<a name="l100"><span class="ln">100 </span></a> <span class="s1">]</span><span class="s3">,</span>
<a name="l101"><span class="ln">101 </span></a> <span class="s1">[</span>
<a name="l102"><span class="ln">102 </span></a> <span class="s2">mesh</span><span class="s1">.</span><span class="s2">normals</span><span class="s1">[</span><span class="s4">3 </span><span class="s1">* </span><span class="s2">v</span><span class="s1">]</span><span class="s3">,</span>
<a name="l103"><span class="ln">103 </span></a> <span class="s2">mesh</span><span class="s1">.</span><span class="s2">normals</span><span class="s1">[</span><span class="s4">3 </span><span class="s1">* </span><span class="s2">v </span><span class="s1">+ </span><span class="s4">1</span><span class="s1">]</span><span class="s3">,</span>
<a name="l104"><span class="ln">104 </span></a> <span class="s2">mesh</span><span class="s1">.</span><span class="s2">normals</span><span class="s1">[</span><span class="s4">3 </span><span class="s1">* </span><span class="s2">v </span><span class="s1">+ </span><span class="s4">2</span><span class="s1">]</span><span class="s3">,</span>
<a name="l105"><span class="ln">105 </span></a> <span class="s1">]</span><span class="s3">,</span>
<a name="l106"><span class="ln">106 </span></a> <span class="s2">texcoords</span><span class="s3">,</span>
<a name="l107"><span class="ln">107 </span></a> <span class="s1">))</span><span class="s3">;</span>
<a name="l108"><span class="ln">108 </span></a> <span class="s1">}</span>
<a name="l109"><span class="ln">109 </span></a> <span class="s1">}</span>
<a name="l110"><span class="ln">110 </span></a> <span class="s2">Ok</span><span class="s1">(</span><span class="s2">RawMesh </span><span class="s1">{</span>
<a name="l111"><span class="ln">111 </span></a> <span class="s2">vertices</span><span class="s1">: </span><span class="s2">vertex_data</span><span class="s1">.</span><span class="s2">to_vec</span><span class="s1">()</span><span class="s3">,</span>
<a name="l112"><span class="ln">112 </span></a> <span class="s2">indices</span><span class="s1">: </span><span class="s2">index_data</span><span class="s1">.</span><span class="s2">to_vec</span><span class="s1">()</span><span class="s3">,</span>
<a name="l113"><span class="ln">113 </span></a> <span class="s1">})</span>
<a name="l114"><span class="ln">114 </span></a><span class="s1">}</span>
<a name="l115"><span class="ln">115 </span></a>
<a name="l116"><span class="ln">116 </span></a><span class="s7">// pub fn create_quad_mesh() -&gt; RawMesh {</span>
<a name="l117"><span class="ln">117 </span></a><span class="s7">//</span>
<a name="l118"><span class="ln">118 </span></a><span class="s7">// let mut index_data: Vec&lt;[u32; 3]&gt; = Vec::new();</span>
<a name="l119"><span class="ln">119 </span></a><span class="s7">// let mut vertex_data = Vec::new();</span>
<a name="l120"><span class="ln">120 </span></a><span class="s7">//</span>
<a name="l121"><span class="ln">121 </span></a><span class="s7">// vertex_data.push(Vertex::from(</span>
<a name="l122"><span class="ln">122 </span></a><span class="s7">// [</span>
<a name="l123"><span class="ln">123 </span></a><span class="s7">// mesh.positions[3 * v],</span>
<a name="l124"><span class="ln">124 </span></a><span class="s7">// mesh.positions[3 * v + 1],</span>
<a name="l125"><span class="ln">125 </span></a><span class="s7">// mesh.positions[3 * v + 2],</span>
<a name="l126"><span class="ln">126 </span></a><span class="s7">// ],</span>
<a name="l127"><span class="ln">127 </span></a><span class="s7">// [</span>
<a name="l128"><span class="ln">128 </span></a><span class="s7">// mesh.normals[3 * v],</span>
<a name="l129"><span class="ln">129 </span></a><span class="s7">// mesh.normals[3 * v + 1],</span>
<a name="l130"><span class="ln">130 </span></a><span class="s7">// mesh.normals[3 * v + 2],</span>
<a name="l131"><span class="ln">131 </span></a><span class="s7">// ],</span>
<a name="l132"><span class="ln">132 </span></a><span class="s7">// [mesh.texcoords[2 * v], mesh.texcoords[2 * v + 1]],</span>
<a name="l133"><span class="ln">133 </span></a><span class="s7">// ));</span>
<a name="l134"><span class="ln">134 </span></a><span class="s7">//</span>
<a name="l135"><span class="ln">135 </span></a><span class="s7">// RawMesh {</span>
<a name="l136"><span class="ln">136 </span></a><span class="s7">// vertices: vertex_data.to_vec(),</span>
<a name="l137"><span class="ln">137 </span></a><span class="s7">// indices: index_data.to_vec(),</span>
<a name="l138"><span class="ln">138 </span></a><span class="s7">// }</span>
<a name="l139"><span class="ln">139 </span></a><span class="s7">// }</span>
<a name="l140"><span class="ln">140 </span></a></pre>
</body>
</html>

@ -0,0 +1,32 @@
<html>
<head>
<title>imgui_support.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;}
.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">
imgui_support.rs</font>
</center></td></tr></table>
<pre><a name="l1"><span class="ln">1 </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="s1">::</span><span class="s2">WinitPlatform</span><span class="s3">;</span>
<a name="l2"><span class="ln">2 </span></a>
<a name="l3"><span class="ln">3 </span></a>
<a name="l4"><span class="ln">4 </span></a><span class="s0">pub struct </span><span class="s2">ImguiContext </span><span class="s1">{</span>
<a name="l5"><span class="ln">5 </span></a> <span class="s0">pub </span><span class="s2">context</span><span class="s1">: </span><span class="s2">imgui</span><span class="s1">::</span><span class="s2">Context</span><span class="s3">,</span>
<a name="l6"><span class="ln">6 </span></a><span class="s1">}</span>
<a name="l7"><span class="ln">7 </span></a><span class="s0">unsafe impl </span><span class="s2">Send </span><span class="s0">for </span><span class="s2">ImguiContext </span><span class="s1">{}</span>
<a name="l8"><span class="ln">8 </span></a>
<a name="l9"><span class="ln">9 </span></a><span class="s0">pub struct </span><span class="s2">ImguiPlatform </span><span class="s1">{</span>
<a name="l10"><span class="ln">10 </span></a> <span class="s0">pub </span><span class="s2">platform</span><span class="s1">: </span><span class="s2">WinitPlatform</span><span class="s3">,</span>
<a name="l11"><span class="ln">11 </span></a><span class="s1">}</span>
<a name="l12"><span class="ln">12 </span></a><span class="s0">unsafe impl </span><span class="s2">Send </span><span class="s0">for </span><span class="s2">ImguiPlatform </span><span class="s1">{}</span></pre>
</body>
</html>

@ -0,0 +1 @@
<html><head><title>~/source/3d-min-viable-eng/src/imgui_supp</title></head><body><a href="mod.rs.html">mod.rs</a><br /><a href="imgui_support.rs.html">imgui_support.rs</a><br /><a href="extended_winit_imgui_support.rs.html">extended_winit_imgui_support.rs</a><br /></body></html>

@ -0,0 +1,79 @@
<html>
<head>
<title>light.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: #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">
light.rs</font>
</center></td></tr></table>
<pre><a name="l1"><span class="ln">1 </span></a><span class="s0">use </span><span class="s2">bytemuck</span><span class="s1">::</span><span class="s2">__core</span><span class="s1">::</span><span class="s2">ops</span><span class="s1">::</span><span class="s2">Range</span><span class="s3">;</span>
<a name="l2"><span class="ln">2 </span></a><span class="s0">use </span><span class="s2">bytemuck</span><span class="s1">::{</span><span class="s2">Zeroable</span><span class="s3">, </span><span class="s2">Pod</span><span class="s1">}</span><span class="s3">;</span>
<a name="l3"><span class="ln">3 </span></a><span class="s0">use </span><span class="s2">cgmath</span><span class="s1">::</span><span class="s2">Point3</span><span class="s3">;</span>
<a name="l4"><span class="ln">4 </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>
<a name="l5"><span class="ln">5 </span></a><span class="s0">use </span><span class="s2">wgpu</span><span class="s1">::</span><span class="s2">TextureView</span><span class="s3">;</span>
<a name="l6"><span class="ln">6 </span></a><span class="s0">use crate</span><span class="s1">::</span><span class="s2">components</span><span class="s1">::{</span><span class="s2">RangeCopy</span><span class="s3">, </span><span class="s2">Position</span><span class="s1">}</span><span class="s3">;</span>
<a name="l7"><span class="ln">7 </span></a><span class="s0">use crate</span><span class="s1">::</span><span class="s2">render</span><span class="s1">::</span><span class="s2">OPENGL_TO_WGPU_MATRIX</span><span class="s3">;</span>
<a name="l8"><span class="ln">8 </span></a>
<a name="l9"><span class="ln">9 </span></a>
<a name="l10"><span class="ln">10 </span></a><span class="s1">#[</span><span class="s2">repr</span><span class="s1">(</span><span class="s2">C</span><span class="s1">)]</span>
<a name="l11"><span class="ln">11 </span></a><span class="s1">#[</span><span class="s2">derive</span><span class="s1">(</span><span class="s2">Clone</span><span class="s3">, </span><span class="s2">Copy</span><span class="s1">)]</span>
<a name="l12"><span class="ln">12 </span></a><span class="s0">pub struct </span><span class="s2">LightRaw </span><span class="s1">{</span>
<a name="l13"><span class="ln">13 </span></a> <span class="s2">proj</span><span class="s1">: [[</span><span class="s2">f32</span><span class="s3">; </span><span class="s4">4</span><span class="s1">]</span><span class="s3">; </span><span class="s4">4</span><span class="s1">]</span><span class="s3">,</span>
<a name="l14"><span class="ln">14 </span></a> <span class="s2">pos</span><span class="s1">: [</span><span class="s2">f32</span><span class="s3">; </span><span class="s4">4</span><span class="s1">]</span><span class="s3">,</span>
<a name="l15"><span class="ln">15 </span></a> <span class="s2">color</span><span class="s1">: [</span><span class="s2">f32</span><span class="s3">; </span><span class="s4">4</span><span class="s1">]</span><span class="s3">,</span>
<a name="l16"><span class="ln">16 </span></a><span class="s1">}</span>
<a name="l17"><span class="ln">17 </span></a>
<a name="l18"><span class="ln">18 </span></a><span class="s0">unsafe impl </span><span class="s2">Pod </span><span class="s0">for </span><span class="s2">LightRaw </span><span class="s1">{}</span>
<a name="l19"><span class="ln">19 </span></a>
<a name="l20"><span class="ln">20 </span></a><span class="s0">unsafe impl </span><span class="s2">Zeroable </span><span class="s0">for </span><span class="s2">LightRaw </span><span class="s1">{}</span>
<a name="l21"><span class="ln">21 </span></a>
<a name="l22"><span class="ln">22 </span></a><span class="s1">#[</span><span class="s2">derive</span><span class="s1">(</span><span class="s2">Clone</span><span class="s3">, </span><span class="s2">Debug</span><span class="s1">)]</span>
<a name="l23"><span class="ln">23 </span></a><span class="s0">pub struct </span><span class="s2">DirectionalLight </span><span class="s1">{</span>
<a name="l24"><span class="ln">24 </span></a> <span class="s0">pub </span><span class="s2">color</span><span class="s1">: </span><span class="s2">wgpu</span><span class="s1">::</span><span class="s2">Color</span><span class="s3">,</span>
<a name="l25"><span class="ln">25 </span></a> <span class="s0">pub </span><span class="s2">fov</span><span class="s1">: </span><span class="s2">f32</span><span class="s3">,</span>
<a name="l26"><span class="ln">26 </span></a> <span class="s0">pub </span><span class="s2">depth</span><span class="s1">: </span><span class="s2">RangeCopy</span><span class="s1">&lt;</span><span class="s2">f32</span><span class="s1">&gt;</span><span class="s3">,</span>
<a name="l27"><span class="ln">27 </span></a> <span class="s0">pub </span><span class="s2">target_view</span><span class="s1">: </span><span class="s2">Arc</span><span class="s1">&lt;</span><span class="s2">TextureView</span><span class="s1">&gt;</span><span class="s3">,</span>
<a name="l28"><span class="ln">28 </span></a><span class="s1">}</span>
<a name="l29"><span class="ln">29 </span></a>
<a name="l30"><span class="ln">30 </span></a><span class="s0">impl </span><span class="s2">DirectionalLight </span><span class="s1">{</span>
<a name="l31"><span class="ln">31 </span></a> <span class="s0">pub fn </span><span class="s2">to_raw</span><span class="s1">(&amp;</span><span class="s0">self</span><span class="s3">, </span><span class="s2">pos</span><span class="s1">: &amp;</span><span class="s2">Position</span><span class="s1">) -&gt; </span><span class="s2">LightRaw </span><span class="s1">{</span>
<a name="l32"><span class="ln">32 </span></a> <span class="s0">use </span><span class="s2">cgmath</span><span class="s1">::{</span><span class="s2">Deg</span><span class="s3">, </span><span class="s2">EuclideanSpace</span><span class="s3">, </span><span class="s2">Matrix4</span><span class="s3">, </span><span class="s2">PerspectiveFov</span><span class="s3">, </span><span class="s2">Point3</span><span class="s3">, </span><span class="s2">Vector3</span><span class="s1">}</span><span class="s3">;</span>
<a name="l33"><span class="ln">33 </span></a>
<a name="l34"><span class="ln">34 </span></a> <span class="s0">let </span><span class="s2">point3d </span><span class="s1">= </span><span class="s2">Point3</span><span class="s1">::</span><span class="s2">new</span><span class="s1">(</span><span class="s2">pos</span><span class="s1">.</span><span class="s2">x</span><span class="s3">, </span><span class="s2">pos</span><span class="s1">.</span><span class="s2">y</span><span class="s3">, </span><span class="s2">pos</span><span class="s1">.</span><span class="s2">z</span><span class="s1">)</span><span class="s3">;</span>
<a name="l35"><span class="ln">35 </span></a> <span class="s0">let </span><span class="s2">point3d_2 </span><span class="s1">= </span><span class="s2">Point3</span><span class="s1">::</span><span class="s2">new</span><span class="s1">(</span><span class="s2">pos</span><span class="s1">.</span><span class="s2">x</span><span class="s3">, </span><span class="s2">pos</span><span class="s1">.</span><span class="s2">y </span><span class="s1">- </span><span class="s4">1</span><span class="s1">.</span><span class="s4">0</span><span class="s3">, </span><span class="s2">pos</span><span class="s1">.</span><span class="s2">z</span><span class="s1">)</span><span class="s3">;</span>
<a name="l36"><span class="ln">36 </span></a> <span class="s0">let </span><span class="s2">mx_view </span><span class="s1">= </span><span class="s2">Matrix4</span><span class="s1">::</span><span class="s2">look_at</span><span class="s1">(</span><span class="s2">point3d</span><span class="s3">, </span><span class="s2">point3d_2</span><span class="s3">, </span><span class="s2">Vector3</span><span class="s1">::</span><span class="s2">unit_z</span><span class="s1">())</span><span class="s3">;</span>
<a name="l37"><span class="ln">37 </span></a>
<a name="l38"><span class="ln">38 </span></a> <span class="s0">let </span><span class="s2">projection </span><span class="s1">= </span><span class="s2">PerspectiveFov </span><span class="s1">{</span>
<a name="l39"><span class="ln">39 </span></a> <span class="s2">fovy</span><span class="s1">: </span><span class="s2">Deg</span><span class="s1">(</span><span class="s0">self</span><span class="s1">.</span><span class="s2">fov</span><span class="s1">).</span><span class="s2">into</span><span class="s1">()</span><span class="s3">,</span>
<a name="l40"><span class="ln">40 </span></a> <span class="s2">aspect</span><span class="s1">: </span><span class="s4">1</span><span class="s1">.</span><span class="s4">0</span><span class="s3">,</span>
<a name="l41"><span class="ln">41 </span></a> <span class="s2">near</span><span class="s1">: </span><span class="s0">self</span><span class="s1">.</span><span class="s2">depth</span><span class="s1">.</span><span class="s2">start</span><span class="s3">,</span>
<a name="l42"><span class="ln">42 </span></a> <span class="s2">far</span><span class="s1">: </span><span class="s0">self</span><span class="s1">.</span><span class="s2">depth</span><span class="s1">.</span><span class="s2">end</span><span class="s3">,</span>
<a name="l43"><span class="ln">43 </span></a> <span class="s1">}</span><span class="s3">;</span>
<a name="l44"><span class="ln">44 </span></a> <span class="s0">let </span><span class="s2">mx_correction </span><span class="s1">= </span><span class="s2">OPENGL_TO_WGPU_MATRIX</span><span class="s3">;</span>
<a name="l45"><span class="ln">45 </span></a> <span class="s0">let </span><span class="s2">mx_view_proj </span><span class="s1">=</span>
<a name="l46"><span class="ln">46 </span></a> <span class="s2">mx_correction </span><span class="s1">* </span><span class="s2">cgmath</span><span class="s1">::</span><span class="s2">Matrix4</span><span class="s1">::</span><span class="s2">from</span><span class="s1">(</span><span class="s2">projection</span><span class="s1">.</span><span class="s2">to_perspective</span><span class="s1">()) * </span><span class="s2">mx_view</span><span class="s3">;</span>
<a name="l47"><span class="ln">47 </span></a> <span class="s2">LightRaw </span><span class="s1">{</span>
<a name="l48"><span class="ln">48 </span></a> <span class="s2">proj</span><span class="s1">: *</span><span class="s2">mx_view_proj</span><span class="s1">.</span><span class="s2">as_ref</span><span class="s1">()</span><span class="s3">,</span>
<a name="l49"><span class="ln">49 </span></a> <span class="s2">pos</span><span class="s1">: [</span><span class="s2">pos</span><span class="s1">.</span><span class="s2">x</span><span class="s3">, </span><span class="s2">pos</span><span class="s1">.</span><span class="s2">y</span><span class="s3">, </span><span class="s2">pos</span><span class="s1">.</span><span class="s2">z</span><span class="s3">, </span><span class="s4">1</span><span class="s1">.</span><span class="s4">0</span><span class="s1">]</span><span class="s3">,</span>
<a name="l50"><span class="ln">50 </span></a> <span class="s2">color</span><span class="s1">: [</span>
<a name="l51"><span class="ln">51 </span></a> <span class="s0">self</span><span class="s1">.</span><span class="s2">color</span><span class="s1">.</span><span class="s2">r </span><span class="s0">as </span><span class="s2">f32</span><span class="s3">,</span>
<a name="l52"><span class="ln">52 </span></a> <span class="s0">self</span><span class="s1">.</span><span class="s2">color</span><span class="s1">.</span><span class="s2">g </span><span class="s0">as </span><span class="s2">f32</span><span class="s3">,</span>
<a name="l53"><span class="ln">53 </span></a> <span class="s0">self</span><span class="s1">.</span><span class="s2">color</span><span class="s1">.</span><span class="s2">b </span><span class="s0">as </span><span class="s2">f32</span><span class="s3">,</span>
<a name="l54"><span class="ln">54 </span></a> <span class="s4">1</span><span class="s1">.</span><span class="s4">0</span><span class="s3">,</span>
<a name="l55"><span class="ln">55 </span></a> <span class="s1">]</span><span class="s3">,</span>
<a name="l56"><span class="ln">56 </span></a> <span class="s1">}</span>
<a name="l57"><span class="ln">57 </span></a> <span class="s1">}</span>
<a name="l58"><span class="ln">58 </span></a><span class="s1">}</span></pre>
</body>
</html>

@ -0,0 +1,409 @@
<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">&quot;wasm32&quot;</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 &amp; 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 &amp; 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!(&quot;&quot;);</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">&lt;</span><span class="s2">imgui</span><span class="s1">::</span><span class="s2">Ui</span><span class="s1">&lt;</span><span class="s6">'static</span><span class="s1">&gt;&gt; = </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">&lt;</span><span class="s6">'a</span><span class="s1">&gt;() -&gt; </span><span class="s2">Option</span><span class="s1">&lt;&amp;</span><span class="s6">'a </span><span class="s2">imgui</span><span class="s1">::</span><span class="s2">Ui</span><span class="s1">&lt;</span><span class="s6">'a</span><span class="s1">&gt;&gt; {</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">&quot;minimal_viable_game_engine&quot;</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">::&lt;</span><span class="s2">OwnedEventExtension</span><span class="s1">&gt;::</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">&quot;MVGE&quot;</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">(&amp;</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">(&amp;</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">&amp;</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">(&amp;[</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">(&amp;</span><span class="s2">window</span><span class="s3">, </span><span class="s1">&amp;</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">::&lt;</span><span class="s2">OwnedEvent</span><span class="s1">&lt;</span><span class="s2">OwnedEventExtension</span><span class="s1">&gt;&gt;::</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">(&amp;</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">::&lt;</span><span class="s2">LoopState</span><span class="s1">&gt;().</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">) =&gt; {</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">(&amp;</span><span class="s0">mut </span><span class="s2">world</span><span class="s3">, </span><span class="s1">&amp;</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">=&gt; {</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">(&amp;</span><span class="s0">mut </span><span class="s2">world</span><span class="s3">, </span><span class="s1">&amp;</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">::&lt;</span><span class="s2">Vec</span><span class="s1">&lt;</span><span class="s2">OwnedEvent</span><span class="s1">&lt;</span><span class="s2">OwnedEventExtension</span><span class="s1">&gt;&gt;&gt;()</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">(&amp;</span><span class="s0">mut </span><span class="s2">world</span><span class="s3">, </span><span class="s1">&amp;</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">::&lt;</span><span class="s2">LoopState</span><span class="s1">&gt;().</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">::&lt;</span><span class="s2">LoopState</span><span class="s1">&gt;().</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">&gt; </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">&gt;= </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">(&amp;</span><span class="s0">mut </span><span class="s2">world</span><span class="s3">, </span><span class="s1">&amp;</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">(&amp;</span><span class="s0">mut </span><span class="s2">world</span><span class="s3">, </span><span class="s1">&amp;</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">} =&gt; {</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">::&lt;</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">&gt;()</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">} =&gt; {</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">=&gt; {</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">=&gt; ()</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">} =&gt; *</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">) =&gt; {</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(&amp;mut world, &amp;mut resources);</span>
<a name="l331"><span class="ln">331 </span></a> <span class="s5">// render_schedule.execute(&amp;mut world, &amp;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">=&gt; {}</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">::&lt;</span><span class="s2">Vec</span><span class="s1">&lt;</span><span class="s2">OwnedEvent</span><span class="s1">&lt;</span><span class="s2">OwnedEventExtension</span><span class="s1">&gt;&gt;&gt;()</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">: &amp;</span><span class="s2">EventLoop</span><span class="s1">&lt;</span><span class="s2">OwnedEventExtension</span><span class="s1">&gt;) {</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">&lt;</span><span class="s2">Gamepad</span><span class="s1">&gt; = </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">&quot;PS4&quot; </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">// &quot;{} is {:?} {:?}&quot;,</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!(&quot;{:?} New event from {}: {:?}&quot;, 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!(&quot;Button South is pressed (XBox - A, PS - X)&quot;);</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>

@ -0,0 +1,22 @@
<html>
<head>
<title>mod.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;}
.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">
mod.rs</font>
</center></td></tr></table>
<pre><a name="l1"><span class="ln">1 </span></a><span class="s0">pub mod </span><span class="s2">extended_winit_imgui_support</span><span class="s3">;</span>
<a name="l2"><span class="ln">2 </span></a><span class="s0">pub mod </span><span class="s2">imgui_support</span><span class="s3">;</span></pre>
</body>
</html>

@ -0,0 +1,330 @@
<html>
<head>
<title>owned_event.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: #499936; font-style: italic;}
.s5 { color: #20999d; font-style: italic;}
.s6 { color: #54b33e;}
.s7 { color: #33ccff; font-weight: bold;}
.s8 { color: #7ec3e6;}
.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">
owned_event.rs</font>
</center></td></tr></table>
<pre><a name="l1"><span class="ln">1 </span></a><span class="s0">use </span><span class="s2">std</span><span class="s1">::</span><span class="s2">path</span><span class="s1">::</span><span class="s2">PathBuf</span><span class="s3">;</span>
<a name="l2"><span class="ln">2 </span></a>
<a name="l3"><span class="ln">3 </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="l4"><span class="ln">4 </span></a><span class="s0">use </span><span class="s2">legion</span><span class="s1">::</span><span class="s2">world</span><span class="s1">::</span><span class="s2">SubWorld</span><span class="s3">;</span>
<a name="l5"><span class="ln">5 </span></a><span class="s0">use </span><span class="s2">legion</span><span class="s1">::*</span><span class="s3">;</span>
<a name="l6"><span class="ln">6 </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">PhysicalPosition</span><span class="s3">, </span><span class="s2">PhysicalSize</span><span class="s3">, </span><span class="s2">LogicalPosition</span><span class="s1">}</span><span class="s3">;</span>
<a name="l7"><span class="ln">7 </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="l8"><span class="ln">8 </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">AxisId</span><span class="s3">, </span><span class="s2">DeviceEvent</span><span class="s3">, </span><span class="s2">DeviceId</span><span class="s3">, </span><span class="s2">ElementState</span><span class="s3">, </span><span class="s2">Event</span><span class="s3">, </span><span class="s2">KeyboardInput</span><span class="s3">, </span><span class="s2">ModifiersState</span><span class="s3">, </span><span class="s2">MouseButton</span><span class="s3">, </span><span class="s2">MouseScrollDelta</span><span class="s3">, </span><span class="s2">StartCause</span><span class="s3">, </span><span class="s2">Touch</span><span class="s3">, </span><span class="s2">TouchPhase</span><span class="s3">, </span><span class="s2">WindowEvent</span><span class="s3">, </span><span class="s2">VirtualKeyCode</span><span class="s1">}</span><span class="s3">;</span>
<a name="l9"><span class="ln">9 </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">Theme</span><span class="s3">, </span><span class="s2">WindowId</span><span class="s3">, </span><span class="s2">Window</span><span class="s1">}</span><span class="s3">;</span>
<a name="l10"><span class="ln">10 </span></a>
<a name="l11"><span class="ln">11 </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="l12"><span class="ln">12 </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">OwnedWindowEvent</span><span class="s1">::</span><span class="s2">MouseWheel</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">sync</span><span class="s1">::{</span><span class="s2">Mutex</span><span class="s3">, </span><span class="s2">Arc</span><span class="s1">}</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">cmp</span><span class="s1">::</span><span class="s2">Ordering</span><span class="s3">;</span>
<a name="l15"><span class="ln">15 </span></a><span class="s0">use </span><span class="s2">imgui</span><span class="s1">::</span><span class="s2">Io</span><span class="s3">;</span>
<a name="l16"><span class="ln">16 </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="l17"><span class="ln">17 </span></a>
<a name="l18"><span class="ln">18 </span></a><span class="s1">#[</span><span class="s2">derive</span><span class="s1">(</span><span class="s2">Clone</span><span class="s1">)]</span>
<a name="l19"><span class="ln">19 </span></a><span class="s0">pub enum </span><span class="s2">OwnedUIEvent</span><span class="s1">&lt;</span><span class="s2">T</span><span class="s1">&gt; {</span>
<a name="l20"><span class="ln">20 </span></a> <span class="s2">UIEvent</span><span class="s1">(</span><span class="s2">T</span><span class="s1">)</span><span class="s3">,</span>
<a name="l21"><span class="ln">21 </span></a><span class="s1">}</span>
<a name="l22"><span class="ln">22 </span></a>
<a name="l23"><span class="ln">23 </span></a><span class="s1">#[</span><span class="s2">derive</span><span class="s1">(</span><span class="s2">Clone</span><span class="s1">)]</span>
<a name="l24"><span class="ln">24 </span></a><span class="s0">pub enum </span><span class="s2">OwnedEventExtension </span><span class="s1">{</span>
<a name="l25"><span class="ln">25 </span></a> <span class="s4">/// Custom events here</span>
<a name="l26"><span class="ln">26 </span></a> <span class="s2">MouseHeldEvent </span><span class="s1">{}</span><span class="s3">,</span>
<a name="l27"><span class="ln">27 </span></a> <span class="s2">KeyHeldEvent </span><span class="s1">{}</span><span class="s3">,</span>
<a name="l28"><span class="ln">28 </span></a> <span class="s2">GamepadEvent </span><span class="s1">{</span>
<a name="l29"><span class="ln">29 </span></a> <span class="s2">gil_event</span><span class="s1">: </span><span class="s2">GilEvent</span><span class="s3">,</span>
<a name="l30"><span class="ln">30 </span></a> <span class="s1">}</span><span class="s3">,</span>
<a name="l31"><span class="ln">31 </span></a><span class="s1">}</span>
<a name="l32"><span class="ln">32 </span></a>
<a name="l33"><span class="ln">33 </span></a><span class="s1">#[</span><span class="s2">derive</span><span class="s1">(</span><span class="s2">Clone</span><span class="s3">, </span><span class="s2">Debug</span><span class="s1">)]</span>
<a name="l34"><span class="ln">34 </span></a><span class="s0">pub enum </span><span class="s2">OwnedEvent</span><span class="s1">&lt;</span><span class="s2">T</span><span class="s1">&gt; {</span>
<a name="l35"><span class="ln">35 </span></a> <span class="s4">/// Custom events here</span>
<a name="l36"><span class="ln">36 </span></a> <span class="s2">MouseHeldEvent </span><span class="s1">{}</span><span class="s3">,</span>
<a name="l37"><span class="ln">37 </span></a> <span class="s2">KeyHeldEvent </span><span class="s1">{}</span><span class="s3">,</span>
<a name="l38"><span class="ln">38 </span></a> <span class="s2">GamepadEvent </span><span class="s1">{</span>
<a name="l39"><span class="ln">39 </span></a> <span class="s2">gil_event</span><span class="s1">: </span><span class="s2">GilEvent</span><span class="s3">,</span>
<a name="l40"><span class="ln">40 </span></a> <span class="s1">}</span><span class="s3">,</span>
<a name="l41"><span class="ln">41 </span></a>
<a name="l42"><span class="ln">42 </span></a> <span class="s4">/// Winit events here</span>
<a name="l43"><span class="ln">43 </span></a> <span class="s2">NewEvents</span><span class="s1">(</span><span class="s2">StartCause</span><span class="s1">)</span><span class="s3">,</span>
<a name="l44"><span class="ln">44 </span></a> <span class="s2">WindowEvent </span><span class="s1">{</span>
<a name="l45"><span class="ln">45 </span></a> <span class="s2">window_id</span><span class="s1">: </span><span class="s2">WindowId</span><span class="s3">,</span>
<a name="l46"><span class="ln">46 </span></a> <span class="s2">event</span><span class="s1">: </span><span class="s2">OwnedWindowEvent</span><span class="s3">,</span>
<a name="l47"><span class="ln">47 </span></a> <span class="s1">}</span><span class="s3">,</span>
<a name="l48"><span class="ln">48 </span></a> <span class="s2">DeviceEvent </span><span class="s1">{</span>
<a name="l49"><span class="ln">49 </span></a> <span class="s2">device_id</span><span class="s1">: </span><span class="s2">DeviceId</span><span class="s3">,</span>
<a name="l50"><span class="ln">50 </span></a> <span class="s2">event</span><span class="s1">: </span><span class="s2">DeviceEvent</span><span class="s3">,</span>
<a name="l51"><span class="ln">51 </span></a> <span class="s1">}</span><span class="s3">,</span>
<a name="l52"><span class="ln">52 </span></a> <span class="s2">UserEvent</span><span class="s1">(</span><span class="s2">T</span><span class="s1">)</span><span class="s3">,</span>
<a name="l53"><span class="ln">53 </span></a> <span class="s2">Suspended</span><span class="s3">,</span>
<a name="l54"><span class="ln">54 </span></a> <span class="s2">Resumed</span><span class="s3">,</span>
<a name="l55"><span class="ln">55 </span></a> <span class="s2">MainEventsCleared</span><span class="s3">,</span>
<a name="l56"><span class="ln">56 </span></a> <span class="s2">RedrawRequested</span><span class="s1">(</span><span class="s2">WindowId</span><span class="s1">)</span><span class="s3">,</span>
<a name="l57"><span class="ln">57 </span></a> <span class="s2">RedrawEventsCleared</span><span class="s3">,</span>
<a name="l58"><span class="ln">58 </span></a> <span class="s2">LoopDestroyed</span><span class="s3">,</span>
<a name="l59"><span class="ln">59 </span></a><span class="s1">}</span>
<a name="l60"><span class="ln">60 </span></a>
<a name="l61"><span class="ln">61 </span></a><span class="s0">impl</span><span class="s1">&lt;</span><span class="s2">T</span><span class="s1">&gt; </span><span class="s2">From</span><span class="s1">&lt;</span><span class="s2">Event</span><span class="s1">&lt;</span><span class="s5">'_</span><span class="s3">, </span><span class="s2">T</span><span class="s1">&gt;&gt; </span><span class="s0">for </span><span class="s2">OwnedEvent</span><span class="s1">&lt;</span><span class="s2">T</span><span class="s1">&gt; {</span>
<a name="l62"><span class="ln">62 </span></a> <span class="s0">fn </span><span class="s2">from</span><span class="s1">(</span><span class="s2">event</span><span class="s1">: </span><span class="s2">Event</span><span class="s1">&lt;</span><span class="s2">T</span><span class="s1">&gt;) -&gt; </span><span class="s0">Self </span><span class="s1">{</span>
<a name="l63"><span class="ln">63 </span></a> <span class="s0">match </span><span class="s2">event </span><span class="s1">{</span>
<a name="l64"><span class="ln">64 </span></a> <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">) =&gt; </span><span class="s2">OwnedEvent</span><span class="s1">::</span><span class="s2">NewEvents</span><span class="s1">(</span><span class="s2">cause</span><span class="s1">)</span><span class="s3">,</span>
<a name="l65"><span class="ln">65 </span></a> <span class="s2">Event</span><span class="s1">::</span><span class="s2">WindowEvent </span><span class="s1">{</span>
<a name="l66"><span class="ln">66 </span></a> <span class="s2">window_id</span><span class="s1">: </span><span class="s2">window_id</span><span class="s3">,</span>
<a name="l67"><span class="ln">67 </span></a> <span class="s2">event</span><span class="s1">: </span><span class="s2">event</span><span class="s3">,</span>
<a name="l68"><span class="ln">68 </span></a> <span class="s1">} =&gt; </span><span class="s2">OwnedEvent</span><span class="s1">::</span><span class="s2">WindowEvent </span><span class="s1">{</span>
<a name="l69"><span class="ln">69 </span></a> <span class="s2">window_id</span><span class="s1">: </span><span class="s2">window_id</span><span class="s3">,</span>
<a name="l70"><span class="ln">70 </span></a> <span class="s2">event</span><span class="s1">: </span><span class="s0">match </span><span class="s2">event </span><span class="s1">{</span>
<a name="l71"><span class="ln">71 </span></a> <span class="s2">WindowEvent</span><span class="s1">::</span><span class="s2">AxisMotion </span><span class="s1">{</span>
<a name="l72"><span class="ln">72 </span></a> <span class="s2">device_id</span><span class="s3">,</span>
<a name="l73"><span class="ln">73 </span></a> <span class="s2">axis</span><span class="s3">,</span>
<a name="l74"><span class="ln">74 </span></a> <span class="s2">value</span><span class="s3">,</span>
<a name="l75"><span class="ln">75 </span></a> <span class="s1">} =&gt; </span><span class="s2">OwnedWindowEvent</span><span class="s1">::</span><span class="s2">AxisMotion </span><span class="s1">{</span>
<a name="l76"><span class="ln">76 </span></a> <span class="s2">device_id</span><span class="s3">,</span>
<a name="l77"><span class="ln">77 </span></a> <span class="s2">axis</span><span class="s3">,</span>
<a name="l78"><span class="ln">78 </span></a> <span class="s2">value</span><span class="s3">,</span>
<a name="l79"><span class="ln">79 </span></a> <span class="s1">}</span><span class="s3">,</span>
<a name="l80"><span class="ln">80 </span></a> <span class="s2">WindowEvent</span><span class="s1">::</span><span class="s2">Resized</span><span class="s1">(</span><span class="s2">physical_size</span><span class="s1">) =&gt; </span><span class="s2">OwnedWindowEvent</span><span class="s1">::</span><span class="s2">Resized</span><span class="s1">(</span><span class="s2">physical_size</span><span class="s1">)</span><span class="s3">,</span>
<a name="l81"><span class="ln">81 </span></a> <span class="s2">WindowEvent</span><span class="s1">::</span><span class="s2">Moved</span><span class="s1">(</span><span class="s2">physical_position</span><span class="s1">) =&gt; {</span>
<a name="l82"><span class="ln">82 </span></a> <span class="s2">OwnedWindowEvent</span><span class="s1">::</span><span class="s2">Moved</span><span class="s1">(</span><span class="s2">physical_position</span><span class="s1">)</span>
<a name="l83"><span class="ln">83 </span></a> <span class="s1">}</span>
<a name="l84"><span class="ln">84 </span></a> <span class="s2">WindowEvent</span><span class="s1">::</span><span class="s2">CloseRequested </span><span class="s1">=&gt; </span><span class="s2">OwnedWindowEvent</span><span class="s1">::</span><span class="s2">CloseRequested</span><span class="s3">,</span>
<a name="l85"><span class="ln">85 </span></a> <span class="s2">WindowEvent</span><span class="s1">::</span><span class="s2">Destroyed </span><span class="s1">=&gt; </span><span class="s2">OwnedWindowEvent</span><span class="s1">::</span><span class="s2">Destroyed</span><span class="s3">,</span>
<a name="l86"><span class="ln">86 </span></a> <span class="s2">WindowEvent</span><span class="s1">::</span><span class="s2">DroppedFile</span><span class="s1">(</span><span class="s2">path_buf</span><span class="s1">) =&gt; </span><span class="s2">OwnedWindowEvent</span><span class="s1">::</span><span class="s2">DroppedFile</span><span class="s1">(</span><span class="s2">path_buf</span><span class="s1">)</span><span class="s3">,</span>
<a name="l87"><span class="ln">87 </span></a> <span class="s2">WindowEvent</span><span class="s1">::</span><span class="s2">HoveredFile</span><span class="s1">(</span><span class="s2">path_buf</span><span class="s1">) =&gt; </span><span class="s2">OwnedWindowEvent</span><span class="s1">::</span><span class="s2">HoveredFile</span><span class="s1">(</span><span class="s2">path_buf</span><span class="s1">)</span><span class="s3">,</span>
<a name="l88"><span class="ln">88 </span></a> <span class="s2">WindowEvent</span><span class="s1">::</span><span class="s2">HoveredFileCancelled </span><span class="s1">=&gt; </span><span class="s2">OwnedWindowEvent</span><span class="s1">::</span><span class="s2">HoveredFileCancelled</span><span class="s3">,</span>
<a name="l89"><span class="ln">89 </span></a> <span class="s2">WindowEvent</span><span class="s1">::</span><span class="s2">ReceivedCharacter</span><span class="s1">(</span><span class="s2">char</span><span class="s1">) =&gt; {</span>
<a name="l90"><span class="ln">90 </span></a> <span class="s2">OwnedWindowEvent</span><span class="s1">::</span><span class="s2">ReceivedCharacter</span><span class="s1">(</span><span class="s2">char</span><span class="s1">)</span>
<a name="l91"><span class="ln">91 </span></a> <span class="s1">}</span>
<a name="l92"><span class="ln">92 </span></a> <span class="s2">WindowEvent</span><span class="s1">::</span><span class="s2">Focused</span><span class="s1">(</span><span class="s2">bool</span><span class="s1">) =&gt; </span><span class="s2">OwnedWindowEvent</span><span class="s1">::</span><span class="s2">Focused</span><span class="s1">(</span><span class="s2">bool</span><span class="s1">)</span><span class="s3">,</span>
<a name="l93"><span class="ln">93 </span></a> <span class="s2">WindowEvent</span><span class="s1">::</span><span class="s2">KeyboardInput </span><span class="s1">{</span>
<a name="l94"><span class="ln">94 </span></a> <span class="s2">device_id</span><span class="s1">: </span><span class="s2">device_id</span><span class="s3">,</span>
<a name="l95"><span class="ln">95 </span></a> <span class="s2">input</span><span class="s1">: </span><span class="s2">input</span><span class="s3">,</span>
<a name="l96"><span class="ln">96 </span></a> <span class="s2">is_synthetic</span><span class="s1">: </span><span class="s2">is_synthetic</span><span class="s3">,</span>
<a name="l97"><span class="ln">97 </span></a> <span class="s1">} =&gt; </span><span class="s2">OwnedWindowEvent</span><span class="s1">::</span><span class="s2">KeyboardInput </span><span class="s1">{</span>
<a name="l98"><span class="ln">98 </span></a> <span class="s2">device_id</span><span class="s3">,</span>
<a name="l99"><span class="ln">99 </span></a> <span class="s2">input</span><span class="s3">,</span>
<a name="l100"><span class="ln">100 </span></a> <span class="s2">is_synthetic</span><span class="s3">,</span>
<a name="l101"><span class="ln">101 </span></a> <span class="s1">}</span><span class="s3">,</span>
<a name="l102"><span class="ln">102 </span></a> <span class="s2">WindowEvent</span><span class="s1">::</span><span class="s2">ModifiersChanged</span><span class="s1">(</span><span class="s2">modifiers_state</span><span class="s1">) =&gt; {</span>
<a name="l103"><span class="ln">103 </span></a> <span class="s2">OwnedWindowEvent</span><span class="s1">::</span><span class="s2">ModifiersChanged</span><span class="s1">(</span><span class="s2">modifiers_state</span><span class="s1">)</span>
<a name="l104"><span class="ln">104 </span></a> <span class="s1">}</span>
<a name="l105"><span class="ln">105 </span></a> <span class="s2">WindowEvent</span><span class="s1">::</span><span class="s2">CursorMoved </span><span class="s1">{</span>
<a name="l106"><span class="ln">106 </span></a> <span class="s2">device_id</span><span class="s1">: </span><span class="s2">device_id</span><span class="s3">,</span>
<a name="l107"><span class="ln">107 </span></a> <span class="s2">position</span><span class="s1">: </span><span class="s2">position</span><span class="s3">,</span>
<a name="l108"><span class="ln">108 </span></a> <span class="s2">modifiers</span><span class="s1">: </span><span class="s2">modifiers</span><span class="s3">,</span>
<a name="l109"><span class="ln">109 </span></a> <span class="s1">} =&gt; </span><span class="s2">OwnedWindowEvent</span><span class="s1">::</span><span class="s2">CursorMoved </span><span class="s1">{</span>
<a name="l110"><span class="ln">110 </span></a> <span class="s2">device_id</span><span class="s3">,</span>
<a name="l111"><span class="ln">111 </span></a> <span class="s2">position</span><span class="s3">,</span>
<a name="l112"><span class="ln">112 </span></a> <span class="s2">modifiers</span><span class="s3">,</span>
<a name="l113"><span class="ln">113 </span></a> <span class="s1">}</span><span class="s3">,</span>
<a name="l114"><span class="ln">114 </span></a> <span class="s2">WindowEvent</span><span class="s1">::</span><span class="s2">CursorEntered </span><span class="s1">{</span>
<a name="l115"><span class="ln">115 </span></a> <span class="s2">device_id</span><span class="s1">: </span><span class="s2">device_id</span><span class="s3">,</span>
<a name="l116"><span class="ln">116 </span></a> <span class="s1">} =&gt; </span><span class="s2">OwnedWindowEvent</span><span class="s1">::</span><span class="s2">CursorEntered </span><span class="s1">{ </span><span class="s2">device_id </span><span class="s1">}</span><span class="s3">,</span>
<a name="l117"><span class="ln">117 </span></a> <span class="s2">WindowEvent</span><span class="s1">::</span><span class="s2">CursorLeft </span><span class="s1">{</span>
<a name="l118"><span class="ln">118 </span></a> <span class="s2">device_id</span><span class="s1">: </span><span class="s2">device_id</span><span class="s3">,</span>
<a name="l119"><span class="ln">119 </span></a> <span class="s1">} =&gt; </span><span class="s2">OwnedWindowEvent</span><span class="s1">::</span><span class="s2">CursorLeft </span><span class="s1">{ </span><span class="s2">device_id </span><span class="s1">}</span><span class="s3">,</span>
<a name="l120"><span class="ln">120 </span></a> <span class="s2">WindowEvent</span><span class="s1">::</span><span class="s2">MouseWheel </span><span class="s1">{</span>
<a name="l121"><span class="ln">121 </span></a> <span class="s2">device_id</span><span class="s1">: </span><span class="s2">device_id</span><span class="s3">,</span>
<a name="l122"><span class="ln">122 </span></a> <span class="s2">delta</span><span class="s1">: </span><span class="s2">delta</span><span class="s3">,</span>
<a name="l123"><span class="ln">123 </span></a> <span class="s2">phase</span><span class="s1">: </span><span class="s2">phase</span><span class="s3">,</span>
<a name="l124"><span class="ln">124 </span></a> <span class="s2">modifiers</span><span class="s1">: </span><span class="s2">modifiers</span><span class="s3">,</span>
<a name="l125"><span class="ln">125 </span></a> <span class="s1">} =&gt; </span><span class="s2">OwnedWindowEvent</span><span class="s1">::</span><span class="s2">MouseWheel </span><span class="s1">{</span>
<a name="l126"><span class="ln">126 </span></a> <span class="s2">device_id</span><span class="s3">,</span>
<a name="l127"><span class="ln">127 </span></a> <span class="s2">delta</span><span class="s3">,</span>
<a name="l128"><span class="ln">128 </span></a> <span class="s2">phase</span><span class="s3">,</span>
<a name="l129"><span class="ln">129 </span></a> <span class="s2">modifiers</span><span class="s3">,</span>
<a name="l130"><span class="ln">130 </span></a> <span class="s1">}</span><span class="s3">,</span>
<a name="l131"><span class="ln">131 </span></a> <span class="s2">WindowEvent</span><span class="s1">::</span><span class="s2">MouseInput </span><span class="s1">{</span>
<a name="l132"><span class="ln">132 </span></a> <span class="s2">device_id</span><span class="s1">: </span><span class="s2">device_id</span><span class="s3">,</span>
<a name="l133"><span class="ln">133 </span></a> <span class="s2">state</span><span class="s1">: </span><span class="s2">state</span><span class="s3">,</span>
<a name="l134"><span class="ln">134 </span></a> <span class="s2">button</span><span class="s1">: </span><span class="s2">button</span><span class="s3">,</span>
<a name="l135"><span class="ln">135 </span></a> <span class="s2">modifiers</span><span class="s1">: </span><span class="s2">modifiers</span><span class="s3">,</span>
<a name="l136"><span class="ln">136 </span></a> <span class="s1">} =&gt; </span><span class="s2">OwnedWindowEvent</span><span class="s1">::</span><span class="s2">MouseInput </span><span class="s1">{</span>
<a name="l137"><span class="ln">137 </span></a> <span class="s2">device_id</span><span class="s3">,</span>
<a name="l138"><span class="ln">138 </span></a> <span class="s2">state</span><span class="s3">,</span>
<a name="l139"><span class="ln">139 </span></a> <span class="s2">button</span><span class="s3">,</span>
<a name="l140"><span class="ln">140 </span></a> <span class="s2">modifiers</span><span class="s3">,</span>
<a name="l141"><span class="ln">141 </span></a> <span class="s1">}</span><span class="s3">,</span>
<a name="l142"><span class="ln">142 </span></a> <span class="s2">WindowEvent</span><span class="s1">::</span><span class="s2">TouchpadPressure </span><span class="s1">{</span>
<a name="l143"><span class="ln">143 </span></a> <span class="s2">device_id</span><span class="s1">: </span><span class="s2">device_id</span><span class="s3">,</span>
<a name="l144"><span class="ln">144 </span></a> <span class="s2">pressure</span><span class="s1">: </span><span class="s2">pressure</span><span class="s3">,</span>
<a name="l145"><span class="ln">145 </span></a> <span class="s2">stage</span><span class="s1">: </span><span class="s2">stage</span><span class="s3">,</span>
<a name="l146"><span class="ln">146 </span></a> <span class="s1">} =&gt; </span><span class="s2">OwnedWindowEvent</span><span class="s1">::</span><span class="s2">TouchpadPressure </span><span class="s1">{</span>
<a name="l147"><span class="ln">147 </span></a> <span class="s2">device_id</span><span class="s3">,</span>
<a name="l148"><span class="ln">148 </span></a> <span class="s2">pressure</span><span class="s3">,</span>
<a name="l149"><span class="ln">149 </span></a> <span class="s2">stage</span><span class="s3">,</span>
<a name="l150"><span class="ln">150 </span></a> <span class="s1">}</span><span class="s3">,</span>
<a name="l151"><span class="ln">151 </span></a> <span class="s2">WindowEvent</span><span class="s1">::</span><span class="s2">Touch</span><span class="s1">(</span><span class="s2">touch</span><span class="s1">) =&gt; </span><span class="s2">OwnedWindowEvent</span><span class="s1">::</span><span class="s2">Touch</span><span class="s1">(</span><span class="s2">touch</span><span class="s1">)</span><span class="s3">,</span>
<a name="l152"><span class="ln">152 </span></a> <span class="s2">WindowEvent</span><span class="s1">::</span><span class="s2">ScaleFactorChanged </span><span class="s1">{</span>
<a name="l153"><span class="ln">153 </span></a> <span class="s2">scale_factor</span><span class="s1">: </span><span class="s2">scale_factor</span><span class="s3">,</span>
<a name="l154"><span class="ln">154 </span></a> <span class="s2">new_inner_size</span><span class="s1">: </span><span class="s2">new_inner_size</span><span class="s3">,</span>
<a name="l155"><span class="ln">155 </span></a> <span class="s1">} =&gt; </span><span class="s2">OwnedWindowEvent</span><span class="s1">::</span><span class="s2">ScaleFactorChanged </span><span class="s1">{</span>
<a name="l156"><span class="ln">156 </span></a> <span class="s2">scale_factor</span><span class="s3">,</span>
<a name="l157"><span class="ln">157 </span></a> <span class="s2">new_inner_size</span><span class="s1">: </span><span class="s2">PhysicalSize </span><span class="s1">{</span>
<a name="l158"><span class="ln">158 </span></a> <span class="s2">width</span><span class="s1">: </span><span class="s2">new_inner_size</span><span class="s1">.</span><span class="s2">width</span><span class="s3">,</span>
<a name="l159"><span class="ln">159 </span></a> <span class="s2">height</span><span class="s1">: </span><span class="s2">new_inner_size</span><span class="s1">.</span><span class="s2">height</span><span class="s3">,</span>
<a name="l160"><span class="ln">160 </span></a> <span class="s1">}</span><span class="s3">,</span>
<a name="l161"><span class="ln">161 </span></a> <span class="s1">}</span><span class="s3">,</span>
<a name="l162"><span class="ln">162 </span></a> <span class="s2">WindowEvent</span><span class="s1">::</span><span class="s2">ThemeChanged</span><span class="s1">(</span><span class="s2">theme</span><span class="s1">) =&gt; </span><span class="s2">OwnedWindowEvent</span><span class="s1">::</span><span class="s2">ThemeChanged</span><span class="s1">(</span><span class="s2">theme</span><span class="s1">)</span><span class="s3">,</span>
<a name="l163"><span class="ln">163 </span></a> <span class="s1">}</span><span class="s3">,</span>
<a name="l164"><span class="ln">164 </span></a> <span class="s1">}</span><span class="s3">,</span>
<a name="l165"><span class="ln">165 </span></a> <span class="s2">Event</span><span class="s1">::</span><span class="s2">DeviceEvent </span><span class="s1">{</span>
<a name="l166"><span class="ln">166 </span></a> <span class="s2">device_id</span><span class="s1">: </span><span class="s2">device_id</span><span class="s3">,</span>
<a name="l167"><span class="ln">167 </span></a> <span class="s2">event</span><span class="s1">: </span><span class="s2">event</span><span class="s3">,</span>
<a name="l168"><span class="ln">168 </span></a> <span class="s1">} =&gt; </span><span class="s2">OwnedEvent</span><span class="s1">::</span><span class="s2">DeviceEvent </span><span class="s1">{ </span><span class="s2">device_id</span><span class="s3">, </span><span class="s2">event </span><span class="s1">}</span><span class="s3">,</span>
<a name="l169"><span class="ln">169 </span></a> <span class="s2">Event</span><span class="s1">::</span><span class="s2">UserEvent</span><span class="s1">(</span><span class="s2">user_event</span><span class="s1">) =&gt; </span><span class="s2">OwnedEvent</span><span class="s1">::</span><span class="s2">UserEvent</span><span class="s1">(</span><span class="s2">user_event</span><span class="s1">)</span><span class="s3">,</span>
<a name="l170"><span class="ln">170 </span></a> <span class="s2">Event</span><span class="s1">::</span><span class="s2">Suspended </span><span class="s1">=&gt; </span><span class="s2">OwnedEvent</span><span class="s1">::</span><span class="s2">Suspended</span><span class="s3">,</span>
<a name="l171"><span class="ln">171 </span></a> <span class="s2">Event</span><span class="s1">::</span><span class="s2">Resumed </span><span class="s1">=&gt; </span><span class="s2">OwnedEvent</span><span class="s1">::</span><span class="s2">Resumed</span><span class="s3">,</span>
<a name="l172"><span class="ln">172 </span></a> <span class="s2">Event</span><span class="s1">::</span><span class="s2">MainEventsCleared </span><span class="s1">=&gt; </span><span class="s2">OwnedEvent</span><span class="s1">::</span><span class="s2">MainEventsCleared</span><span class="s3">,</span>
<a name="l173"><span class="ln">173 </span></a> <span class="s2">Event</span><span class="s1">::</span><span class="s2">RedrawRequested</span><span class="s1">(</span><span class="s2">window_id</span><span class="s1">) =&gt; </span><span class="s2">OwnedEvent</span><span class="s1">::</span><span class="s2">RedrawRequested</span><span class="s1">(</span><span class="s2">window_id</span><span class="s1">)</span><span class="s3">,</span>
<a name="l174"><span class="ln">174 </span></a> <span class="s2">Event</span><span class="s1">::</span><span class="s2">RedrawEventsCleared </span><span class="s1">=&gt; </span><span class="s2">OwnedEvent</span><span class="s1">::</span><span class="s2">RedrawEventsCleared</span><span class="s3">,</span>
<a name="l175"><span class="ln">175 </span></a> <span class="s2">Event</span><span class="s1">::</span><span class="s2">LoopDestroyed </span><span class="s1">=&gt; </span><span class="s2">OwnedEvent</span><span class="s1">::</span><span class="s2">LoopDestroyed</span><span class="s3">,</span>
<a name="l176"><span class="ln">176 </span></a> <span class="s1">}</span>
<a name="l177"><span class="ln">177 </span></a> <span class="s1">}</span>
<a name="l178"><span class="ln">178 </span></a><span class="s1">}</span>
<a name="l179"><span class="ln">179 </span></a>
<a name="l180"><span class="ln">180 </span></a><span class="s1">#[</span><span class="s2">derive</span><span class="s1">(</span><span class="s2">Debug</span><span class="s3">, </span><span class="s2">PartialEq</span><span class="s3">, </span><span class="s2">Clone</span><span class="s1">)]</span>
<a name="l181"><span class="ln">181 </span></a><span class="s0">pub enum </span><span class="s2">OwnedWindowEvent </span><span class="s1">{</span>
<a name="l182"><span class="ln">182 </span></a> <span class="s2">Resized</span><span class="s1">(</span><span class="s2">PhysicalSize</span><span class="s1">&lt;</span><span class="s2">u32</span><span class="s1">&gt;)</span><span class="s3">,</span>
<a name="l183"><span class="ln">183 </span></a> <span class="s2">Moved</span><span class="s1">(</span><span class="s2">PhysicalPosition</span><span class="s1">&lt;</span><span class="s2">i32</span><span class="s1">&gt;)</span><span class="s3">,</span>
<a name="l184"><span class="ln">184 </span></a> <span class="s2">CloseRequested</span><span class="s3">,</span>
<a name="l185"><span class="ln">185 </span></a> <span class="s2">Destroyed</span><span class="s3">,</span>
<a name="l186"><span class="ln">186 </span></a> <span class="s2">DroppedFile</span><span class="s1">(</span><span class="s2">PathBuf</span><span class="s1">)</span><span class="s3">,</span>
<a name="l187"><span class="ln">187 </span></a> <span class="s2">HoveredFile</span><span class="s1">(</span><span class="s2">PathBuf</span><span class="s1">)</span><span class="s3">,</span>
<a name="l188"><span class="ln">188 </span></a> <span class="s2">HoveredFileCancelled</span><span class="s3">,</span>
<a name="l189"><span class="ln">189 </span></a> <span class="s2">ReceivedCharacter</span><span class="s1">(</span><span class="s2">char</span><span class="s1">)</span><span class="s3">,</span>
<a name="l190"><span class="ln">190 </span></a> <span class="s2">Focused</span><span class="s1">(</span><span class="s2">bool</span><span class="s1">)</span><span class="s3">,</span>
<a name="l191"><span class="ln">191 </span></a> <span class="s2">KeyboardInput </span><span class="s1">{</span>
<a name="l192"><span class="ln">192 </span></a> <span class="s2">device_id</span><span class="s1">: </span><span class="s2">DeviceId</span><span class="s3">,</span>
<a name="l193"><span class="ln">193 </span></a> <span class="s2">input</span><span class="s1">: </span><span class="s2">KeyboardInput</span><span class="s3">,</span>
<a name="l194"><span class="ln">194 </span></a> <span class="s2">is_synthetic</span><span class="s1">: </span><span class="s2">bool</span><span class="s3">,</span>
<a name="l195"><span class="ln">195 </span></a> <span class="s1">}</span><span class="s3">,</span>
<a name="l196"><span class="ln">196 </span></a> <span class="s2">ModifiersChanged</span><span class="s1">(</span><span class="s2">ModifiersState</span><span class="s1">)</span><span class="s3">,</span>
<a name="l197"><span class="ln">197 </span></a> <span class="s2">CursorMoved </span><span class="s1">{</span>
<a name="l198"><span class="ln">198 </span></a> <span class="s2">device_id</span><span class="s1">: </span><span class="s2">DeviceId</span><span class="s3">,</span>
<a name="l199"><span class="ln">199 </span></a> <span class="s2">position</span><span class="s1">: </span><span class="s2">PhysicalPosition</span><span class="s1">&lt;</span><span class="s2">f64</span><span class="s1">&gt;</span><span class="s3">,</span>
<a name="l200"><span class="ln">200 </span></a> <span class="s1">#[</span><span class="s2">deprecated </span><span class="s1">= </span><span class="s6">&quot;Deprecated in favor of WindowEvent::ModifiersChanged&quot;</span><span class="s1">]</span>
<a name="l201"><span class="ln">201 </span></a> <span class="s2">modifiers</span><span class="s1">: </span><span class="s2">ModifiersState</span><span class="s3">,</span>
<a name="l202"><span class="ln">202 </span></a> <span class="s1">}</span><span class="s3">,</span>
<a name="l203"><span class="ln">203 </span></a> <span class="s2">CursorEntered </span><span class="s1">{</span>
<a name="l204"><span class="ln">204 </span></a> <span class="s2">device_id</span><span class="s1">: </span><span class="s2">DeviceId</span><span class="s3">,</span>
<a name="l205"><span class="ln">205 </span></a> <span class="s1">}</span><span class="s3">,</span>
<a name="l206"><span class="ln">206 </span></a> <span class="s2">CursorLeft </span><span class="s1">{</span>
<a name="l207"><span class="ln">207 </span></a> <span class="s2">device_id</span><span class="s1">: </span><span class="s2">DeviceId</span><span class="s3">,</span>
<a name="l208"><span class="ln">208 </span></a> <span class="s1">}</span><span class="s3">,</span>
<a name="l209"><span class="ln">209 </span></a> <span class="s2">MouseWheel </span><span class="s1">{</span>
<a name="l210"><span class="ln">210 </span></a> <span class="s2">device_id</span><span class="s1">: </span><span class="s2">DeviceId</span><span class="s3">,</span>
<a name="l211"><span class="ln">211 </span></a> <span class="s2">delta</span><span class="s1">: </span><span class="s2">MouseScrollDelta</span><span class="s3">,</span>
<a name="l212"><span class="ln">212 </span></a> <span class="s2">phase</span><span class="s1">: </span><span class="s2">TouchPhase</span><span class="s3">,</span>
<a name="l213"><span class="ln">213 </span></a> <span class="s1">#[</span><span class="s2">deprecated </span><span class="s1">= </span><span class="s6">&quot;Deprecated in favor of WindowEvent::ModifiersChanged&quot;</span><span class="s1">]</span>
<a name="l214"><span class="ln">214 </span></a> <span class="s2">modifiers</span><span class="s1">: </span><span class="s2">ModifiersState</span><span class="s3">,</span>
<a name="l215"><span class="ln">215 </span></a> <span class="s1">}</span><span class="s3">,</span>
<a name="l216"><span class="ln">216 </span></a> <span class="s2">MouseInput </span><span class="s1">{</span>
<a name="l217"><span class="ln">217 </span></a> <span class="s2">device_id</span><span class="s1">: </span><span class="s2">DeviceId</span><span class="s3">,</span>
<a name="l218"><span class="ln">218 </span></a> <span class="s2">state</span><span class="s1">: </span><span class="s2">ElementState</span><span class="s3">,</span>
<a name="l219"><span class="ln">219 </span></a> <span class="s2">button</span><span class="s1">: </span><span class="s2">MouseButton</span><span class="s3">,</span>
<a name="l220"><span class="ln">220 </span></a> <span class="s1">#[</span><span class="s2">deprecated </span><span class="s1">= </span><span class="s6">&quot;Deprecated in favor of WindowEvent::ModifiersChanged&quot;</span><span class="s1">]</span>
<a name="l221"><span class="ln">221 </span></a> <span class="s2">modifiers</span><span class="s1">: </span><span class="s2">ModifiersState</span><span class="s3">,</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> <span class="s2">TouchpadPressure </span><span class="s1">{</span>
<a name="l224"><span class="ln">224 </span></a> <span class="s2">device_id</span><span class="s1">: </span><span class="s2">DeviceId</span><span class="s3">,</span>
<a name="l225"><span class="ln">225 </span></a> <span class="s2">pressure</span><span class="s1">: </span><span class="s2">f32</span><span class="s3">,</span>
<a name="l226"><span class="ln">226 </span></a> <span class="s2">stage</span><span class="s1">: </span><span class="s2">i64</span><span class="s3">,</span>
<a name="l227"><span class="ln">227 </span></a> <span class="s1">}</span><span class="s3">,</span>
<a name="l228"><span class="ln">228 </span></a> <span class="s2">AxisMotion </span><span class="s1">{</span>
<a name="l229"><span class="ln">229 </span></a> <span class="s2">device_id</span><span class="s1">: </span><span class="s2">DeviceId</span><span class="s3">,</span>
<a name="l230"><span class="ln">230 </span></a> <span class="s2">axis</span><span class="s1">: </span><span class="s2">AxisId</span><span class="s3">,</span>
<a name="l231"><span class="ln">231 </span></a> <span class="s2">value</span><span class="s1">: </span><span class="s2">f64</span><span class="s3">,</span>
<a name="l232"><span class="ln">232 </span></a> <span class="s1">}</span><span class="s3">,</span>
<a name="l233"><span class="ln">233 </span></a> <span class="s2">Touch</span><span class="s1">(</span><span class="s2">Touch</span><span class="s1">)</span><span class="s3">,</span>
<a name="l234"><span class="ln">234 </span></a> <span class="s2">ScaleFactorChanged </span><span class="s1">{</span>
<a name="l235"><span class="ln">235 </span></a> <span class="s2">scale_factor</span><span class="s1">: </span><span class="s2">f64</span><span class="s3">,</span>
<a name="l236"><span class="ln">236 </span></a> <span class="s2">new_inner_size</span><span class="s1">: </span><span class="s2">PhysicalSize</span><span class="s1">&lt;</span><span class="s2">u32</span><span class="s1">&gt;</span><span class="s3">,</span>
<a name="l237"><span class="ln">237 </span></a> <span class="s1">}</span><span class="s3">,</span>
<a name="l238"><span class="ln">238 </span></a> <span class="s2">ThemeChanged</span><span class="s1">(</span><span class="s2">Theme</span><span class="s1">)</span><span class="s3">,</span>
<a name="l239"><span class="ln">239 </span></a><span class="s1">}</span>
<a name="l240"><span class="ln">240 </span></a>
<a name="l241"><span class="ln">241 </span></a>
<a name="l242"><span class="ln">242 </span></a><span class="s4">/// Because I am a glutton for punishment I am going to just do a mono-event-dispatch-magoooo</span>
<a name="l243"><span class="ln">243 </span></a><span class="s1">#[</span><span class="s2">system</span><span class="s1">]</span>
<a name="l244"><span class="ln">244 </span></a><span class="s1">#[</span><span class="s2">write_component</span><span class="s1">(</span><span class="s2">Camera</span><span class="s1">)]</span>
<a name="l245"><span class="ln">245 </span></a><span class="s1">#[</span><span class="s2">write_component</span><span class="s1">(</span><span class="s2">CameraController</span><span class="s1">)]</span>
<a name="l246"><span class="ln">246 </span></a><span class="s0">pub fn </span><span class="s2">event_dispatch</span><span class="s1">(</span>
<a name="l247"><span class="ln">247 </span></a> <span class="s2">world</span><span class="s1">: &amp;</span><span class="s0">mut </span><span class="s2">SubWorld</span><span class="s3">,</span>
<a name="l248"><span class="ln">248 </span></a> <span class="s1">#[</span><span class="s2">resource</span><span class="s1">] </span><span class="s2">event_stack</span><span class="s1">: &amp;</span><span class="s0">mut </span><span class="s2">Vec</span><span class="s1">&lt;</span><span class="s2">OwnedEvent</span><span class="s1">&lt;</span><span class="s2">OwnedEventExtension</span><span class="s1">&gt;&gt;</span><span class="s3">,</span>
<a name="l249"><span class="ln">249 </span></a> <span class="s1">#[</span><span class="s2">resource</span><span class="s1">] </span><span class="s2">imgui_context</span><span class="s1">: &amp;</span><span class="s0">mut </span><span class="s2">Arc</span><span class="s1">&lt;</span><span class="s2">Mutex</span><span class="s1">&lt;</span><span class="s2">ImguiContext</span><span class="s1">&gt;&gt;</span><span class="s3">,</span>
<a name="l250"><span class="ln">250 </span></a> <span class="s1">#[</span><span class="s2">resource</span><span class="s1">] </span><span class="s2">imgui_platform</span><span class="s1">: &amp;</span><span class="s0">mut </span><span class="s2">Arc</span><span class="s1">&lt;</span><span class="s2">Mutex</span><span class="s1">&lt;</span><span class="s2">ImguiPlatform</span><span class="s1">&gt;&gt;</span><span class="s3">,</span>
<a name="l251"><span class="ln">251 </span></a> <span class="s1">#[</span><span class="s2">resource</span><span class="s1">] </span><span class="s2">winit_window</span><span class="s1">: &amp;</span><span class="s0">mut </span><span class="s2">Window</span><span class="s3">,</span>
<a name="l252"><span class="ln">252 </span></a><span class="s1">) {</span>
<a name="l253"><span class="ln">253 </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">Event</span><span class="s1">::</span><span class="s2">DeviceEvent</span><span class="s3">;</span>
<a name="l254"><span class="ln">254 </span></a>
<a name="l255"><span class="ln">255 </span></a> <span class="s0">for </span><span class="s2">event </span><span class="s0">in </span><span class="s2">event_stack </span><span class="s1">{</span>
<a name="l256"><span class="ln">256 </span></a>
<a name="l257"><span class="ln">257 </span></a> <span class="s0">match </span><span class="s2">event </span><span class="s1">{</span>
<a name="l258"><span class="ln">258 </span></a> <span class="s2">OwnedEvent</span><span class="s1">::</span><span class="s2">DeviceEvent </span><span class="s1">{</span>
<a name="l259"><span class="ln">259 </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">MouseMotion </span><span class="s1">{ </span><span class="s2">delta </span><span class="s1">}</span><span class="s3">,</span>
<a name="l260"><span class="ln">260 </span></a> <span class="s1">..</span>
<a name="l261"><span class="ln">261 </span></a> <span class="s1">} =&gt; {</span>
<a name="l262"><span class="ln">262 </span></a> <span class="s0">let mut </span><span class="s2">query </span><span class="s1">= &lt;(&amp;</span><span class="s0">mut </span><span class="s2">CameraController</span><span class="s1">)&gt;::</span><span class="s2">query</span><span class="s1">()</span><span class="s3">;</span>
<a name="l263"><span class="ln">263 </span></a> <span class="s0">for </span><span class="s1">(</span><span class="s2">camera_controller</span><span class="s1">) </span><span class="s0">in </span><span class="s2">query</span><span class="s1">.</span><span class="s2">iter_mut</span><span class="s1">(</span><span class="s2">world</span><span class="s1">) {</span>
<a name="l264"><span class="ln">264 </span></a> <span class="s2">camera_controller</span><span class="s1">.</span><span class="s2">process_mouse</span><span class="s1">(</span><span class="s2">delta</span><span class="s1">.</span><span class="s7">0</span><span class="s3">, </span><span class="s2">delta</span><span class="s1">.</span><span class="s7">1</span><span class="s1">)</span><span class="s3">;</span>
<a name="l265"><span class="ln">265 </span></a> <span class="s1">}</span>
<a name="l266"><span class="ln">266 </span></a>
<a name="l267"><span class="ln">267 </span></a> <span class="s1">}</span><span class="s3">,</span>
<a name="l268"><span class="ln">268 </span></a> <span class="s2">OwnedEvent</span><span class="s1">::</span><span class="s2">DeviceEvent </span><span class="s1">{</span>
<a name="l269"><span class="ln">269 </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="l270"><span class="ln">270 </span></a> <span class="s1">..</span>
<a name="l271"><span class="ln">271 </span></a> <span class="s1">} =&gt; {</span>
<a name="l272"><span class="ln">272 </span></a> <span class="s0">let mut </span><span class="s2">query </span><span class="s1">= &lt;(&amp;</span><span class="s0">mut </span><span class="s2">CameraController</span><span class="s1">)&gt;::</span><span class="s2">query</span><span class="s1">()</span><span class="s3">;</span>
<a name="l273"><span class="ln">273 </span></a> <span class="s0">for </span><span class="s1">(</span><span class="s2">camera_controller</span><span class="s1">) </span><span class="s0">in </span><span class="s2">query</span><span class="s1">.</span><span class="s2">iter_mut</span><span class="s1">(</span><span class="s2">world</span><span class="s1">) {</span>
<a name="l274"><span class="ln">274 </span></a> <span class="s2">camera_controller</span><span class="s1">.</span><span class="s2">process_keyboard</span><span class="s1">(</span>
<a name="l275"><span class="ln">275 </span></a> <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><span class="s3">,</span>
<a name="l276"><span class="ln">276 </span></a> <span class="s2">keyboard_input</span><span class="s1">.</span><span class="s2">state</span><span class="s3">,</span>
<a name="l277"><span class="ln">277 </span></a> <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>
<a name="l280"><span class="ln">280 </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="l281"><span class="ln">281 </span></a> <span class="s2">VirtualKeyCode</span><span class="s1">::</span><span class="s2">R </span><span class="s1">=&gt; {</span>
<a name="l282"><span class="ln">282 </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="l283"><span class="ln">283 </span></a>
<a name="l284"><span class="ln">284 </span></a>
<a name="l285"><span class="ln">285 </span></a> <span class="s8">//winit_window.set_cursor_grab(true);</span>
<a name="l286"><span class="ln">286 </span></a> <span class="s1">}</span>
<a name="l287"><span class="ln">287 </span></a> <span class="s1">}</span>
<a name="l288"><span class="ln">288 </span></a> <span class="s2">VirtualKeyCode</span><span class="s1">::</span><span class="s2">Escape </span><span class="s1">=&gt; {</span>
<a name="l289"><span class="ln">289 </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="l290"><span class="ln">290 </span></a> <span class="s8">//winit_window.set_cursor_grab(false);</span>
<a name="l291"><span class="ln">291 </span></a> <span class="s1">}</span>
<a name="l292"><span class="ln">292 </span></a> <span class="s1">}</span>
<a name="l293"><span class="ln">293 </span></a> <span class="s2">_ </span><span class="s1">=&gt; ()</span>
<a name="l294"><span class="ln">294 </span></a> <span class="s1">}</span>
<a name="l295"><span class="ln">295 </span></a> <span class="s1">}</span>
<a name="l296"><span class="ln">296 </span></a> <span class="s2">_ </span><span class="s1">=&gt; {}</span>
<a name="l297"><span class="ln">297 </span></a> <span class="s1">}</span>
<a name="l298"><span class="ln">298 </span></a>
<a name="l299"><span class="ln">299 </span></a> <span class="s0">let mut </span><span class="s2">imgui_context </span><span class="s1">= &amp;</span><span class="s0">mut </span><span class="s2">imgui_context</span><span class="s1">.</span><span class="s2">lock</span><span class="s1">().</span><span class="s2">unwrap</span><span class="s1">().</span><span class="s2">context</span><span class="s3">;</span>
<a name="l300"><span class="ln">300 </span></a> <span class="s0">let mut </span><span class="s2">imgui_platform </span><span class="s1">= &amp;</span><span class="s0">mut </span><span class="s2">imgui_platform</span><span class="s1">.</span><span class="s2">lock</span><span class="s1">().</span><span class="s2">unwrap</span><span class="s1">().</span><span class="s2">platform</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">imgui_platform</span><span class="s1">.</span><span class="s2">handle_event</span><span class="s1">(</span><span class="s2">imgui_context</span><span class="s1">.</span><span class="s2">io_mut</span><span class="s1">()</span><span class="s3">, </span><span class="s1">&amp;</span><span class="s2">winit_window</span><span class="s3">, </span><span class="s1">&amp;</span><span class="s2">event</span><span class="s1">)</span><span class="s3">;</span>
<a name="l303"><span class="ln">303 </span></a> <span class="s1">}</span>
<a name="l304"><span class="ln">304 </span></a><span class="s1">}</span>
<a name="l305"><span class="ln">305 </span></a></pre>
</body>
</html>

@ -0,0 +1,138 @@
<html>
<head>
<title>state.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;}
.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">
state.rs</font>
</center></td></tr></table>
<pre><a name="l1"><span class="ln">1 </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="l2"><span class="ln">2 </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="l3"><span class="ln">3 </span></a><span class="s0">use </span><span class="s2">std</span><span class="s1">::</span><span class="s2">path</span><span class="s1">::</span><span class="s2">PathBuf</span><span class="s3">;</span>
<a name="l4"><span class="ln">4 </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">Instant</span><span class="s3">;</span>
<a name="l5"><span class="ln">5 </span></a><span class="s0">use </span><span class="s2">serde_derive</span><span class="s1">::</span><span class="s2">Deserialize</span><span class="s3">;</span>
<a name="l6"><span class="ln">6 </span></a>
<a name="l7"><span class="ln">7 </span></a><span class="s0">use </span><span class="s2">cgmath</span><span class="s1">::{</span><span class="s2">Euler</span><span class="s3">, </span><span class="s2">Quaternion</span><span class="s3">, </span><span class="s2">Deg</span><span class="s1">}</span><span class="s3">;</span>
<a name="l8"><span class="ln">8 </span></a><span class="s0">use </span><span class="s2">legion</span><span class="s1">::</span><span class="s2">world</span><span class="s1">::</span><span class="s2">SubWorld</span><span class="s3">;</span>
<a name="l9"><span class="ln">9 </span></a><span class="s0">use </span><span class="s2">legion</span><span class="s1">::</span><span class="s2">IntoQuery</span><span class="s3">;</span>
<a name="l10"><span class="ln">10 </span></a><span class="s0">use </span><span class="s2">legion</span><span class="s1">::*</span><span class="s3">;</span>
<a name="l11"><span class="ln">11 </span></a><span class="s0">use </span><span class="s2">nalgebra</span><span class="s1">::</span><span class="s2">Quaternion </span><span class="s0">as </span><span class="s2">naQuaternion</span><span class="s3">;</span>
<a name="l12"><span class="ln">12 </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><span class="s2">IntegrationParameters</span><span class="s3">, </span><span class="s2">JointSet</span><span class="s3">, </span><span class="s2">RigidBodySet</span><span class="s1">}</span><span class="s3">;</span>
<a name="l13"><span class="ln">13 </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">ColliderSet</span><span class="s3">, </span><span class="s2">NarrowPhase</span><span class="s1">}</span><span class="s3">;</span>
<a name="l14"><span class="ln">14 </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="l15"><span class="ln">15 </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="l16"><span class="ln">16 </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">LoopState</span><span class="s3">, </span><span class="s2">Mesh</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="l17"><span class="ln">17 </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="l18"><span class="ln">18 </span></a><span class="s0">use </span><span class="s2">std</span><span class="s1">::</span><span class="s2">io</span><span class="s1">::</span><span class="s2">Read</span><span class="s3">;</span>
<a name="l19"><span class="ln">19 </span></a>
<a name="l20"><span class="ln">20 </span></a>
<a name="l21"><span class="ln">21 </span></a>
<a name="l22"><span class="ln">22 </span></a><span class="s1">#[</span><span class="s2">derive</span><span class="s1">(</span><span class="s2">Deserialize</span><span class="s3">, </span><span class="s2">Clone</span><span class="s1">)]</span>
<a name="l23"><span class="ln">23 </span></a><span class="s0">pub struct </span><span class="s2">TomlBallPhysicsBodyDescription </span><span class="s1">{</span>
<a name="l24"><span class="ln">24 </span></a> <span class="s0">pub </span><span class="s2">radius</span><span class="s1">: </span><span class="s2">String</span>
<a name="l25"><span class="ln">25 </span></a><span class="s1">}</span>
<a name="l26"><span class="ln">26 </span></a>
<a name="l27"><span class="ln">27 </span></a><span class="s1">#[</span><span class="s2">derive</span><span class="s1">(</span><span class="s2">Deserialize</span><span class="s3">, </span><span class="s2">Clone</span><span class="s1">)]</span>
<a name="l28"><span class="ln">28 </span></a><span class="s0">pub struct </span><span class="s2">TomlCuboidPhysicsBodyDescription </span><span class="s1">{</span>
<a name="l29"><span class="ln">29 </span></a> <span class="s0">pub </span><span class="s2">x</span><span class="s1">: </span><span class="s2">f32</span><span class="s3">,</span>
<a name="l30"><span class="ln">30 </span></a> <span class="s0">pub </span><span class="s2">y</span><span class="s1">: </span><span class="s2">f32</span><span class="s3">,</span>
<a name="l31"><span class="ln">31 </span></a> <span class="s0">pub </span><span class="s2">z</span><span class="s1">: </span><span class="s2">f32</span><span class="s3">,</span>
<a name="l32"><span class="ln">32 </span></a><span class="s1">}</span>
<a name="l33"><span class="ln">33 </span></a>
<a name="l34"><span class="ln">34 </span></a><span class="s1">#[</span><span class="s2">derive</span><span class="s1">(</span><span class="s2">Deserialize</span><span class="s3">, </span><span class="s2">Clone</span><span class="s1">)]</span>
<a name="l35"><span class="ln">35 </span></a><span class="s0">pub struct </span><span class="s2">TomlPhysicsDescription </span><span class="s1">{</span>
<a name="l36"><span class="ln">36 </span></a> <span class="s0">pub </span><span class="s2">body_status</span><span class="s1">: </span><span class="s2">String</span><span class="s3">,</span>
<a name="l37"><span class="ln">37 </span></a> <span class="s0">pub </span><span class="s2">ball</span><span class="s1">: </span><span class="s2">Option</span><span class="s1">&lt;</span><span class="s2">TomlBallPhysicsBodyDescription</span><span class="s1">&gt;</span><span class="s3">,</span>
<a name="l38"><span class="ln">38 </span></a> <span class="s0">pub </span><span class="s2">cuboid</span><span class="s1">: </span><span class="s2">Option</span><span class="s1">&lt;</span><span class="s2">TomlCuboidPhysicsBodyDescription</span><span class="s1">&gt;</span><span class="s3">,</span>
<a name="l39"><span class="ln">39 </span></a><span class="s1">}</span>
<a name="l40"><span class="ln">40 </span></a>
<a name="l41"><span class="ln">41 </span></a><span class="s1">#[</span><span class="s2">derive</span><span class="s1">(</span><span class="s2">Deserialize</span><span class="s3">, </span><span class="s2">Clone</span><span class="s1">)]</span>
<a name="l42"><span class="ln">42 </span></a><span class="s0">pub struct </span><span class="s2">TomlRotationDescription </span><span class="s1">{</span>
<a name="l43"><span class="ln">43 </span></a> <span class="s0">pub </span><span class="s2">x</span><span class="s1">: </span><span class="s2">f32</span><span class="s3">,</span>
<a name="l44"><span class="ln">44 </span></a> <span class="s0">pub </span><span class="s2">y</span><span class="s1">: </span><span class="s2">f32</span><span class="s3">,</span>
<a name="l45"><span class="ln">45 </span></a> <span class="s0">pub </span><span class="s2">z</span><span class="s1">: </span><span class="s2">f32</span><span class="s3">,</span>
<a name="l46"><span class="ln">46 </span></a><span class="s1">}</span>
<a name="l47"><span class="ln">47 </span></a>
<a name="l48"><span class="ln">48 </span></a><span class="s1">#[</span><span class="s2">derive</span><span class="s1">(</span><span class="s2">Deserialize</span><span class="s3">, </span><span class="s2">Clone</span><span class="s1">)]</span>
<a name="l49"><span class="ln">49 </span></a><span class="s0">pub struct </span><span class="s2">TomlPositionDescription </span><span class="s1">{</span>
<a name="l50"><span class="ln">50 </span></a> <span class="s0">pub </span><span class="s2">x</span><span class="s1">: </span><span class="s2">f32</span><span class="s3">,</span>
<a name="l51"><span class="ln">51 </span></a> <span class="s0">pub </span><span class="s2">y</span><span class="s1">: </span><span class="s2">f32</span><span class="s3">,</span>
<a name="l52"><span class="ln">52 </span></a> <span class="s0">pub </span><span class="s2">z</span><span class="s1">: </span><span class="s2">f32</span><span class="s3">,</span>
<a name="l53"><span class="ln">53 </span></a> <span class="s0">pub </span><span class="s2">rot</span><span class="s1">: </span><span class="s2">Option</span><span class="s1">&lt;</span><span class="s2">TomlRotationDescription</span><span class="s1">&gt;</span><span class="s3">,</span>
<a name="l54"><span class="ln">54 </span></a><span class="s1">}</span>
<a name="l55"><span class="ln">55 </span></a>
<a name="l56"><span class="ln">56 </span></a><span class="s1">#[</span><span class="s2">derive</span><span class="s1">(</span><span class="s2">Deserialize</span><span class="s3">, </span><span class="s2">Clone</span><span class="s1">)]</span>
<a name="l57"><span class="ln">57 </span></a><span class="s0">pub struct </span><span class="s2">TomlEntityDescription </span><span class="s1">{</span>
<a name="l58"><span class="ln">58 </span></a> <span class="s0">pub </span><span class="s2">name</span><span class="s1">: </span><span class="s2">String</span><span class="s3">,</span>
<a name="l59"><span class="ln">59 </span></a> <span class="s1">#[</span><span class="s2">serde</span><span class="s1">(</span><span class="s2">rename </span><span class="s1">= </span><span class="s4">&quot;type&quot;</span><span class="s1">)]</span>
<a name="l60"><span class="ln">60 </span></a> <span class="s0">pub </span><span class="s2">type_name</span><span class="s1">: </span><span class="s2">String</span><span class="s3">,</span>
<a name="l61"><span class="ln">61 </span></a> <span class="s0">pub </span><span class="s2">mesh</span><span class="s1">: </span><span class="s2">Option</span><span class="s1">&lt;</span><span class="s2">String</span><span class="s1">&gt;</span><span class="s3">,</span>
<a name="l62"><span class="ln">62 </span></a> <span class="s0">pub </span><span class="s2">position</span><span class="s1">: </span><span class="s2">Option</span><span class="s1">&lt;</span><span class="s2">TomlPositionDescription</span><span class="s1">&gt;</span><span class="s3">,</span>
<a name="l63"><span class="ln">63 </span></a> <span class="s0">pub </span><span class="s2">physics</span><span class="s1">: </span><span class="s2">Option</span><span class="s1">&lt;</span><span class="s2">TomlPhysicsDescription</span><span class="s1">&gt;</span><span class="s3">,</span>
<a name="l64"><span class="ln">64 </span></a><span class="s1">}</span>
<a name="l65"><span class="ln">65 </span></a>
<a name="l66"><span class="ln">66 </span></a><span class="s1">#[</span><span class="s2">derive</span><span class="s1">(</span><span class="s2">Deserialize</span><span class="s3">, </span><span class="s2">Clone</span><span class="s1">)]</span>
<a name="l67"><span class="ln">67 </span></a><span class="s0">pub struct </span><span class="s2">TomlEntityContainer </span><span class="s1">{</span>
<a name="l68"><span class="ln">68 </span></a> <span class="s0">pub </span><span class="s2">entities</span><span class="s1">: </span><span class="s2">Vec</span><span class="s1">&lt;</span><span class="s2">TomlEntityDescription</span><span class="s1">&gt;</span><span class="s3">,</span>
<a name="l69"><span class="ln">69 </span></a><span class="s1">}</span>
<a name="l70"><span class="ln">70 </span></a>
<a name="l71"><span class="ln">71 </span></a><span class="s0">pub struct </span><span class="s2">RuntimeState </span><span class="s1">{</span>
<a name="l72"><span class="ln">72 </span></a> <span class="s2">config_db</span><span class="s1">: </span><span class="s2">TomlEntityContainer</span><span class="s3">,</span>
<a name="l73"><span class="ln">73 </span></a> <span class="s2">mesh_cache</span><span class="s1">: </span><span class="s2">HashMap</span><span class="s1">&lt;</span><span class="s2">String</span><span class="s3">, </span><span class="s2">RawMesh</span><span class="s1">&gt;</span><span class="s3">,</span>
<a name="l74"><span class="ln">74 </span></a><span class="s1">}</span>
<a name="l75"><span class="ln">75 </span></a>
<a name="l76"><span class="ln">76 </span></a><span class="s0">impl </span><span class="s2">RuntimeState </span><span class="s1">{</span>
<a name="l77"><span class="ln">77 </span></a> <span class="s0">pub fn </span><span class="s2">new</span><span class="s1">() -&gt; </span><span class="s2">RuntimeState </span><span class="s1">{</span>
<a name="l78"><span class="ln">78 </span></a> <span class="s5">// TODO: Hook this file to the gui</span>
<a name="l79"><span class="ln">79 </span></a> <span class="s0">let mut </span><span class="s2">file </span><span class="s1">= </span><span class="s2">fs</span><span class="s1">::</span><span class="s2">File</span><span class="s1">::</span><span class="s2">open</span><span class="s1">(</span><span class="s4">&quot;./conf/entity_spawns.toml&quot;</span><span class="s1">).</span><span class="s2">unwrap</span><span class="s1">()</span><span class="s3">;</span>
<a name="l80"><span class="ln">80 </span></a> <span class="s0">let mut </span><span class="s2">content </span><span class="s1">= </span><span class="s2">String</span><span class="s1">::</span><span class="s2">new</span><span class="s1">()</span><span class="s3">;</span>
<a name="l81"><span class="ln">81 </span></a> <span class="s2">file</span><span class="s1">.</span><span class="s2">read_to_string</span><span class="s1">(&amp;</span><span class="s0">mut </span><span class="s2">content</span><span class="s1">).</span><span class="s2">unwrap</span><span class="s1">()</span><span class="s3">;</span>
<a name="l82"><span class="ln">82 </span></a>
<a name="l83"><span class="ln">83 </span></a> <span class="s5">// TODO: gracefully fail</span>
<a name="l84"><span class="ln">84 </span></a> <span class="s0">let mut </span><span class="s2">settings </span><span class="s1">: </span><span class="s2">TomlEntityContainer </span><span class="s1">= </span><span class="s2">toml</span><span class="s1">::</span><span class="s2">from_str</span><span class="s1">(</span><span class="s2">content</span><span class="s1">.</span><span class="s2">as_str</span><span class="s1">()).</span><span class="s2">unwrap</span><span class="s1">()</span><span class="s3">;</span>
<a name="l85"><span class="ln">85 </span></a>
<a name="l86"><span class="ln">86 </span></a> <span class="s2">RuntimeState </span><span class="s1">{</span>
<a name="l87"><span class="ln">87 </span></a> <span class="s2">config_db</span><span class="s1">: </span><span class="s2">settings</span><span class="s3">,</span>
<a name="l88"><span class="ln">88 </span></a> <span class="s2">mesh_cache</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="l89"><span class="ln">89 </span></a> <span class="s1">}</span>
<a name="l90"><span class="ln">90 </span></a> <span class="s1">}</span>
<a name="l91"><span class="ln">91 </span></a>
<a name="l92"><span class="ln">92 </span></a> <span class="s0">pub fn </span><span class="s2">get_mesh</span><span class="s1">(&amp;</span><span class="s0">mut self</span><span class="s3">, </span><span class="s2">mesh</span><span class="s1">: &amp;</span><span class="s2">str</span><span class="s1">) -&gt; </span><span class="s2">Option</span><span class="s1">&lt;&amp;</span><span class="s2">RawMesh</span><span class="s1">&gt; {</span>
<a name="l93"><span class="ln">93 </span></a> <span class="s0">self</span><span class="s1">.</span><span class="s2">mesh_cache</span><span class="s1">.</span><span class="s2">get</span><span class="s1">(</span><span class="s2">mesh</span><span class="s1">)</span>
<a name="l94"><span class="ln">94 </span></a> <span class="s1">}</span>
<a name="l95"><span class="ln">95 </span></a>
<a name="l96"><span class="ln">96 </span></a> <span class="s0">pub fn </span><span class="s2">get_entities</span><span class="s1">(&amp;</span><span class="s0">mut self</span><span class="s1">) -&gt; </span><span class="s2">Vec</span><span class="s1">&lt;</span><span class="s2">TomlEntityDescription</span><span class="s1">&gt; {</span>
<a name="l97"><span class="ln">97 </span></a> <span class="s0">self</span><span class="s1">.</span><span class="s2">config_db</span><span class="s1">.</span><span class="s2">entities</span><span class="s1">.</span><span class="s2">clone</span><span class="s1">()</span>
<a name="l98"><span class="ln">98 </span></a> <span class="s1">}</span>
<a name="l99"><span class="ln">99 </span></a>
<a name="l100"><span class="ln">100 </span></a> <span class="s0">pub fn </span><span class="s2">preload_meshes</span><span class="s1">(&amp;</span><span class="s0">mut self</span><span class="s3">, </span><span class="s2">resources_path</span><span class="s1">: </span><span class="s2">PathBuf</span><span class="s1">) {</span>
<a name="l101"><span class="ln">101 </span></a> <span class="s2">log</span><span class="s1">::</span><span class="s2">info</span><span class="s1">!(</span><span class="s4">&quot;Preloading meshes...&quot;</span><span class="s1">)</span><span class="s3">;</span>
<a name="l102"><span class="ln">102 </span></a>
<a name="l103"><span class="ln">103 </span></a> <span class="s0">let </span><span class="s2">paths </span><span class="s1">= </span><span class="s2">fs</span><span class="s1">::</span><span class="s2">read_dir</span><span class="s1">(</span><span class="s2">resources_path</span><span class="s1">).</span><span class="s2">unwrap</span><span class="s1">()</span><span class="s3">;</span>
<a name="l104"><span class="ln">104 </span></a> <span class="s0">for </span><span class="s2">file </span><span class="s0">in </span><span class="s2">paths </span><span class="s1">{</span>
<a name="l105"><span class="ln">105 </span></a> <span class="s0">let </span><span class="s2">file </span><span class="s1">= </span><span class="s2">file</span><span class="s1">.</span><span class="s2">unwrap</span><span class="s1">()</span><span class="s3">;</span>
<a name="l106"><span class="ln">106 </span></a> <span class="s0">let </span><span class="s2">filepath </span><span class="s1">= </span><span class="s2">file</span><span class="s1">.</span><span class="s2">path</span><span class="s1">().</span><span class="s2">clone</span><span class="s1">()</span><span class="s3">;</span>
<a name="l107"><span class="ln">107 </span></a> <span class="s0">let </span><span class="s2">filename </span><span class="s1">= </span><span class="s2">String</span><span class="s1">::</span><span class="s2">from</span><span class="s1">(</span><span class="s2">file</span><span class="s1">.</span><span class="s2">file_name</span><span class="s1">().</span><span class="s2">to_str</span><span class="s1">().</span><span class="s2">unwrap</span><span class="s1">())</span><span class="s3">;</span>
<a name="l108"><span class="ln">108 </span></a>
<a name="l109"><span class="ln">109 </span></a> <span class="s0">if </span><span class="s2">filename</span><span class="s1">.</span><span class="s2">ends_with</span><span class="s1">(</span><span class="s4">&quot;.obj&quot;</span><span class="s1">) {</span>
<a name="l110"><span class="ln">110 </span></a> <span class="s0">let </span><span class="s2">mesh </span><span class="s1">= </span><span class="s2">load_obj</span><span class="s1">(</span><span class="s2">filepath</span><span class="s1">.</span><span class="s2">to_str</span><span class="s1">().</span><span class="s2">unwrap</span><span class="s1">()).</span><span class="s2">unwrap</span><span class="s1">()</span><span class="s3">;</span>
<a name="l111"><span class="ln">111 </span></a> <span class="s0">self</span><span class="s1">.</span><span class="s2">mesh_cache</span><span class="s1">.</span><span class="s2">insert</span><span class="s1">(</span><span class="s2">filename</span><span class="s3">, </span><span class="s2">mesh</span><span class="s1">)</span><span class="s3">;</span>
<a name="l112"><span class="ln">112 </span></a> <span class="s1">}</span>
<a name="l113"><span class="ln">113 </span></a> <span class="s1">}</span>
<a name="l114"><span class="ln">114 </span></a> <span class="s1">}</span>
<a name="l115"><span class="ln">115 </span></a><span class="s1">}</span>
<a name="l116"><span class="ln">116 </span></a></pre>
</body>
</html>

@ -0,0 +1,356 @@
<html>
<head>
<title>system.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: #33ccff; font-weight: bold;}
.s5 { color: #54b33e;}
.s6 { color: #7ec3e6;}
.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">
system.rs</font>
</center></td></tr></table>
<pre><a name="l1"><span class="ln">1 </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="l2"><span class="ln">2 </span></a><span class="s0">use </span><span class="s2">std</span><span class="s1">::</span><span class="s2">path</span><span class="s1">::</span><span class="s2">PathBuf</span><span class="s3">;</span>
<a name="l3"><span class="ln">3 </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">Instant</span><span class="s3">;</span>
<a name="l4"><span class="ln">4 </span></a>
<a name="l5"><span class="ln">5 </span></a><span class="s0">use </span><span class="s2">cgmath</span><span class="s1">::{</span><span class="s2">Deg</span><span class="s3">, </span><span class="s2">Euler</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="s1">}</span><span class="s3">;</span>
<a name="l6"><span class="ln">6 </span></a><span class="s0">use </span><span class="s2">imgui</span><span class="s1">::*</span><span class="s3">;</span>
<a name="l7"><span class="ln">7 </span></a><span class="s0">use </span><span class="s2">imgui</span><span class="s1">::{</span><span class="s2">Condition</span><span class="s3">, </span><span class="s2">FontSource</span><span class="s3">, </span><span class="s2">Ui</span><span class="s1">}</span><span class="s3">;</span>
<a name="l8"><span class="ln">8 </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">CommandBuffer</span><span class="s3">;</span>
<a name="l9"><span class="ln">9 </span></a><span class="s0">use </span><span class="s2">legion</span><span class="s1">::</span><span class="s2">world</span><span class="s1">::</span><span class="s2">SubWorld</span><span class="s3">;</span>
<a name="l10"><span class="ln">10 </span></a><span class="s0">use </span><span class="s2">legion</span><span class="s1">::</span><span class="s2">IntoQuery</span><span class="s3">;</span>
<a name="l11"><span class="ln">11 </span></a><span class="s0">use </span><span class="s2">legion</span><span class="s1">::*</span><span class="s3">;</span>
<a name="l12"><span class="ln">12 </span></a><span class="s0">use </span><span class="s2">nalgebra</span><span class="s1">::</span><span class="s2">Quaternion </span><span class="s0">as </span><span class="s2">naQuaternion</span><span class="s3">;</span>
<a name="l13"><span class="ln">13 </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="l14"><span class="ln">14 </span></a> <span class="s2">IntegrationParameters</span><span class="s3">, </span><span class="s2">JointSet</span><span class="s3">, </span><span class="s2">MassProperties</span><span class="s3">, </span><span class="s2">RigidBodyBuilder</span><span class="s3">, </span><span class="s2">RigidBodySet</span><span class="s3">,</span>
<a name="l15"><span class="ln">15 </span></a><span class="s1">}</span><span class="s3">;</span>
<a name="l16"><span class="ln">16 </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">ColliderSet</span><span class="s3">, </span><span class="s2">NarrowPhase</span><span class="s1">}</span><span class="s3">;</span>
<a name="l17"><span class="ln">17 </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">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="l18"><span class="ln">18 </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">ChannelEventCollector</span><span class="s3">, </span><span class="s2">PhysicsPipeline</span><span class="s1">}</span><span class="s3">;</span>
<a name="l19"><span class="ln">19 </span></a>
<a name="l20"><span class="ln">20 </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="l21"><span class="ln">21 </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">Mesh</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="l22"><span class="ln">22 </span></a><span class="s0">use crate</span><span class="s1">::</span><span class="s2">geometry</span><span class="s3">;</span>
<a name="l23"><span class="ln">23 </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="l24"><span class="ln">24 </span></a><span class="s0">use crate</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="s3">;</span>
<a name="l25"><span class="ln">25 </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">ImguiGenericOutputLine</span><span class="s3">, </span><span class="s2">ImguiPerformanceProfilerLine</span><span class="s1">}</span><span class="s3">;</span>
<a name="l26"><span class="ln">26 </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="l27"><span class="ln">27 </span></a><span class="s0">use crate</span><span class="s1">::</span><span class="s2">geometry</span><span class="s1">::</span><span class="s2">RawMesh</span><span class="s3">;</span>
<a name="l28"><span class="ln">28 </span></a>
<a name="l29"><span class="ln">29 </span></a><span class="s0">pub fn </span><span class="s2">quad_color</span><span class="s1">(</span><span class="s2">color</span><span class="s1">: [</span><span class="s2">f32</span><span class="s3">; </span><span class="s4">4</span><span class="s1">]) -&gt; [[</span><span class="s2">f32</span><span class="s3">; </span><span class="s4">4</span><span class="s1">]</span><span class="s3">; </span><span class="s4">4</span><span class="s1">] {</span>
<a name="l30"><span class="ln">30 </span></a> <span class="s1">[</span><span class="s2">color</span><span class="s3">, </span><span class="s2">color</span><span class="s3">, </span><span class="s2">color</span><span class="s3">, </span><span class="s2">color</span><span class="s1">]</span>
<a name="l31"><span class="ln">31 </span></a><span class="s1">}</span>
<a name="l32"><span class="ln">32 </span></a>
<a name="l33"><span class="ln">33 </span></a><span class="s1">#[</span><span class="s2">system</span><span class="s1">]</span>
<a name="l34"><span class="ln">34 </span></a><span class="s1">#[</span><span class="s2">write_component</span><span class="s1">(</span><span class="s2">Mesh</span><span class="s1">)]</span>
<a name="l35"><span class="ln">35 </span></a><span class="s0">pub fn </span><span class="s2">runtime_load</span><span class="s1">(</span>
<a name="l36"><span class="ln">36 </span></a> <span class="s2">cmd</span><span class="s1">: &amp;</span><span class="s0">mut </span><span class="s2">CommandBuffer</span><span class="s3">,</span>
<a name="l37"><span class="ln">37 </span></a> <span class="s2">world</span><span class="s1">: &amp;</span><span class="s0">mut </span><span class="s2">SubWorld</span><span class="s3">,</span>
<a name="l38"><span class="ln">38 </span></a> <span class="s1">#[</span><span class="s2">resource</span><span class="s1">] </span><span class="s2">runtime_state</span><span class="s1">: &amp;</span><span class="s0">mut </span><span class="s2">RuntimeState</span><span class="s3">,</span>
<a name="l39"><span class="ln">39 </span></a><span class="s1">) {</span>
<a name="l40"><span class="ln">40 </span></a> <span class="s2">runtime_state</span><span class="s1">.</span><span class="s2">preload_meshes</span><span class="s1">(</span><span class="s2">PathBuf</span><span class="s1">::</span><span class="s2">from</span><span class="s1">(</span><span class="s5">&quot;./resources&quot;</span><span class="s1">))</span><span class="s3">;</span>
<a name="l41"><span class="ln">41 </span></a>
<a name="l42"><span class="ln">42 </span></a> <span class="s0">let </span><span class="s2">entity</span><span class="s1">: </span><span class="s2">Entity </span><span class="s1">= </span><span class="s2">cmd</span><span class="s1">.</span><span class="s2">push</span><span class="s1">((</span><span class="s2">ImguiWindow </span><span class="s1">{</span>
<a name="l43"><span class="ln">43 </span></a> <span class="s6">// a window that does everything for the performance profiler</span>
<a name="l44"><span class="ln">44 </span></a> <span class="s2">window</span><span class="s1">: || {</span>
<a name="l45"><span class="ln">45 </span></a> <span class="s2">imgui</span><span class="s1">::</span><span class="s2">Window</span><span class="s1">::</span><span class="s2">new</span><span class="s1">(</span><span class="s2">im_str</span><span class="s1">!(</span><span class="s5">&quot;Performance Profiler&quot;</span><span class="s1">))</span>
<a name="l46"><span class="ln">46 </span></a> <span class="s1">.</span><span class="s2">size</span><span class="s1">([</span><span class="s4">400</span><span class="s1">.</span><span class="s4">0</span><span class="s3">, </span><span class="s4">200</span><span class="s1">.</span><span class="s4">0</span><span class="s1">]</span><span class="s3">, </span><span class="s2">Condition</span><span class="s1">::</span><span class="s2">FirstUseEver</span><span class="s1">)</span>
<a name="l47"><span class="ln">47 </span></a> <span class="s1">.</span><span class="s2">position</span><span class="s1">([</span><span class="s4">10</span><span class="s1">.</span><span class="s4">0</span><span class="s3">, </span><span class="s4">10</span><span class="s1">.</span><span class="s4">0</span><span class="s1">]</span><span class="s3">, </span><span class="s2">Condition</span><span class="s1">::</span><span class="s2">FirstUseEver</span><span class="s1">)</span>
<a name="l48"><span class="ln">48 </span></a> <span class="s1">}</span><span class="s3">,</span>
<a name="l49"><span class="ln">49 </span></a> <span class="s2">func</span><span class="s1">: |</span><span class="s2">ui</span><span class="s1">: &amp;</span><span class="s2">Ui</span><span class="s3">, </span><span class="s2">a</span><span class="s1">: </span><span class="s2">Vec</span><span class="s1">&lt;&amp;</span><span class="s2">ImguiPerformanceProfilerLine</span><span class="s1">&gt;| {</span>
<a name="l50"><span class="ln">50 </span></a> <span class="s6">// ui.text(im_str!(&quot;Performance Graph&quot;));</span>
<a name="l51"><span class="ln">51 </span></a>
<a name="l52"><span class="ln">52 </span></a> <span class="s0">let </span><span class="s2">draw_list </span><span class="s1">= </span><span class="s2">ui</span><span class="s1">.</span><span class="s2">get_window_draw_list</span><span class="s1">()</span><span class="s3">;</span>
<a name="l53"><span class="ln">53 </span></a> <span class="s0">let </span><span class="s2">top_left </span><span class="s1">= </span><span class="s2">ui</span><span class="s1">.</span><span class="s2">cursor_screen_pos</span><span class="s1">()</span><span class="s3">;</span>
<a name="l54"><span class="ln">54 </span></a> <span class="s0">let </span><span class="s2">region_size </span><span class="s1">= </span><span class="s2">ui</span><span class="s1">.</span><span class="s2">content_region_avail</span><span class="s1">()</span><span class="s3">;</span>
<a name="l55"><span class="ln">55 </span></a>
<a name="l56"><span class="ln">56 </span></a> <span class="s0">let </span><span class="s2">region_size </span><span class="s1">= [</span><span class="s2">region_size</span><span class="s1">[</span><span class="s4">0</span><span class="s1">] * </span><span class="s4">0</span><span class="s1">.</span><span class="s4">80</span><span class="s3">, </span><span class="s2">region_size</span><span class="s1">[</span><span class="s4">1</span><span class="s1">]]</span><span class="s3">;</span>
<a name="l57"><span class="ln">57 </span></a>
<a name="l58"><span class="ln">58 </span></a> <span class="s6">// Fill rect</span>
<a name="l59"><span class="ln">59 </span></a> <span class="s0">let </span><span class="s2">qcolor </span><span class="s1">= </span><span class="s2">quad_color</span><span class="s1">([</span><span class="s4">0</span><span class="s1">.</span><span class="s4">5</span><span class="s3">, </span><span class="s4">0</span><span class="s1">.</span><span class="s4">5</span><span class="s3">, </span><span class="s4">1</span><span class="s1">.</span><span class="s4">0</span><span class="s3">, </span><span class="s4">0</span><span class="s1">.</span><span class="s4">1</span><span class="s1">])</span><span class="s3">;</span>
<a name="l60"><span class="ln">60 </span></a> <span class="s2">draw_list</span><span class="s1">.</span><span class="s2">add_rect_filled_multicolor</span><span class="s1">(</span>
<a name="l61"><span class="ln">61 </span></a> <span class="s2">top_left</span><span class="s3">,</span>
<a name="l62"><span class="ln">62 </span></a> <span class="s1">[</span><span class="s2">top_left</span><span class="s1">[</span><span class="s4">0</span><span class="s1">] + (</span><span class="s2">region_size</span><span class="s1">[</span><span class="s4">0</span><span class="s1">])</span><span class="s3">, </span><span class="s2">top_left</span><span class="s1">[</span><span class="s4">1</span><span class="s1">] + </span><span class="s2">region_size</span><span class="s1">[</span><span class="s4">1</span><span class="s1">]]</span><span class="s3">,</span>
<a name="l63"><span class="ln">63 </span></a> <span class="s2">qcolor</span><span class="s1">[</span><span class="s4">0</span><span class="s1">]</span><span class="s3">,</span>
<a name="l64"><span class="ln">64 </span></a> <span class="s2">qcolor</span><span class="s1">[</span><span class="s4">1</span><span class="s1">]</span><span class="s3">,</span>
<a name="l65"><span class="ln">65 </span></a> <span class="s2">qcolor</span><span class="s1">[</span><span class="s4">2</span><span class="s1">]</span><span class="s3">,</span>
<a name="l66"><span class="ln">66 </span></a> <span class="s2">qcolor</span><span class="s1">[</span><span class="s4">3</span><span class="s1">]</span><span class="s3">,</span>
<a name="l67"><span class="ln">67 </span></a> <span class="s1">)</span><span class="s3">;</span>
<a name="l68"><span class="ln">68 </span></a>
<a name="l69"><span class="ln">69 </span></a> <span class="s0">for </span><span class="s2">profiler_line </span><span class="s0">in </span><span class="s2">a </span><span class="s1">{</span>
<a name="l70"><span class="ln">70 </span></a> <span class="s0">let </span><span class="s2">x_scale </span><span class="s1">= (</span><span class="s2">region_size</span><span class="s1">[</span><span class="s4">0</span><span class="s1">]) / </span><span class="s4">400</span><span class="s1">.</span><span class="s4">0</span><span class="s3">;</span>
<a name="l71"><span class="ln">71 </span></a> <span class="s0">let </span><span class="s2">y_scale </span><span class="s1">= </span><span class="s2">region_size</span><span class="s1">[</span><span class="s4">1</span><span class="s1">] / </span><span class="s2">profiler_line</span><span class="s1">.</span><span class="s2">scale_max</span><span class="s3">;</span>
<a name="l72"><span class="ln">72 </span></a> <span class="s2">profiler_line</span>
<a name="l73"><span class="ln">73 </span></a> <span class="s1">.</span><span class="s2">iter_data_from_head</span><span class="s1">()</span>
<a name="l74"><span class="ln">74 </span></a> <span class="s1">.</span><span class="s2">fold</span><span class="s1">((</span><span class="s4">0</span><span class="s3">, </span><span class="s4">0</span><span class="s1">.</span><span class="s4">0f32</span><span class="s1">)</span><span class="s3">, </span><span class="s1">|</span><span class="s2">accum</span><span class="s3">, </span><span class="s1">&amp;</span><span class="s2">fps_val</span><span class="s1">| {</span>
<a name="l75"><span class="ln">75 </span></a> <span class="s0">let </span><span class="s2">x1 </span><span class="s1">= </span><span class="s2">accum</span><span class="s1">.</span><span class="s4">0 </span><span class="s0">as </span><span class="s2">f32 </span><span class="s1">* </span><span class="s2">x_scale </span><span class="s1">+ </span><span class="s2">top_left</span><span class="s1">[</span><span class="s4">0</span><span class="s1">]</span><span class="s3">;</span>
<a name="l76"><span class="ln">76 </span></a> <span class="s0">let </span><span class="s2">y1 </span><span class="s1">= </span><span class="s2">top_left</span><span class="s1">[</span><span class="s4">1</span><span class="s1">] + </span><span class="s2">region_size</span><span class="s1">[</span><span class="s4">1</span><span class="s1">] - </span><span class="s2">accum</span><span class="s1">.</span><span class="s4">1 </span><span class="s1">* </span><span class="s2">y_scale</span><span class="s3">;</span>
<a name="l77"><span class="ln">77 </span></a> <span class="s0">let </span><span class="s2">x2 </span><span class="s1">= (</span><span class="s2">accum</span><span class="s1">.</span><span class="s4">0 </span><span class="s0">as </span><span class="s2">f32 </span><span class="s1">+ </span><span class="s4">1</span><span class="s1">.</span><span class="s4">0</span><span class="s1">) * </span><span class="s2">x_scale </span><span class="s1">+ </span><span class="s2">top_left</span><span class="s1">[</span><span class="s4">0</span><span class="s1">]</span><span class="s3">;</span>
<a name="l78"><span class="ln">78 </span></a> <span class="s0">let </span><span class="s2">y2 </span><span class="s1">= </span><span class="s2">top_left</span><span class="s1">[</span><span class="s4">1</span><span class="s1">] + </span><span class="s2">region_size</span><span class="s1">[</span><span class="s4">1</span><span class="s1">] - </span><span class="s2">fps_val </span><span class="s1">* </span><span class="s2">y_scale</span><span class="s3">;</span>
<a name="l79"><span class="ln">79 </span></a> <span class="s0">let </span><span class="s2">p1 </span><span class="s1">= [</span><span class="s2">x1</span><span class="s3">, </span><span class="s2">y1</span><span class="s1">]</span><span class="s3">;</span>
<a name="l80"><span class="ln">80 </span></a> <span class="s0">let </span><span class="s2">p2 </span><span class="s1">= [</span><span class="s2">x2</span><span class="s3">, </span><span class="s2">y2</span><span class="s1">]</span><span class="s3">;</span>
<a name="l81"><span class="ln">81 </span></a> <span class="s2">draw_list</span>
<a name="l82"><span class="ln">82 </span></a> <span class="s1">.</span><span class="s2">add_line</span><span class="s1">(</span><span class="s2">p1</span><span class="s3">, </span><span class="s2">p2</span><span class="s3">, </span><span class="s1">[</span><span class="s4">1</span><span class="s1">.</span><span class="s4">0</span><span class="s3">, </span><span class="s4">1</span><span class="s1">.</span><span class="s4">0</span><span class="s3">, </span><span class="s4">0</span><span class="s1">.</span><span class="s4">0</span><span class="s3">, </span><span class="s4">0</span><span class="s1">.</span><span class="s4">8</span><span class="s1">])</span>
<a name="l83"><span class="ln">83 </span></a> <span class="s1">.</span><span class="s2">thickness</span><span class="s1">(</span><span class="s4">1</span><span class="s1">.</span><span class="s4">0</span><span class="s1">)</span>
<a name="l84"><span class="ln">84 </span></a> <span class="s1">.</span><span class="s2">build</span><span class="s1">()</span><span class="s3">;</span>
<a name="l85"><span class="ln">85 </span></a> <span class="s1">(</span><span class="s2">accum</span><span class="s1">.</span><span class="s4">0 </span><span class="s1">+ </span><span class="s4">1</span><span class="s3">, </span><span class="s2">fps_val</span><span class="s1">)</span>
<a name="l86"><span class="ln">86 </span></a> <span class="s1">})</span><span class="s3">;</span>
<a name="l87"><span class="ln">87 </span></a>
<a name="l88"><span class="ln">88 </span></a> <span class="s0">let </span><span class="s2">text_x </span><span class="s1">= (</span><span class="s2">region_size</span><span class="s1">[</span><span class="s4">0</span><span class="s1">] + </span><span class="s2">top_left</span><span class="s1">[</span><span class="s4">0</span><span class="s1">])</span><span class="s3">;</span>
<a name="l89"><span class="ln">89 </span></a> <span class="s0">let </span><span class="s2">text_y </span><span class="s1">= </span><span class="s2">top_left</span><span class="s1">[</span><span class="s4">1</span><span class="s1">] + </span><span class="s2">region_size</span><span class="s1">[</span><span class="s4">1</span><span class="s1">]</span>
<a name="l90"><span class="ln">90 </span></a> <span class="s1">- </span><span class="s2">profiler_line</span><span class="s1">.</span><span class="s2">current_average_label</span><span class="s1">().</span><span class="s4">0 </span><span class="s1">* </span><span class="s2">y_scale</span><span class="s3">;</span>
<a name="l91"><span class="ln">91 </span></a> <span class="s2">draw_list</span><span class="s1">.</span><span class="s2">add_text</span><span class="s1">(</span>
<a name="l92"><span class="ln">92 </span></a> <span class="s1">[</span><span class="s2">text_x</span><span class="s3">, </span><span class="s2">text_y</span><span class="s1">]</span><span class="s3">,</span>
<a name="l93"><span class="ln">93 </span></a> <span class="s1">[</span><span class="s4">1</span><span class="s1">.</span><span class="s4">0</span><span class="s3">, </span><span class="s4">1</span><span class="s1">.</span><span class="s4">0</span><span class="s3">, </span><span class="s4">0</span><span class="s1">.</span><span class="s4">0</span><span class="s3">, </span><span class="s4">1</span><span class="s1">.</span><span class="s4">0</span><span class="s1">]</span><span class="s3">,</span>
<a name="l94"><span class="ln">94 </span></a> <span class="s2">format</span><span class="s1">!(</span>
<a name="l95"><span class="ln">95 </span></a> <span class="s5">&quot;{} {:.0}&quot;</span><span class="s3">,</span>
<a name="l96"><span class="ln">96 </span></a> <span class="s2">profiler_line</span><span class="s1">.</span><span class="s2">current_average_label</span><span class="s1">().</span><span class="s4">1</span><span class="s3">,</span>
<a name="l97"><span class="ln">97 </span></a> <span class="s4">1</span><span class="s1">.</span><span class="s4">0 </span><span class="s1">/ </span><span class="s2">profiler_line</span><span class="s1">.</span><span class="s2">current_average_label</span><span class="s1">().</span><span class="s4">0</span>
<a name="l98"><span class="ln">98 </span></a> <span class="s1">)</span><span class="s3">,</span>
<a name="l99"><span class="ln">99 </span></a> <span class="s1">)</span><span class="s3">;</span>
<a name="l100"><span class="ln">100 </span></a> <span class="s1">}</span>
<a name="l101"><span class="ln">101 </span></a> <span class="s1">}</span><span class="s3">,</span>
<a name="l102"><span class="ln">102 </span></a> <span class="s1">}</span><span class="s3">,</span><span class="s1">))</span><span class="s3">;</span>
<a name="l103"><span class="ln">103 </span></a> <span class="s0">let </span><span class="s2">entity</span><span class="s1">: </span><span class="s2">Entity </span><span class="s1">= </span><span class="s2">cmd</span><span class="s1">.</span><span class="s2">push</span><span class="s1">((</span><span class="s2">ImguiPerformanceProfilerLine</span><span class="s1">::</span><span class="s2">new</span><span class="s1">(</span><span class="s5">&quot;RenderFPS&quot;</span><span class="s1">.</span><span class="s2">to_string</span><span class="s1">())</span><span class="s3">,</span><span class="s1">))</span><span class="s3">;</span>
<a name="l104"><span class="ln">104 </span></a>
<a name="l105"><span class="ln">105 </span></a> <span class="s0">let </span><span class="s2">entity</span><span class="s1">: </span><span class="s2">Entity </span><span class="s1">= </span><span class="s2">cmd</span><span class="s1">.</span><span class="s2">push</span><span class="s1">((</span><span class="s2">ImguiWindow </span><span class="s1">{</span>
<a name="l106"><span class="ln">106 </span></a> <span class="s6">// a window that does everything for the performance profiler</span>
<a name="l107"><span class="ln">107 </span></a> <span class="s2">window</span><span class="s1">: || {</span>
<a name="l108"><span class="ln">108 </span></a> <span class="s2">imgui</span><span class="s1">::</span><span class="s2">Window</span><span class="s1">::</span><span class="s2">new</span><span class="s1">(</span><span class="s2">im_str</span><span class="s1">!(</span><span class="s5">&quot;Generic Output&quot;</span><span class="s1">))</span>
<a name="l109"><span class="ln">109 </span></a> <span class="s1">.</span><span class="s2">size</span><span class="s1">([</span><span class="s4">400</span><span class="s1">.</span><span class="s4">0</span><span class="s3">, </span><span class="s4">500</span><span class="s1">.</span><span class="s4">0</span><span class="s1">]</span><span class="s3">, </span><span class="s2">Condition</span><span class="s1">::</span><span class="s2">FirstUseEver</span><span class="s1">)</span>
<a name="l110"><span class="ln">110 </span></a> <span class="s1">.</span><span class="s2">position</span><span class="s1">([</span><span class="s4">50</span><span class="s1">.</span><span class="s4">0</span><span class="s3">, </span><span class="s4">250</span><span class="s1">.</span><span class="s4">0</span><span class="s1">]</span><span class="s3">, </span><span class="s2">Condition</span><span class="s1">::</span><span class="s2">FirstUseEver</span><span class="s1">)</span>
<a name="l111"><span class="ln">111 </span></a> <span class="s1">}</span><span class="s3">,</span>
<a name="l112"><span class="ln">112 </span></a> <span class="s2">func</span><span class="s1">: |</span><span class="s2">ui</span><span class="s1">: &amp;</span><span class="s2">Ui</span><span class="s3">, </span><span class="s2">a</span><span class="s1">: </span><span class="s2">Vec</span><span class="s1">&lt;&amp;</span><span class="s2">ImguiGenericOutputLine</span><span class="s1">&gt;| {</span>
<a name="l113"><span class="ln">113 </span></a> <span class="s0">for </span><span class="s2">label </span><span class="s0">in </span><span class="s2">a </span><span class="s1">{</span>
<a name="l114"><span class="ln">114 </span></a> <span class="s2">ui</span><span class="s1">.</span><span class="s2">text</span><span class="s1">(</span><span class="s2">im_str</span><span class="s1">!(</span><span class="s5">&quot;{}&quot;</span><span class="s3">, </span><span class="s2">label</span><span class="s1">.</span><span class="s2">label</span><span class="s1">))</span><span class="s3">;</span>
<a name="l115"><span class="ln">115 </span></a> <span class="s1">}</span>
<a name="l116"><span class="ln">116 </span></a> <span class="s1">}</span><span class="s3">,</span>
<a name="l117"><span class="ln">117 </span></a> <span class="s1">}</span><span class="s3">,</span><span class="s1">))</span><span class="s3">;</span>
<a name="l118"><span class="ln">118 </span></a><span class="s1">}</span>
<a name="l119"><span class="ln">119 </span></a>
<a name="l120"><span class="ln">120 </span></a><span class="s1">#[</span><span class="s2">system</span><span class="s1">]</span>
<a name="l121"><span class="ln">121 </span></a><span class="s1">#[</span><span class="s2">write_component</span><span class="s1">(</span><span class="s2">Mesh</span><span class="s1">)]</span>
<a name="l122"><span class="ln">122 </span></a><span class="s0">pub fn </span><span class="s2">runtime_spawn</span><span class="s1">(</span>
<a name="l123"><span class="ln">123 </span></a> <span class="s2">cmd</span><span class="s1">: &amp;</span><span class="s0">mut </span><span class="s2">CommandBuffer</span><span class="s3">,</span>
<a name="l124"><span class="ln">124 </span></a> <span class="s2">world</span><span class="s1">: &amp;</span><span class="s0">mut </span><span class="s2">SubWorld</span><span class="s3">,</span>
<a name="l125"><span class="ln">125 </span></a> <span class="s1">#[</span><span class="s2">resource</span><span class="s1">] </span><span class="s2">runtime_state</span><span class="s1">: &amp;</span><span class="s0">mut </span><span class="s2">RuntimeState</span><span class="s3">,</span>
<a name="l126"><span class="ln">126 </span></a> <span class="s1">#[</span><span class="s2">resource</span><span class="s1">] </span><span class="s2">renderer</span><span class="s1">: &amp;</span><span class="s0">mut </span><span class="s2">RenderState</span><span class="s3">,</span>
<a name="l127"><span class="ln">127 </span></a><span class="s1">) {</span>
<a name="l128"><span class="ln">128 </span></a> <span class="s0">for </span><span class="s2">entity </span><span class="s0">in </span><span class="s1">&amp;</span><span class="s2">runtime_state</span><span class="s1">.</span><span class="s2">get_entities</span><span class="s1">() {</span>
<a name="l129"><span class="ln">129 </span></a> <span class="s0">match </span><span class="s2">entity</span><span class="s1">.</span><span class="s2">type_name</span><span class="s1">.</span><span class="s2">as_ref</span><span class="s1">() {</span>
<a name="l130"><span class="ln">130 </span></a> <span class="s5">&quot;Sprite&quot; </span><span class="s1">=&gt; {</span>
<a name="l131"><span class="ln">131 </span></a>
<a name="l132"><span class="ln">132 </span></a>
<a name="l133"><span class="ln">133 </span></a>
<a name="l134"><span class="ln">134 </span></a> <span class="s0">let </span><span class="s2">mesh_name </span><span class="s1">= </span><span class="s2">entity</span><span class="s1">.</span><span class="s2">mesh</span><span class="s1">.</span><span class="s2">clone</span><span class="s1">().</span><span class="s2">unwrap</span><span class="s1">()</span><span class="s3">;</span>
<a name="l135"><span class="ln">135 </span></a> <span class="s0">let </span><span class="s2">raw_mesh </span><span class="s1">= </span><span class="s0">match </span><span class="s2">runtime_state</span><span class="s1">.</span><span class="s2">get_mesh</span><span class="s1">(</span><span class="s2">mesh_name</span><span class="s1">.</span><span class="s2">as_str</span><span class="s1">()) {</span>
<a name="l136"><span class="ln">136 </span></a> <span class="s2">None </span><span class="s1">=&gt; {</span>
<a name="l137"><span class="ln">137 </span></a> <span class="s2">log</span><span class="s1">::</span><span class="s2">warn</span><span class="s1">!(</span><span class="s5">&quot;Skipping entity with invalid mesh file {:?} &quot;</span><span class="s3">, </span><span class="s2">mesh_name</span><span class="s1">)</span><span class="s3">;</span>
<a name="l138"><span class="ln">138 </span></a> <span class="s0">continue</span><span class="s3">;</span>
<a name="l139"><span class="ln">139 </span></a> <span class="s1">}</span>
<a name="l140"><span class="ln">140 </span></a> <span class="s2">Some</span><span class="s1">(</span><span class="s2">mesh</span><span class="s1">) =&gt; </span><span class="s2">mesh</span><span class="s3">,</span>
<a name="l141"><span class="ln">141 </span></a> <span class="s1">}</span><span class="s3">;</span>
<a name="l142"><span class="ln">142 </span></a>
<a name="l143"><span class="ln">143 </span></a> <span class="s0">let </span><span class="s2">position </span><span class="s1">= </span><span class="s2">Position</span><span class="s1">::</span><span class="s2">from</span><span class="s1">(</span><span class="s2">entity</span><span class="s1">.</span><span class="s2">position</span><span class="s1">.</span><span class="s2">clone</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">static_body </span><span class="s1">= </span><span class="s2">RigidBodyBuilder</span><span class="s1">::</span><span class="s2">new_static</span><span class="s1">()</span>
<a name="l146"><span class="ln">146 </span></a> <span class="s1">.</span><span class="s2">position</span><span class="s1">(</span><span class="s2">Isometry3</span><span class="s1">::</span><span class="s2">new</span><span class="s1">(</span>
<a name="l147"><span class="ln">147 </span></a> <span class="s2">Vector3</span><span class="s1">::</span><span class="s2">new</span><span class="s1">(</span><span class="s2">position</span><span class="s1">.</span><span class="s2">x</span><span class="s3">, </span><span class="s2">position</span><span class="s1">.</span><span class="s2">y</span><span class="s3">, </span><span class="s2">position</span><span class="s1">.</span><span class="s2">z</span><span class="s1">)</span><span class="s3">,</span>
<a name="l148"><span class="ln">148 </span></a> <span class="s2">Vector</span><span class="s1">::</span><span class="s2">y</span><span class="s1">()</span><span class="s3">,</span>
<a name="l149"><span class="ln">149 </span></a> <span class="s1">))</span>
<a name="l150"><span class="ln">150 </span></a> <span class="s1">.</span><span class="s2">build</span><span class="s1">()</span><span class="s3">;</span>
<a name="l151"><span class="ln">151 </span></a>
<a name="l152"><span class="ln">152 </span></a> <span class="s0">let </span><span class="s2">mesh_collider </span><span class="s1">= </span><span class="s2">ColliderBuilder</span><span class="s1">::</span><span class="s2">trimesh</span><span class="s1">(</span>
<a name="l153"><span class="ln">153 </span></a> <span class="s2">raw_mesh</span><span class="s1">.</span><span class="s2">vertices</span><span class="s1">.</span><span class="s2">iter</span><span class="s1">().</span><span class="s2">map</span><span class="s1">(|</span><span class="s2">v</span><span class="s1">| </span><span class="s2">v</span><span class="s1">.</span><span class="s2">position</span><span class="s1">()).</span><span class="s2">collect</span><span class="s1">()</span><span class="s3">,</span>
<a name="l154"><span class="ln">154 </span></a> <span class="s2">raw_mesh</span><span class="s1">.</span><span class="s2">indices</span><span class="s1">.</span><span class="s2">clone</span><span class="s1">()</span><span class="s3">,</span>
<a name="l155"><span class="ln">155 </span></a> <span class="s1">)</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 </span><span class="s2">gpu_mesh_buffer </span><span class="s1">= </span><span class="s2">renderer</span>
<a name="l159"><span class="ln">159 </span></a> <span class="s1">.</span><span class="s2">upload_mesh_to_buffer</span><span class="s1">(</span>
<a name="l160"><span class="ln">160 </span></a> <span class="s2">raw_mesh</span><span class="s3">,</span>
<a name="l161"><span class="ln">161 </span></a> <span class="s2">Some</span><span class="s1">(</span><span class="s2">wgpu</span><span class="s1">::</span><span class="s2">Color </span><span class="s1">{</span>
<a name="l162"><span class="ln">162 </span></a> <span class="s2">r</span><span class="s1">: </span><span class="s4">1</span><span class="s1">.</span><span class="s4">0</span><span class="s3">,</span>
<a name="l163"><span class="ln">163 </span></a> <span class="s2">g</span><span class="s1">: </span><span class="s4">0</span><span class="s1">.</span><span class="s4">7</span><span class="s3">,</span>
<a name="l164"><span class="ln">164 </span></a> <span class="s2">b</span><span class="s1">: </span><span class="s4">0</span><span class="s1">.</span><span class="s4">3</span><span class="s3">,</span>
<a name="l165"><span class="ln">165 </span></a> <span class="s2">a</span><span class="s1">: </span><span class="s4">1</span><span class="s1">.</span><span class="s4">0</span><span class="s3">,</span>
<a name="l166"><span class="ln">166 </span></a> <span class="s1">})</span><span class="s3">,</span>
<a name="l167"><span class="ln">167 </span></a> <span class="s1">)</span>
<a name="l168"><span class="ln">168 </span></a> <span class="s1">.</span><span class="s2">unwrap</span><span class="s1">()</span><span class="s3">;</span>
<a name="l169"><span class="ln">169 </span></a>
<a name="l170"><span class="ln">170 </span></a> <span class="s0">let </span><span class="s2">entity</span><span class="s1">: </span><span class="s2">Entity </span><span class="s1">= </span><span class="s2">cmd</span><span class="s1">.</span><span class="s2">push</span><span class="s1">((</span>
<a name="l171"><span class="ln">171 </span></a> <span class="s2">position</span><span class="s3">,</span>
<a name="l172"><span class="ln">172 </span></a> <span class="s2">gpu_mesh_buffer</span><span class="s3">,</span>
<a name="l173"><span class="ln">173 </span></a> <span class="s2">Physics </span><span class="s1">{</span>
<a name="l174"><span class="ln">174 </span></a> <span class="s2">rigid_body</span><span class="s1">: </span><span class="s2">static_body</span><span class="s3">,</span>
<a name="l175"><span class="ln">175 </span></a> <span class="s2">rigid_body_handle</span><span class="s1">: </span><span class="s2">None</span><span class="s3">,</span>
<a name="l176"><span class="ln">176 </span></a> <span class="s1">}</span><span class="s3">,</span>
<a name="l177"><span class="ln">177 </span></a> <span class="s2">Collider </span><span class="s1">{</span>
<a name="l178"><span class="ln">178 </span></a> <span class="s2">collider</span><span class="s1">: </span><span class="s2">mesh_collider</span><span class="s3">,</span>
<a name="l179"><span class="ln">179 </span></a> <span class="s2">collider_handle</span><span class="s1">: </span><span class="s2">None</span><span class="s3">,</span>
<a name="l180"><span class="ln">180 </span></a> <span class="s1">}</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> <span class="s1">}</span>
<a name="l183"><span class="ln">183 </span></a> <span class="s5">&quot;PhysicsEntity&quot; </span><span class="s1">=&gt; {</span>
<a name="l184"><span class="ln">184 </span></a> <span class="s0">let </span><span class="s2">mesh_name </span><span class="s1">= </span><span class="s2">entity</span><span class="s1">.</span><span class="s2">mesh</span><span class="s1">.</span><span class="s2">as_ref</span><span class="s1">().</span><span class="s2">unwrap</span><span class="s1">()</span><span class="s3">;</span>
<a name="l185"><span class="ln">185 </span></a> <span class="s0">let </span><span class="s2">raw_mesh </span><span class="s1">= </span><span class="s0">match </span><span class="s2">runtime_state</span><span class="s1">.</span><span class="s2">get_mesh</span><span class="s1">(</span><span class="s2">mesh_name</span><span class="s1">.</span><span class="s2">as_str</span><span class="s1">()) {</span>
<a name="l186"><span class="ln">186 </span></a> <span class="s2">None </span><span class="s1">=&gt; {</span>
<a name="l187"><span class="ln">187 </span></a> <span class="s2">log</span><span class="s1">::</span><span class="s2">warn</span><span class="s1">!(</span><span class="s5">&quot;Skipping entity with invalid mesh file {:?} &quot;</span><span class="s3">, </span><span class="s2">mesh_name</span><span class="s1">)</span><span class="s3">;</span>
<a name="l188"><span class="ln">188 </span></a> <span class="s0">continue</span><span class="s3">;</span>
<a name="l189"><span class="ln">189 </span></a> <span class="s1">}</span>
<a name="l190"><span class="ln">190 </span></a> <span class="s2">Some</span><span class="s1">(</span><span class="s2">mesh</span><span class="s1">) =&gt; </span><span class="s2">mesh</span><span class="s3">,</span>
<a name="l191"><span class="ln">191 </span></a> <span class="s1">}</span><span class="s3">;</span>
<a name="l192"><span class="ln">192 </span></a>
<a name="l193"><span class="ln">193 </span></a> <span class="s0">let </span><span class="s2">collider </span><span class="s1">= </span><span class="s2">ColliderBuilder</span><span class="s1">::</span><span class="s2">trimesh</span><span class="s1">(</span>
<a name="l194"><span class="ln">194 </span></a> <span class="s2">raw_mesh</span><span class="s1">.</span><span class="s2">vertices</span><span class="s1">.</span><span class="s2">iter</span><span class="s1">().</span><span class="s2">map</span><span class="s1">(|</span><span class="s2">v</span><span class="s1">| </span><span class="s2">v</span><span class="s1">.</span><span class="s2">position</span><span class="s1">()).</span><span class="s2">collect</span><span class="s1">()</span><span class="s3">,</span>
<a name="l195"><span class="ln">195 </span></a> <span class="s2">raw_mesh</span><span class="s1">.</span><span class="s2">indices</span><span class="s1">.</span><span class="s2">clone</span><span class="s1">()</span><span class="s3">,</span>
<a name="l196"><span class="ln">196 </span></a> <span class="s1">)</span>
<a name="l197"><span class="ln">197 </span></a> <span class="s1">.</span><span class="s2">build</span><span class="s1">()</span><span class="s3">;</span>
<a name="l198"><span class="ln">198 </span></a>
<a name="l199"><span class="ln">199 </span></a> <span class="s0">let </span><span class="s2">collider </span><span class="s1">= </span><span class="s2">ColliderBuilder</span><span class="s1">::</span><span class="s2">capsule_y</span><span class="s1">(</span><span class="s4">2</span><span class="s1">.</span><span class="s4">0</span><span class="s3">, </span><span class="s4">1</span><span class="s1">.</span><span class="s4">0</span><span class="s1">).</span><span class="s2">build</span><span class="s1">()</span><span class="s3">;</span>
<a name="l200"><span class="ln">200 </span></a>
<a name="l201"><span class="ln">201 </span></a> <span class="s0">let </span><span class="s2">gpu_mesh_buffer </span><span class="s1">= </span><span class="s2">renderer</span>
<a name="l202"><span class="ln">202 </span></a> <span class="s1">.</span><span class="s2">upload_mesh_to_buffer</span><span class="s1">(</span>
<a name="l203"><span class="ln">203 </span></a> <span class="s2">raw_mesh</span><span class="s3">,</span>
<a name="l204"><span class="ln">204 </span></a> <span class="s2">Some</span><span class="s1">(</span><span class="s2">wgpu</span><span class="s1">::</span><span class="s2">Color </span><span class="s1">{</span>
<a name="l205"><span class="ln">205 </span></a> <span class="s2">r</span><span class="s1">: </span><span class="s4">1</span><span class="s1">.</span><span class="s4">0</span><span class="s3">,</span>
<a name="l206"><span class="ln">206 </span></a> <span class="s2">g</span><span class="s1">: </span><span class="s4">0</span><span class="s1">.</span><span class="s4">7</span><span class="s3">,</span>
<a name="l207"><span class="ln">207 </span></a> <span class="s2">b</span><span class="s1">: </span><span class="s4">0</span><span class="s1">.</span><span class="s4">3</span><span class="s3">,</span>
<a name="l208"><span class="ln">208 </span></a> <span class="s2">a</span><span class="s1">: </span><span class="s4">1</span><span class="s1">.</span><span class="s4">0</span><span class="s3">,</span>
<a name="l209"><span class="ln">209 </span></a> <span class="s1">})</span><span class="s3">,</span>
<a name="l210"><span class="ln">210 </span></a> <span class="s1">)</span>
<a name="l211"><span class="ln">211 </span></a> <span class="s1">.</span><span class="s2">unwrap</span><span class="s1">()</span><span class="s3">;</span>
<a name="l212"><span class="ln">212 </span></a>
<a name="l213"><span class="ln">213 </span></a> <span class="s0">let </span><span class="s2">position </span><span class="s1">= </span><span class="s2">Position</span><span class="s1">::</span><span class="s2">from</span><span class="s1">(</span><span class="s2">entity</span><span class="s1">.</span><span class="s2">position</span><span class="s1">.</span><span class="s2">clone</span><span class="s1">())</span><span class="s3">;</span>
<a name="l214"><span class="ln">214 </span></a>
<a name="l215"><span class="ln">215 </span></a> <span class="s0">let mut </span><span class="s2">dynamic_body </span><span class="s1">= </span><span class="s2">RigidBodyBuilder</span><span class="s1">::</span><span class="s2">new_dynamic</span><span class="s1">()</span>
<a name="l216"><span class="ln">216 </span></a> <span class="s1">.</span><span class="s2">can_sleep</span><span class="s1">(</span><span class="s0">false</span><span class="s1">)</span>
<a name="l217"><span class="ln">217 </span></a> <span class="s1">.</span><span class="s2">mass</span><span class="s1">(</span><span class="s4">100</span><span class="s1">.</span><span class="s4">0</span><span class="s1">)</span>
<a name="l218"><span class="ln">218 </span></a> <span class="s1">.</span><span class="s2">translation</span><span class="s1">(</span><span class="s2">position</span><span class="s1">.</span><span class="s2">x</span><span class="s3">, </span><span class="s2">position</span><span class="s1">.</span><span class="s2">y</span><span class="s3">, </span><span class="s2">position</span><span class="s1">.</span><span class="s2">z</span><span class="s1">)</span>
<a name="l219"><span class="ln">219 </span></a> <span class="s1">.</span><span class="s2">build</span><span class="s1">()</span><span class="s3">;</span>
<a name="l220"><span class="ln">220 </span></a>
<a name="l221"><span class="ln">221 </span></a> <span class="s0">let </span><span class="s2">entity</span><span class="s1">: </span><span class="s2">Entity </span><span class="s1">= </span><span class="s2">cmd</span><span class="s1">.</span><span class="s2">push</span><span class="s1">((</span>
<a name="l222"><span class="ln">222 </span></a> <span class="s2">position</span><span class="s3">,</span>
<a name="l223"><span class="ln">223 </span></a> <span class="s2">gpu_mesh_buffer</span><span class="s3">,</span>
<a name="l224"><span class="ln">224 </span></a> <span class="s2">Physics </span><span class="s1">{</span>
<a name="l225"><span class="ln">225 </span></a> <span class="s2">rigid_body</span><span class="s1">: </span><span class="s2">dynamic_body</span><span class="s3">,</span>
<a name="l226"><span class="ln">226 </span></a> <span class="s2">rigid_body_handle</span><span class="s1">: </span><span class="s2">None</span><span class="s3">,</span>
<a name="l227"><span class="ln">227 </span></a> <span class="s1">}</span><span class="s3">,</span>
<a name="l228"><span class="ln">228 </span></a> <span class="s2">Collider </span><span class="s1">{</span>
<a name="l229"><span class="ln">229 </span></a> <span class="s2">collider</span><span class="s1">: </span><span class="s2">collider</span><span class="s3">,</span>
<a name="l230"><span class="ln">230 </span></a> <span class="s2">collider_handle</span><span class="s1">: </span><span class="s2">None</span><span class="s3">,</span>
<a name="l231"><span class="ln">231 </span></a> <span class="s1">}</span><span class="s3">,</span>
<a name="l232"><span class="ln">232 </span></a> <span class="s2">ImguiGenericOutputLine</span><span class="s1">::</span><span class="s2">new</span><span class="s1">(</span><span class="s5">&quot;wahoo! from a physics entity&quot;</span><span class="s1">.</span><span class="s2">to_string</span><span class="s1">())</span><span class="s3">,</span>
<a name="l233"><span class="ln">233 </span></a> <span class="s1">))</span><span class="s3">;</span>
<a name="l234"><span class="ln">234 </span></a> <span class="s1">}</span>
<a name="l235"><span class="ln">235 </span></a> <span class="s5">&quot;StaticMesh&quot; </span><span class="s1">=&gt; {</span>
<a name="l236"><span class="ln">236 </span></a> <span class="s0">let </span><span class="s2">mesh_name </span><span class="s1">= </span><span class="s2">entity</span><span class="s1">.</span><span class="s2">mesh</span><span class="s1">.</span><span class="s2">clone</span><span class="s1">().</span><span class="s2">unwrap</span><span class="s1">()</span><span class="s3">;</span>
<a name="l237"><span class="ln">237 </span></a> <span class="s0">let </span><span class="s2">raw_mesh </span><span class="s1">= </span><span class="s0">match </span><span class="s2">runtime_state</span><span class="s1">.</span><span class="s2">get_mesh</span><span class="s1">(</span><span class="s2">mesh_name</span><span class="s1">.</span><span class="s2">as_str</span><span class="s1">()) {</span>
<a name="l238"><span class="ln">238 </span></a> <span class="s2">None </span><span class="s1">=&gt; {</span>
<a name="l239"><span class="ln">239 </span></a> <span class="s2">log</span><span class="s1">::</span><span class="s2">warn</span><span class="s1">!(</span><span class="s5">&quot;Skipping entity with invalid mesh file {:?} &quot;</span><span class="s3">, </span><span class="s2">mesh_name</span><span class="s1">)</span><span class="s3">;</span>
<a name="l240"><span class="ln">240 </span></a> <span class="s0">continue</span><span class="s3">;</span>
<a name="l241"><span class="ln">241 </span></a> <span class="s1">}</span>
<a name="l242"><span class="ln">242 </span></a> <span class="s2">Some</span><span class="s1">(</span><span class="s2">mesh</span><span class="s1">) =&gt; </span><span class="s2">mesh</span><span class="s3">,</span>
<a name="l243"><span class="ln">243 </span></a> <span class="s1">}</span><span class="s3">;</span>
<a name="l244"><span class="ln">244 </span></a>
<a name="l245"><span class="ln">245 </span></a> <span class="s0">let </span><span class="s2">position </span><span class="s1">= </span><span class="s2">Position</span><span class="s1">::</span><span class="s2">from</span><span class="s1">(</span><span class="s2">entity</span><span class="s1">.</span><span class="s2">position</span><span class="s1">.</span><span class="s2">clone</span><span class="s1">())</span><span class="s3">;</span>
<a name="l246"><span class="ln">246 </span></a>
<a name="l247"><span class="ln">247 </span></a> <span class="s0">let mut </span><span class="s2">static_body </span><span class="s1">= </span><span class="s2">RigidBodyBuilder</span><span class="s1">::</span><span class="s2">new_static</span><span class="s1">()</span>
<a name="l248"><span class="ln">248 </span></a> <span class="s1">.</span><span class="s2">position</span><span class="s1">(</span><span class="s2">Isometry3</span><span class="s1">::</span><span class="s2">new</span><span class="s1">(</span>
<a name="l249"><span class="ln">249 </span></a> <span class="s2">Vector3</span><span class="s1">::</span><span class="s2">new</span><span class="s1">(</span><span class="s2">position</span><span class="s1">.</span><span class="s2">x</span><span class="s3">, </span><span class="s2">position</span><span class="s1">.</span><span class="s2">y</span><span class="s3">, </span><span class="s2">position</span><span class="s1">.</span><span class="s2">z</span><span class="s1">)</span><span class="s3">,</span>
<a name="l250"><span class="ln">250 </span></a> <span class="s2">Vector</span><span class="s1">::</span><span class="s2">y</span><span class="s1">()</span><span class="s3">,</span>
<a name="l251"><span class="ln">251 </span></a> <span class="s1">))</span>
<a name="l252"><span class="ln">252 </span></a> <span class="s1">.</span><span class="s2">build</span><span class="s1">()</span><span class="s3">;</span>
<a name="l253"><span class="ln">253 </span></a>
<a name="l254"><span class="ln">254 </span></a> <span class="s0">let </span><span class="s2">mesh_collider </span><span class="s1">= </span><span class="s2">ColliderBuilder</span><span class="s1">::</span><span class="s2">trimesh</span><span class="s1">(</span>
<a name="l255"><span class="ln">255 </span></a> <span class="s2">raw_mesh</span><span class="s1">.</span><span class="s2">vertices</span><span class="s1">.</span><span class="s2">iter</span><span class="s1">().</span><span class="s2">map</span><span class="s1">(|</span><span class="s2">v</span><span class="s1">| </span><span class="s2">v</span><span class="s1">.</span><span class="s2">position</span><span class="s1">()).</span><span class="s2">collect</span><span class="s1">()</span><span class="s3">,</span>
<a name="l256"><span class="ln">256 </span></a> <span class="s2">raw_mesh</span><span class="s1">.</span><span class="s2">indices</span><span class="s1">.</span><span class="s2">clone</span><span class="s1">()</span><span class="s3">,</span>
<a name="l257"><span class="ln">257 </span></a> <span class="s1">)</span>
<a name="l258"><span class="ln">258 </span></a> <span class="s1">.</span><span class="s2">build</span><span class="s1">()</span><span class="s3">;</span>
<a name="l259"><span class="ln">259 </span></a>
<a name="l260"><span class="ln">260 </span></a> <span class="s0">let </span><span class="s2">gpu_mesh_buffer </span><span class="s1">= </span><span class="s2">renderer</span>
<a name="l261"><span class="ln">261 </span></a> <span class="s1">.</span><span class="s2">upload_mesh_to_buffer</span><span class="s1">(</span>
<a name="l262"><span class="ln">262 </span></a> <span class="s2">raw_mesh</span><span class="s3">,</span>
<a name="l263"><span class="ln">263 </span></a> <span class="s2">Some</span><span class="s1">(</span><span class="s2">wgpu</span><span class="s1">::</span><span class="s2">Color </span><span class="s1">{</span>
<a name="l264"><span class="ln">264 </span></a> <span class="s2">r</span><span class="s1">: </span><span class="s4">1</span><span class="s1">.</span><span class="s4">0</span><span class="s3">,</span>
<a name="l265"><span class="ln">265 </span></a> <span class="s2">g</span><span class="s1">: </span><span class="s4">0</span><span class="s1">.</span><span class="s4">7</span><span class="s3">,</span>
<a name="l266"><span class="ln">266 </span></a> <span class="s2">b</span><span class="s1">: </span><span class="s4">0</span><span class="s1">.</span><span class="s4">3</span><span class="s3">,</span>
<a name="l267"><span class="ln">267 </span></a> <span class="s2">a</span><span class="s1">: </span><span class="s4">1</span><span class="s1">.</span><span class="s4">0</span><span class="s3">,</span>
<a name="l268"><span class="ln">268 </span></a> <span class="s1">})</span><span class="s3">,</span>
<a name="l269"><span class="ln">269 </span></a> <span class="s1">)</span>
<a name="l270"><span class="ln">270 </span></a> <span class="s1">.</span><span class="s2">unwrap</span><span class="s1">()</span><span class="s3">;</span>
<a name="l271"><span class="ln">271 </span></a>
<a name="l272"><span class="ln">272 </span></a> <span class="s0">let </span><span class="s2">entity</span><span class="s1">: </span><span class="s2">Entity </span><span class="s1">= </span><span class="s2">cmd</span><span class="s1">.</span><span class="s2">push</span><span class="s1">((</span>
<a name="l273"><span class="ln">273 </span></a> <span class="s2">position</span><span class="s3">,</span>
<a name="l274"><span class="ln">274 </span></a> <span class="s2">gpu_mesh_buffer</span><span class="s3">,</span>
<a name="l275"><span class="ln">275 </span></a> <span class="s2">Physics </span><span class="s1">{</span>
<a name="l276"><span class="ln">276 </span></a> <span class="s2">rigid_body</span><span class="s1">: </span><span class="s2">static_body</span><span class="s3">,</span>
<a name="l277"><span class="ln">277 </span></a> <span class="s2">rigid_body_handle</span><span class="s1">: </span><span class="s2">None</span><span class="s3">,</span>
<a name="l278"><span class="ln">278 </span></a> <span class="s1">}</span><span class="s3">,</span>
<a name="l279"><span class="ln">279 </span></a> <span class="s2">Collider </span><span class="s1">{</span>
<a name="l280"><span class="ln">280 </span></a> <span class="s2">collider</span><span class="s1">: </span><span class="s2">mesh_collider</span><span class="s3">,</span>
<a name="l281"><span class="ln">281 </span></a> <span class="s2">collider_handle</span><span class="s1">: </span><span class="s2">None</span><span class="s3">,</span>
<a name="l282"><span class="ln">282 </span></a> <span class="s1">}</span><span class="s3">,</span>
<a name="l283"><span class="ln">283 </span></a> <span class="s1">))</span><span class="s3">;</span>
<a name="l284"><span class="ln">284 </span></a> <span class="s1">}</span>
<a name="l285"><span class="ln">285 </span></a> <span class="s5">&quot;Camera&quot; </span><span class="s1">=&gt; {</span>
<a name="l286"><span class="ln">286 </span></a> <span class="s0">let </span><span class="s2">position </span><span class="s1">= </span><span class="s2">Position</span><span class="s1">::</span><span class="s2">from</span><span class="s1">(</span><span class="s2">entity</span><span class="s1">.</span><span class="s2">position</span><span class="s1">.</span><span class="s2">clone</span><span class="s1">())</span><span class="s3">;</span>
<a name="l287"><span class="ln">287 </span></a> <span class="s0">let </span><span class="s2">entity</span><span class="s1">: </span><span class="s2">Entity </span><span class="s1">= </span><span class="s2">cmd</span><span class="s1">.</span><span class="s2">push</span><span class="s1">((</span>
<a name="l288"><span class="ln">288 </span></a> <span class="s2">Camera </span><span class="s1">{</span>
<a name="l289"><span class="ln">289 </span></a> <span class="s2">position</span><span class="s1">: </span><span class="s2">cgmath</span><span class="s1">::</span><span class="s2">Point3 </span><span class="s1">{</span>
<a name="l290"><span class="ln">290 </span></a> <span class="s2">x</span><span class="s1">: </span><span class="s2">position</span><span class="s1">.</span><span class="s2">x</span><span class="s3">,</span>
<a name="l291"><span class="ln">291 </span></a> <span class="s2">y</span><span class="s1">: </span><span class="s2">position</span><span class="s1">.</span><span class="s2">y</span><span class="s3">,</span>
<a name="l292"><span class="ln">292 </span></a> <span class="s2">z</span><span class="s1">: </span><span class="s2">position</span><span class="s1">.</span><span class="s2">z</span><span class="s3">,</span>
<a name="l293"><span class="ln">293 </span></a> <span class="s1">}</span><span class="s3">,</span>
<a name="l294"><span class="ln">294 </span></a> <span class="s2">yaw</span><span class="s1">: </span><span class="s2">Rad</span><span class="s1">(</span><span class="s2">PI </span><span class="s1">/ </span><span class="s4">2</span><span class="s1">.</span><span class="s4">0</span><span class="s1">)</span><span class="s3">,</span>
<a name="l295"><span class="ln">295 </span></a> <span class="s2">pitch</span><span class="s1">: </span><span class="s2">Rad</span><span class="s1">(</span><span class="s2">PI </span><span class="s1">/ </span><span class="s4">2</span><span class="s1">.</span><span class="s4">0 </span><span class="s1">+ </span><span class="s4">25</span><span class="s1">.</span><span class="s4">0</span><span class="s1">)</span><span class="s3">,</span>
<a name="l296"><span class="ln">296 </span></a> <span class="s1">}</span><span class="s3">,</span>
<a name="l297"><span class="ln">297 </span></a> <span class="s2">CameraController</span><span class="s1">::</span><span class="s2">new</span><span class="s1">(</span><span class="s4">5</span><span class="s1">.</span><span class="s4">0</span><span class="s3">, </span><span class="s4">1</span><span class="s1">.</span><span class="s4">0</span><span class="s1">)</span><span class="s3">,</span>
<a name="l298"><span class="ln">298 </span></a> <span class="s2">ImguiGenericOutputLine</span><span class="s1">::</span><span class="s2">new</span><span class="s1">(</span><span class="s5">&quot;wahoo! from a camera&quot;</span><span class="s1">.</span><span class="s2">to_string</span><span class="s1">())</span><span class="s3">,</span>
<a name="l299"><span class="ln">299 </span></a> <span class="s1">))</span><span class="s3">;</span>
<a name="l300"><span class="ln">300 </span></a> <span class="s1">}</span>
<a name="l301"><span class="ln">301 </span></a> <span class="s5">&quot;Light&quot; </span><span class="s1">=&gt; {</span>
<a name="l302"><span class="ln">302 </span></a> <span class="s0">let </span><span class="s2">mesh_name </span><span class="s1">= </span><span class="s2">entity</span><span class="s1">.</span><span class="s2">mesh</span><span class="s1">.</span><span class="s2">clone</span><span class="s1">().</span><span class="s2">unwrap</span><span class="s1">()</span><span class="s3">;</span>
<a name="l303"><span class="ln">303 </span></a> <span class="s0">let </span><span class="s2">raw_mesh </span><span class="s1">= </span><span class="s0">match </span><span class="s2">runtime_state</span><span class="s1">.</span><span class="s2">get_mesh</span><span class="s1">(</span><span class="s2">mesh_name</span><span class="s1">.</span><span class="s2">as_str</span><span class="s1">()) {</span>
<a name="l304"><span class="ln">304 </span></a> <span class="s2">None </span><span class="s1">=&gt; {</span>
<a name="l305"><span class="ln">305 </span></a> <span class="s2">log</span><span class="s1">::</span><span class="s2">warn</span><span class="s1">!(</span><span class="s5">&quot;Skipping entity with invalid mesh file {:?} &quot;</span><span class="s3">, </span><span class="s2">mesh_name</span><span class="s1">)</span><span class="s3">;</span>
<a name="l306"><span class="ln">306 </span></a> <span class="s0">continue</span><span class="s3">;</span>
<a name="l307"><span class="ln">307 </span></a> <span class="s1">}</span>
<a name="l308"><span class="ln">308 </span></a> <span class="s2">Some</span><span class="s1">(</span><span class="s2">mesh</span><span class="s1">) =&gt; </span><span class="s2">mesh</span><span class="s3">,</span>
<a name="l309"><span class="ln">309 </span></a> <span class="s1">}</span><span class="s3">;</span>
<a name="l310"><span class="ln">310 </span></a>
<a name="l311"><span class="ln">311 </span></a> <span class="s0">let </span><span class="s2">position </span><span class="s1">= </span><span class="s2">Position</span><span class="s1">::</span><span class="s2">from</span><span class="s1">(</span><span class="s2">entity</span><span class="s1">.</span><span class="s2">position</span><span class="s1">.</span><span class="s2">clone</span><span class="s1">())</span><span class="s3">;</span>
<a name="l312"><span class="ln">312 </span></a>
<a name="l313"><span class="ln">313 </span></a> <span class="s0">let </span><span class="s2">gpu_mesh_buffer </span><span class="s1">= </span><span class="s2">renderer</span>
<a name="l314"><span class="ln">314 </span></a> <span class="s1">.</span><span class="s2">upload_mesh_to_buffer</span><span class="s1">(</span>
<a name="l315"><span class="ln">315 </span></a> <span class="s2">raw_mesh</span><span class="s3">,</span>
<a name="l316"><span class="ln">316 </span></a> <span class="s2">Some</span><span class="s1">(</span><span class="s2">wgpu</span><span class="s1">::</span><span class="s2">Color </span><span class="s1">{</span>
<a name="l317"><span class="ln">317 </span></a> <span class="s2">r</span><span class="s1">: </span><span class="s4">1</span><span class="s1">.</span><span class="s4">0</span><span class="s3">,</span>
<a name="l318"><span class="ln">318 </span></a> <span class="s2">g</span><span class="s1">: </span><span class="s4">0</span><span class="s1">.</span><span class="s4">7</span><span class="s3">,</span>
<a name="l319"><span class="ln">319 </span></a> <span class="s2">b</span><span class="s1">: </span><span class="s4">0</span><span class="s1">.</span><span class="s4">3</span><span class="s3">,</span>
<a name="l320"><span class="ln">320 </span></a> <span class="s2">a</span><span class="s1">: </span><span class="s4">1</span><span class="s1">.</span><span class="s4">0</span><span class="s3">,</span>
<a name="l321"><span class="ln">321 </span></a> <span class="s1">})</span><span class="s3">,</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><span class="s2">unwrap</span><span class="s1">()</span><span class="s3">;</span>
<a name="l324"><span class="ln">324 </span></a>
<a name="l325"><span class="ln">325 </span></a> <span class="s0">let </span><span class="s2">light_entity</span><span class="s1">: </span><span class="s2">Entity </span><span class="s1">=</span>
<a name="l326"><span class="ln">326 </span></a> <span class="s2">cmd</span><span class="s1">.</span><span class="s2">push</span><span class="s1">((</span><span class="s2">position</span><span class="s3">, </span><span class="s2">gpu_mesh_buffer</span><span class="s3">, </span><span class="s2">renderer</span><span class="s1">.</span><span class="s2">create_light</span><span class="s1">()))</span><span class="s3">;</span>
<a name="l327"><span class="ln">327 </span></a> <span class="s1">}</span>
<a name="l328"><span class="ln">328 </span></a>
<a name="l329"><span class="ln">329 </span></a> <span class="s2">_ </span><span class="s1">=&gt; {}</span>
<a name="l330"><span class="ln">330 </span></a> <span class="s1">}</span>
<a name="l331"><span class="ln">331 </span></a> <span class="s1">}</span>
<a name="l332"><span class="ln">332 </span></a><span class="s1">}</span>
<a name="l333"><span class="ln">333 </span></a></pre>
</body>
</html>

Before

Width:  |  Height:  |  Size: 3.0 MiB

After

Width:  |  Height:  |  Size: 3.0 MiB

@ -0,0 +1,13 @@
# Blender MTL File: 'None'
# Material Count: 1
newmtl Material.002
Ns 225.000000
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.450000
d 1.000000
illum 2
map_Kd /Users/mitchellhansen/source/minimum-viable-game-engine/resources/test.jpg

@ -0,0 +1,18 @@
# Blender v2.93.1 OBJ File: ''
# www.blender.org
mtllib texture-test-1.mtl
o Plane_Plane.001
v -1.000000 0.000000 1.000000
v 1.000000 0.000000 1.000000
v -1.000000 0.000000 -1.000000
v 1.000000 0.000000 -1.000000
vt 1.000000 0.000000
vt 0.000000 1.000000
vt 0.000000 0.000000
vt 1.000000 1.000000
vn 0.0000 1.0000 0.0000
g Plane_Plane.001_Material.002
usemtl Material.002
s off
f 2/1/1 3/2/1 1/3/1
f 2/1/1 4/4/1 3/2/1

@ -0,0 +1,12 @@
# Blender MTL File: 'None'
# Material Count: 1
newmtl Material.001
Ns 323.999994
Ka 1.000000 1.000000 1.000000
Kd 0.800000 0.800000 0.800000
Ks 0.500000 0.500000 0.500000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 2

@ -0,0 +1,17 @@
# Blender v2.93.1 OBJ File: ''
# www.blender.org
mtllib textured-plane.mtl
o Plane
v -1.000000 0.000000 1.000000
v 1.000000 0.000000 1.000000
v -1.000000 0.000000 -1.000000
v 1.000000 0.000000 -1.000000
vt 1.000000 0.000000
vt 0.000000 1.000000
vt 0.000000 0.000000
vt 1.000000 1.000000
vn 0.0000 1.0000 0.0000
usemtl Material.001
s off
f 2/1/1 3/2/1 1/3/1
f 2/1/1 4/4/1 3/2/1

@ -10,8 +10,9 @@ use wgpu::{BindGroup, Buffer, TextureView};
use crate::runtime::state::{TomlPositionDescription, TomlRotationDescription}; use crate::runtime::state::{TomlPositionDescription, TomlRotationDescription};
use imgui::Ui; use imgui::Ui;
// a component is any type that is 'static, sized, send and sync /// a component is any type that is 'static, sized, send and sync
/// ImguiWindow contains a single handle and lifetime to an Imgui window, along with
/// a function which takes a UI, as well as a vector of a user defined type T
pub struct ImguiWindow<'a, T> { pub struct ImguiWindow<'a, T> {
pub window: fn() -> imgui::Window<'a>, pub window: fn() -> imgui::Window<'a>,
pub func: fn(&Ui, Vec<&T>), pub func: fn(&Ui, Vec<&T>),

@ -35,6 +35,8 @@ pub struct RawMesh {
} }
/// We use meshes in a few different places. To keep things simple, we return /// We use meshes in a few different places. To keep things simple, we return
/// the most basic, direct-to-memory version. If something fancy needs to be done /// the most basic, direct-to-memory version. If something fancy needs to be done
/// with it, the fancy stays there /// with it, the fancy stays there
@ -58,6 +60,11 @@ pub fn load_obj(obj_path: &str) -> Result<RawMesh, String> {
for model in models { for model in models {
let mesh = &model.mesh; let mesh = &model.mesh;
if let Some(mat_id) = mesh.material_id {
let mat : &Material = materials.get(mat_id).unwrap();
println!("{:?}", mat);
}
// Cycle through the faces and chunk out the indices // Cycle through the faces and chunk out the indices
let mut next_face = 0; let mut next_face = 0;
for f in 0..mesh.num_face_indices.len() { for f in 0..mesh.num_face_indices.len() {
@ -112,3 +119,28 @@ pub fn load_obj(obj_path: &str) -> Result<RawMesh, String> {
indices: index_data.to_vec(), indices: index_data.to_vec(),
}) })
} }
// pub fn create_quad_mesh() -> RawMesh {
//
// let mut index_data: Vec<[u32; 3]> = Vec::new();
// let mut vertex_data = Vec::new();
//
// vertex_data.push(Vertex::from(
// [
// mesh.positions[3 * v],
// mesh.positions[3 * v + 1],
// mesh.positions[3 * v + 2],
// ],
// [
// mesh.normals[3 * v],
// mesh.normals[3 * v + 1],
// mesh.normals[3 * v + 2],
// ],
// [mesh.texcoords[2 * v], mesh.texcoords[2 * v + 1]],
// ));
//
// RawMesh {
// vertices: vertex_data.to_vec(),
// indices: index_data.to_vec(),
// }
// }

@ -99,20 +99,38 @@ ECS
entities & behaviours (got the entities!) entities & behaviours (got the entities!)
scripting! scripting!
Todo: Todo:
Load scene imgui interface w/ toml files Load scene imgui interface w/ toml files
FPS graph port from voxel raycaster This means a scene graph
better imgui interface with components & systems better imgui interface with components & systems
Figure out eventing, GameInput, passing all events, etc. Figure out eventing, GameInput, passing all events, etc.
+ texturing + texturing
I need to figure out the way that I want to do 2d graphics in a 3d engine...
I suppose I will need sprites. And those are just 2 polygons which are textured
*/ */
/**
Notes:
(Im)GUI,
* I have to hold onto an ImGUI window and it's lifetime
* I have to execute a bunch of function calls to build
the immediate mode UI each and every frame
It looks like my solution was to have an entity describing
the window
*/
//log::info!(""); //log::info!("");
// ImGUI works on more or less an unsafe global state. which is MegaLame /// ImGUI works on more or less an unsafe global state. which is MegaLame
static mut CURRENT_UI: Option<imgui::Ui<'static>> = None; static mut CURRENT_UI: Option<imgui::Ui<'static>> = None;
pub unsafe fn current_ui<'a>() -> Option<&'a imgui::Ui<'a>> { pub unsafe fn current_ui<'a>() -> Option<&'a imgui::Ui<'a>> {
CURRENT_UI.as_ref() CURRENT_UI.as_ref()
@ -139,7 +157,7 @@ fn main() {
let mut render_schedule = Schedule::builder() let mut render_schedule = Schedule::builder()
.add_system(render::system::render_imgui_system()) .add_system(render::system::render_imgui_system())
.add_system(render::system::render_test_system()) .add_system(render::system::render_function_system())
.add_system(render::system::render_performance_flag_system()) .add_system(render::system::render_performance_flag_system())
.build(); .build();

@ -12,15 +12,18 @@ use rapier3d::pipeline::PhysicsPipeline;
use crate::camera::{Camera, CameraController}; use crate::camera::{Camera, CameraController};
use crate::components::{Collider, LoopState, Mesh, Physics, Position}; use crate::components::{Collider, LoopState, Mesh, Physics, Position};
use imgui::FontSource; use imgui::FontSource;
use rapier3d::prelude::{IslandManager, CCDSolver};
pub struct PhysicsState { pub struct PhysicsState {
pub(in crate::physics) gravity: rapier3d::math::Vector<f32>, pub(in crate::physics) gravity: rapier3d::math::Vector<f32>,
pub(in crate::physics) integration_parameters: IntegrationParameters, pub(in crate::physics) integration_parameters: IntegrationParameters,
pub(in crate::physics) island_manager: IslandManager,
pub(in crate::physics) broad_phase: BroadPhase, pub(in crate::physics) broad_phase: BroadPhase,
pub(in crate::physics) narrow_phase: NarrowPhase, pub(in crate::physics) narrow_phase: NarrowPhase,
pub(in crate::physics) bodies: RigidBodySet, pub(in crate::physics) bodies: RigidBodySet,
pub(in crate::physics) colliders: ColliderSet, pub(in crate::physics) colliders: ColliderSet,
pub(in crate::physics) joints: JointSet, pub(in crate::physics) joints: JointSet,
pub(in crate::physics) ccd_solver: CCDSolver,
} }
impl PhysicsState { impl PhysicsState {
@ -30,11 +33,13 @@ impl PhysicsState {
PhysicsState { PhysicsState {
gravity, gravity,
integration_parameters: IntegrationParameters::default(), integration_parameters: IntegrationParameters::default(),
island_manager: IslandManager::new(),
broad_phase: BroadPhase::new(), broad_phase: BroadPhase::new(),
narrow_phase: NarrowPhase::new(), narrow_phase: NarrowPhase::new(),
bodies: RigidBodySet::new(), bodies: RigidBodySet::new(),
colliders: ColliderSet::new(), colliders: ColliderSet::new(),
joints: JointSet::new(), joints: JointSet::new(),
ccd_solver: CCDSolver::new(),
}, },
) )
} }

@ -38,7 +38,7 @@ pub fn run_physics(
Some(handle) => handle, Some(handle) => handle,
}; };
if collider.collider_handle == None { if collider.collider_handle == None {
let handle = physics_state.colliders.insert( let handle = physics_state.colliders.insert_with_parent(
collider.collider.clone(), collider.collider.clone(),
rigid_body_handle, rigid_body_handle,
&mut physics_state.bodies, &mut physics_state.bodies,
@ -56,13 +56,14 @@ pub fn run_physics(
physics_pipeline.step( physics_pipeline.step(
&physics_state.gravity, &physics_state.gravity,
&physics_state.integration_parameters, &physics_state.integration_parameters,
&mut physics_state.island_manager,
&mut physics_state.broad_phase, &mut physics_state.broad_phase,
&mut physics_state.narrow_phase, &mut physics_state.narrow_phase,
&mut physics_state.bodies, &mut physics_state.bodies,
&mut physics_state.colliders, &mut physics_state.colliders,
&mut physics_state.joints, &mut physics_state.joints,
None, &mut physics_state.ccd_solver,
None, &(),
&event_handler, &event_handler,
); );
@ -105,6 +106,8 @@ pub fn update_models(
) { ) {
// Make sure all the entities we care about are added to the system // Make sure all the entities we care about are added to the system
// TODO add scenegraph component to compare against
// allows per node rotation, better logging
let mut query = <(&mut Collider, &mut Physics, &mut Mesh, &mut Position)>::query(); let mut query = <(&mut Collider, &mut Physics, &mut Mesh, &mut Position)>::query();
for (collider, physics, mesh, position) in query.iter_mut(world) { for (collider, physics, mesh, position) in query.iter_mut(world) {
let pos = physics_state let pos = physics_state

@ -16,7 +16,6 @@ use imgui::*;
use imgui_wgpu::{Renderer as ImguiRenderer, RendererConfig as ImguiRendererConfig}; use imgui_wgpu::{Renderer as ImguiRenderer, RendererConfig as ImguiRendererConfig};
use legion::world::SubWorld; use legion::world::SubWorld;
use legion::*; use legion::*;
use rapier3d::parry::motion::RigidMotionComposition;
use wgpu::util::DeviceExt; use wgpu::util::DeviceExt;
use wgpu::{BackendBit, BindGroup, BindGroupLayout, Buffer, BufferBindingType, Device, FragmentState, Instance, Queue, Surface, SwapChain, SwapChainDescriptor, SwapChainFrame, TextureView, VertexState, CommandEncoder}; use wgpu::{BackendBit, BindGroup, BindGroupLayout, Buffer, BufferBindingType, Device, FragmentState, Instance, Queue, Surface, SwapChain, SwapChainDescriptor, SwapChainFrame, TextureView, VertexState, CommandEncoder};
use winit_24::dpi::PhysicalSize; use winit_24::dpi::PhysicalSize;
@ -290,11 +289,6 @@ impl RenderState {
}], }],
}); });
/*
There appear to be two passes required for shadows, the shadow pass, and the forward pass
Need to open this up in renderdoc and see what it's actually doing
*/
let shadow_pass = { let shadow_pass = {
let uniform_size = mem::size_of::<ShadowUniforms>() as wgpu::BufferAddress; let uniform_size = mem::size_of::<ShadowUniforms>() as wgpu::BufferAddress;

@ -18,7 +18,6 @@ use imgui::*;
use imgui_wgpu::{Renderer as ImguiRenderer, RendererConfig as ImguiRendererConfig}; use imgui_wgpu::{Renderer as ImguiRenderer, RendererConfig as ImguiRendererConfig};
use legion::world::SubWorld; use legion::world::SubWorld;
use legion::*; use legion::*;
use rapier3d::parry::motion::RigidMotionComposition;
use wgpu::util::DeviceExt; use wgpu::util::DeviceExt;
use wgpu::{ use wgpu::{
BackendBit, BindGroup, BindGroupLayout, Buffer, BufferBindingType, CommandEncoder, Device, BackendBit, BindGroup, BindGroupLayout, Buffer, BufferBindingType, CommandEncoder, Device,
@ -39,6 +38,7 @@ use crate::render::{
insert_debug_marker_checked, pop_debug_group_checked, push_debug_group_checked, EntityUniforms, insert_debug_marker_checked, pop_debug_group_checked, push_debug_group_checked, EntityUniforms,
}; };
#[system] #[system]
#[write_component(Camera)] #[write_component(Camera)]
pub fn imgui_prepare( pub fn imgui_prepare(
@ -80,6 +80,7 @@ fn run_imgui_render_step<G: 'static + Sized + Send + Sync>(world: &mut SubWorld,
.build(&ui, || (window_func.unwrap())(ui, v)); .build(&ui, || (window_func.unwrap())(ui, v));
} }
} }
/// Go through each "global" window-data component and render it's data /// Go through each "global" window-data component and render it's data
#[system] #[system]
#[write_component(ImguiWindow<ImguiPerformanceProfilerLine>)] #[write_component(ImguiWindow<ImguiPerformanceProfilerLine>)]
@ -87,13 +88,33 @@ fn run_imgui_render_step<G: 'static + Sized + Send + Sync>(world: &mut SubWorld,
#[write_component(ImguiWindow<ImguiGenericOutputLine>)] #[write_component(ImguiWindow<ImguiGenericOutputLine>)]
#[write_component(ImguiGenericOutputLine)] #[write_component(ImguiGenericOutputLine)]
pub fn render_imgui(world: &mut SubWorld, #[resource] loop_state: &mut LoopState) { pub fn render_imgui(world: &mut SubWorld, #[resource] loop_state: &mut LoopState) {
// This is a global that we have to grab for imgui
let ui = unsafe { crate::current_ui().unwrap() }; let ui = unsafe { crate::current_ui().unwrap() };
// Pull out the window associated with this type, and render each of the components in the sytem // Pull out the window associated with this type, and render each of the components in the system
run_imgui_render_step::<ImguiGenericOutputLine>(world, &ui); run_imgui_render_step::<ImguiGenericOutputLine>(world, &ui);
run_imgui_render_step::<ImguiPerformanceProfilerLine>(world, &ui); run_imgui_render_step::<ImguiPerformanceProfilerLine>(world, &ui);
} }
/**
Oh boy, now I need to remember this interface that I wrote...
The (Im)GUI System
* Each window is a static type, like ImguiGenericOutputLine, and ImguiPerformanceProfilerLine.
* Each window is also an entity that we do a query on
*/
// This would be the shared state for all imgui generic output things // This would be the shared state for all imgui generic output things
pub struct ImguiGenericOutputLine { pub struct ImguiGenericOutputLine {
pub label: String, pub label: String,
@ -114,6 +135,7 @@ pub struct ImguiPerformanceProfilerLine {
pub scale_max: f32, pub scale_max: f32,
} }
/// Adding samples, iterating, and calculating profiler lines
impl ImguiPerformanceProfilerLine { impl ImguiPerformanceProfilerLine {
fn add_sample(&mut self, sample: f32) { fn add_sample(&mut self, sample: f32) {
self.list_of_fps[self.index] = sample; self.list_of_fps[self.index] = sample;
@ -160,6 +182,7 @@ impl ImguiPerformanceProfilerLine {
} }
} }
/// Take the current delta time from the loop state and add it to the profile line
#[system] #[system]
#[write_component(ImguiPerformanceProfilerLine)] #[write_component(ImguiPerformanceProfilerLine)]
pub fn render_performance_flag(world: &mut SubWorld, #[resource] loop_state: &mut LoopState) { pub fn render_performance_flag(world: &mut SubWorld, #[resource] loop_state: &mut LoopState) {
@ -178,7 +201,7 @@ pub fn render_performance_flag(world: &mut SubWorld, #[resource] loop_state: &mu
#[write_component(Point3<f32>)] #[write_component(Point3<f32>)]
#[write_component(Mesh)] #[write_component(Mesh)]
#[write_component(DirectionalLight)] #[write_component(DirectionalLight)]
pub fn render_test( pub fn render_function(
world: &mut SubWorld, world: &mut SubWorld,
#[resource] loop_state: &mut LoopState, #[resource] loop_state: &mut LoopState,
#[resource] renderer: &mut RenderState, #[resource] renderer: &mut RenderState,
@ -334,6 +357,7 @@ pub fn render_test(
pass.draw_indexed(0..mesh.index_count as u32, 0, 0..1); pass.draw_indexed(0..mesh.index_count as u32, 0, 0..1);
} }
} }
pop_debug_group_checked(&mut encoder); pop_debug_group_checked(&mut encoder);
pop_debug_group_checked(&mut encoder); pop_debug_group_checked(&mut encoder);

@ -16,7 +16,7 @@ use crate::camera::{Camera, CameraController};
use crate::components::{Collider, LoopState, Mesh, Physics, Position}; use crate::components::{Collider, LoopState, Mesh, Physics, Position};
use crate::geometry::{load_obj, RawMesh}; use crate::geometry::{load_obj, RawMesh};
use std::io::Read; use std::io::Read;
use imgui_wgpu::Texture;
#[derive(Deserialize, Clone)] #[derive(Deserialize, Clone)]
@ -71,8 +71,28 @@ pub struct TomlEntityContainer {
pub struct RuntimeState { pub struct RuntimeState {
config_db: TomlEntityContainer, config_db: TomlEntityContainer,
mesh_cache: HashMap<String, RawMesh>, mesh_cache: HashMap<String, RawMesh>,
texture_cache: HashMap<String, RawMesh>,
}
pub struct Model {
pub meshes: Vec<RawMesh>,
pub materials: Vec<Material>,
}
pub struct Material {
pub name: String,
pub diffuse_texture: Texture,
} }
// pub struct Mesh {
// pub name: String,
// pub vertex_buffer: wgpu::Buffer,
// pub index_buffer: wgpu::Buffer,
// pub num_elements: u32,
// pub material: usize,
// }
impl RuntimeState { impl RuntimeState {
pub fn new() -> RuntimeState { pub fn new() -> RuntimeState {
// TODO: Hook this file to the gui // TODO: Hook this file to the gui
@ -86,6 +106,7 @@ impl RuntimeState {
RuntimeState { RuntimeState {
config_db: settings, config_db: settings,
mesh_cache: Default::default(), mesh_cache: Default::default(),
texture_cache: Default::default(),
} }
} }

@ -19,11 +19,12 @@ use rapier3d::pipeline::{ChannelEventCollector, PhysicsPipeline};
use crate::camera::{Camera, CameraController}; use crate::camera::{Camera, CameraController};
use crate::components::{Collider, ImguiWindow, LoopState, Mesh, Physics, Position}; use crate::components::{Collider, ImguiWindow, LoopState, Mesh, Physics, Position};
use crate::geometry::RawMesh; use crate::geometry;
use crate::physics::state::PhysicsState; use crate::physics::state::PhysicsState;
use crate::render::state::RenderState; use crate::render::state::RenderState;
use crate::render::system::{ImguiGenericOutputLine, ImguiPerformanceProfilerLine}; use crate::render::system::{ImguiGenericOutputLine, ImguiPerformanceProfilerLine};
use crate::runtime::state::RuntimeState; use crate::runtime::state::RuntimeState;
use crate::geometry::RawMesh;
pub fn quad_color(color: [f32; 4]) -> [[f32; 4]; 4] { pub fn quad_color(color: [f32; 4]) -> [[f32; 4]; 4] {
[color, color, color, color] [color, color, color, color]
@ -126,6 +127,59 @@ pub fn runtime_spawn(
) { ) {
for entity in &runtime_state.get_entities() { for entity in &runtime_state.get_entities() {
match entity.type_name.as_ref() { match entity.type_name.as_ref() {
// "Sprite" => {
//
//
//
// let mesh_name = entity.mesh.clone().unwrap();
// let raw_mesh = match runtime_state.get_mesh(mesh_name.as_str()) {
// None => {
// log::warn!("Skipping entity with invalid mesh file {:?} ", mesh_name);
// continue;
// }
// Some(mesh) => mesh,
// };
//
// let position = Position::from(entity.position.clone());
//
// let mut static_body = RigidBodyBuilder::new_static()
// .position(Isometry3::new(
// Vector3::new(position.x, position.y, position.z),
// Vector::y(),
// ))
// .build();
//
// let mesh_collider = ColliderBuilder::trimesh(
// raw_mesh.vertices.iter().map(|v| v.position()).collect(),
// raw_mesh.indices.clone(),
// )
// .build();
//
// let gpu_mesh_buffer = renderer
// .upload_mesh_to_buffer(
// raw_mesh,
// Some(wgpu::Color {
// r: 1.0,
// g: 0.7,
// b: 0.3,
// a: 1.0,
// }),
// )
// .unwrap();
//
// let entity: Entity = cmd.push((
// position,
// gpu_mesh_buffer,
// Physics {
// rigid_body: static_body,
// rigid_body_handle: None,
// },
// Collider {
// collider: mesh_collider,
// collider_handle: None,
// },
// ));
// }
"PhysicsEntity" => { "PhysicsEntity" => {
let mesh_name = entity.mesh.as_ref().unwrap(); let mesh_name = entity.mesh.as_ref().unwrap();
let raw_mesh = match runtime_state.get_mesh(mesh_name.as_str()) { let raw_mesh = match runtime_state.get_mesh(mesh_name.as_str()) {
@ -144,6 +198,10 @@ pub fn runtime_spawn(
let collider = ColliderBuilder::capsule_y(2.0, 1.0).build(); let collider = ColliderBuilder::capsule_y(2.0, 1.0).build();
//let mut vec = Vec::new();
//vec.push()
let gpu_mesh_buffer = renderer let gpu_mesh_buffer = renderer
.upload_mesh_to_buffer( .upload_mesh_to_buffer(
raw_mesh, raw_mesh,
@ -161,7 +219,7 @@ pub fn runtime_spawn(
let mut dynamic_body = RigidBodyBuilder::new_dynamic() let mut dynamic_body = RigidBodyBuilder::new_dynamic()
.can_sleep(false) .can_sleep(false)
.mass(100.0) .mass(100.0)
.translation(position.x, position.y, position.z) .translation(Vector3::new(position.x, position.y, position.z))
.build(); .build();
let entity: Entity = cmd.push(( let entity: Entity = cmd.push((
@ -178,7 +236,7 @@ pub fn runtime_spawn(
ImguiGenericOutputLine::new("wahoo! from a physics entity".to_string()), ImguiGenericOutputLine::new("wahoo! from a physics entity".to_string()),
)); ));
} }
"Terrain" => { "StaticMesh" => {
let mesh_name = entity.mesh.clone().unwrap(); let mesh_name = entity.mesh.clone().unwrap();
let raw_mesh = match runtime_state.get_mesh(mesh_name.as_str()) { let raw_mesh = match runtime_state.get_mesh(mesh_name.as_str()) {
None => { None => {

Loading…
Cancel
Save