You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
142 lines
23 KiB
142 lines
23 KiB
<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"><</span><span class="s5">'a</span><span class="s3">, </span><span class="s2">T</span><span class="s1">> {</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">() -> </span><span class="s2">imgui</span><span class="s1">::</span><span class="s2">Window</span><span class="s1"><</span><span class="s5">'a</span><span class="s1">></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">(&</span><span class="s2">Ui</span><span class="s3">, </span><span class="s2">Vec</span><span class="s1"><&</span><span class="s2">T</span><span class="s1">>)</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"><</span><span class="s2">Deg</span><span class="s1"><</span><span class="s2">f32</span><span class="s1">>></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">() -> </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"><</span><span class="s2">TomlPositionDescription</span><span class="s1">> </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">) -> </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">=> </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">) => </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"><</span><span class="s2">Option</span><span class="s1"><</span><span class="s2">TomlPositionDescription</span><span class="s1">>> </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"><</span><span class="s2">TomlPositionDescription</span><span class="s1">>) -> </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">=> </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">) => </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"><</span><span class="s2">Idx</span><span class="s1">> {</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"><</span><span class="s2">Buffer</span><span class="s1">></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"><</span><span class="s2">Buffer</span><span class="s1">></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"><</span><span class="s2">Buffer</span><span class="s1">></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"><</span><span class="s2">BindGroup</span><span class="s1">></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"><</span><span class="s2">RigidBodyHandle</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>
|
|
<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"><</span><span class="s2">ColliderHandle</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></pre>
|
|
</body>
|
|
</html> |