<?xml version='1.0' encoding='UTF-8' standalone='no'?>
<doxygen xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="compound.xsd" version="1.9.7" xml:lang="en-US">
  <compounddef id="df/da7/PhysicsEngine_8cpp" kind="file" language="C++">
    <compoundname>PhysicsEngine.cpp</compoundname>
    <includes local="no">algorithm</includes>
    <includes local="no">iostream</includes>
    <includes refid="d1/d20/PhysicsEngine_8hpp" local="yes">PhysicsEngine.hpp</includes>
    <includes refid="d9/dec/TinyMath_8hpp" local="yes">TinyMath.hpp</includes>
    <incdepgraph>
      <node id="7">
        <label>Component.hpp</label>
        <link refid="df/d1f/Component_8hpp_source"/>
        <childnode refid="8" relation="include">
        </childnode>
        <childnode refid="9" relation="include">
        </childnode>
        <childnode refid="10" relation="include">
        </childnode>
        <childnode refid="11" relation="include">
        </childnode>
        <childnode refid="5" relation="include">
        </childnode>
        <childnode refid="12" relation="include">
        </childnode>
        <childnode refid="2" relation="include">
        </childnode>
      </node>
      <node id="6">
        <label>IPhysicsComponent.hpp</label>
        <link refid="d5/d69/IPhysicsComponent_8hpp_source"/>
        <childnode refid="7" relation="include">
        </childnode>
        <childnode refid="13" relation="include">
        </childnode>
        <childnode refid="14" relation="include">
        </childnode>
      </node>
      <node id="4">
        <label>PhysicsEngine.hpp</label>
        <link refid="d1/d20/PhysicsEngine_8hpp_source"/>
        <childnode refid="5" relation="include">
        </childnode>
        <childnode refid="6" relation="include">
        </childnode>
      </node>
      <node id="14">
        <label>TinyMath.hpp</label>
        <link refid="d9/dec/TinyMath_8hpp_source"/>
        <childnode refid="15" relation="include">
        </childnode>
        <childnode refid="16" relation="include">
        </childnode>
      </node>
      <node id="13">
        <label>TransformComponent.hpp</label>
        <link refid="d9/da8/TransformComponent_8hpp_source"/>
        <childnode refid="14" relation="include">
        </childnode>
        <childnode refid="7" relation="include">
        </childnode>
        <childnode refid="12" relation="include">
        </childnode>
      </node>
      <node id="1">
        <label>src/PhysicsEngine.cpp</label>
        <link refid="df/da7/PhysicsEngine_8cpp"/>
        <childnode refid="2" relation="include">
        </childnode>
        <childnode refid="3" relation="include">
        </childnode>
        <childnode refid="4" relation="include">
        </childnode>
        <childnode refid="14" relation="include">
        </childnode>
      </node>
      <node id="8">
        <label>SDL.h</label>
      </node>
      <node id="2">
        <label>algorithm</label>
      </node>
      <node id="15">
        <label>cmath</label>
      </node>
      <node id="9">
        <label>imgui.h</label>
      </node>
      <node id="10">
        <label>imgui_impl_sdl2.h</label>
      </node>
      <node id="11">
        <label>imgui_impl_sdlrenderer.h</label>
      </node>
      <node id="3">
        <label>iostream</label>
      </node>
      <node id="16">
        <label>ostream</label>
      </node>
      <node id="12">
        <label>string</label>
      </node>
      <node id="5">
        <label>vector</label>
      </node>
    </incdepgraph>
    <briefdescription>
    </briefdescription>
    <detaileddescription>
    </detaileddescription>
    <programlisting>
<codeline lineno="1"><highlight class="preprocessor">#include<sp/>&lt;algorithm&gt;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="2"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&lt;iostream&gt;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="3"><highlight class="normal"></highlight></codeline>
<codeline lineno="4"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&quot;PhysicsEngine.hpp&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="5"><highlight class="normal"></highlight><highlight class="preprocessor">#include<sp/>&quot;TinyMath.hpp&quot;</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="6"><highlight class="normal"></highlight></codeline>
<codeline lineno="7"><highlight class="normal"></highlight><highlight class="comment">//<sp/>These<sp/>methods<sp/>intentionally<sp/>left<sp/>blank</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="8" refid="db/df5/classPhysicsEngine_1a7fc9180ea453680df0b863fa157c5b92" refkind="member"><highlight class="normal"><ref refid="db/df5/classPhysicsEngine_1a7fc9180ea453680df0b863fa157c5b92" kindref="member">PhysicsEngine::PhysicsEngine</ref>(){};</highlight></codeline>
<codeline lineno="9" refid="db/df5/classPhysicsEngine_1ae5f076ee99bbfdbc79ab2d27366d8476" refkind="member"><highlight class="normal"><ref refid="db/df5/classPhysicsEngine_1ae5f076ee99bbfdbc79ab2d27366d8476" kindref="member">PhysicsEngine::~PhysicsEngine</ref>(){};</highlight></codeline>
<codeline lineno="10"><highlight class="normal"></highlight></codeline>
<codeline lineno="11" refid="db/df5/classPhysicsEngine_1aaa69a81964d980456a6ac48816d2f756" refkind="member"><highlight class="normal"></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/><ref refid="db/df5/classPhysicsEngine_1aaa69a81964d980456a6ac48816d2f756" kindref="member">PhysicsEngine::AddComponent</ref>(<ref refid="d9/d15/classIPhysicsComponent" kindref="compound">IPhysicsComponent</ref>*<sp/>newComponent){</highlight></codeline>
<codeline lineno="12"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="db/df5/classPhysicsEngine_1add4a407cb22c67709b399c68c99b621e" kindref="member">m_components</ref>.push_back(newComponent);</highlight></codeline>
<codeline lineno="13"><highlight class="normal">}</highlight></codeline>
<codeline lineno="14"><highlight class="normal"></highlight></codeline>
<codeline lineno="15"><highlight class="normal"></highlight><highlight class="comment">//<sp/>TODO:<sp/>Work<sp/>in<sp/>progress</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="16"><highlight class="normal"></highlight><highlight class="comment">//<sp/>Calculates<sp/>all<sp/>relevant<sp/>forces<sp/>on<sp/>an<sp/>object<sp/>in<sp/>total<sp/>so<sp/>there&apos;s<sp/>only<sp/>one<sp/>time<sp/>each<sp/>of<sp/>the<sp/>components<sp/>are<sp/>affected</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="17" refid="db/df5/classPhysicsEngine_1a30d283b6067980e42765340dea6eb62a" refkind="member"><highlight class="normal"></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/><ref refid="db/df5/classPhysicsEngine_1a30d283b6067980e42765340dea6eb62a" kindref="member">PhysicsEngine::Update</ref>(){</highlight></codeline>
<codeline lineno="18"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>Fill<sp/>an<sp/>array<sp/>with<sp/>new<sp/>velocities<sp/>to<sp/>be<sp/>applied<sp/>to<sp/>all<sp/>the<sp/>components</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="19"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="dd/d40/structVec2D" kindref="compound">Vec2D</ref><sp/>velocities[<ref refid="db/df5/classPhysicsEngine_1add4a407cb22c67709b399c68c99b621e" kindref="member">m_components</ref>.size()];</highlight></codeline>
<codeline lineno="20"><highlight class="normal"></highlight></codeline>
<codeline lineno="21"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>Apply<sp/>gravity<sp/>first<sp/>so<sp/>it<sp/>can<sp/>be<sp/>cancelled<sp/>out<sp/>if<sp/>on<sp/>a<sp/>surface</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="22"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal">(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>i<sp/>=<sp/>0;<sp/>i<sp/>&lt;<sp/><ref refid="db/df5/classPhysicsEngine_1add4a407cb22c67709b399c68c99b621e" kindref="member">m_components</ref>.size();<sp/>++i){</highlight></codeline>
<codeline lineno="23"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>velocities[i]<sp/>=<sp/><ref refid="db/df5/classPhysicsEngine_1add4a407cb22c67709b399c68c99b621e" kindref="member">m_components</ref>[i]-&gt;GetVelocity();</highlight></codeline>
<codeline lineno="24"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal">(<ref refid="db/df5/classPhysicsEngine_1add4a407cb22c67709b399c68c99b621e" kindref="member">m_components</ref>[i]-&gt;UsesGravity()){</highlight></codeline>
<codeline lineno="25"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>velocities[i]<sp/>+=<sp/><ref refid="dd/d40/structVec2D" kindref="compound">Vec2D</ref>(0,<sp/><ref refid="db/df5/classPhysicsEngine_1aac07745baaaa47e949089444ecd41247" kindref="member">m_gravity</ref>);</highlight></codeline>
<codeline lineno="26"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="27"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="28"><highlight class="normal"></highlight></codeline>
<codeline lineno="29"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>Apply<sp/>collisions<sp/>to<sp/>all<sp/>components</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="30"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal">(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>i<sp/>=<sp/>0;<sp/>i<sp/>&lt;<sp/><ref refid="db/df5/classPhysicsEngine_1add4a407cb22c67709b399c68c99b621e" kindref="member">m_components</ref>.size();<sp/>++i){</highlight></codeline>
<codeline lineno="31"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="d9/d15/classIPhysicsComponent" kindref="compound">IPhysicsComponent</ref>*<sp/>component<sp/>=<sp/><ref refid="db/df5/classPhysicsEngine_1add4a407cb22c67709b399c68c99b621e" kindref="member">m_components</ref>.at(i);</highlight></codeline>
<codeline lineno="32"><highlight class="normal"></highlight></codeline>
<codeline lineno="33"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>Check<sp/>for<sp/>collisions<sp/>with<sp/>all<sp/>unhandled<sp/>components</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="34"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal">(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>j<sp/>=<sp/>i<sp/>+<sp/>1;<sp/>j<sp/>&lt;<sp/><ref refid="db/df5/classPhysicsEngine_1add4a407cb22c67709b399c68c99b621e" kindref="member">m_components</ref>.size();<sp/>++j){</highlight></codeline>
<codeline lineno="35"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="d9/d15/classIPhysicsComponent" kindref="compound">IPhysicsComponent</ref>*<sp/>other<sp/>=<sp/><ref refid="db/df5/classPhysicsEngine_1add4a407cb22c67709b399c68c99b621e" kindref="member">m_components</ref>.at(j);</highlight></codeline>
<codeline lineno="36"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal">(component-&gt;<ref refid="d9/d15/classIPhysicsComponent_1aae80e0691898c61495f43a7bc2f0e494" kindref="member">IsColliding</ref>(other)){</highlight></codeline>
<codeline lineno="37"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal">(component-&gt;<ref refid="d9/d15/classIPhysicsComponent_1aaf37980fe6dea6de4d49156b3c4ce998" kindref="member">IsKinematic</ref>()){</highlight></codeline>
<codeline lineno="38"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal">(other-&gt;<ref refid="d9/d15/classIPhysicsComponent_1aaf37980fe6dea6de4d49156b3c4ce998" kindref="member">IsKinematic</ref>()){</highlight></codeline>
<codeline lineno="39"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>https://imada.sdu.dk/u/rolf/Edu/DM842/E14/2dcollisions.pdf</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="40"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>https://en.wikipedia.org/wiki/Elastic_collision</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="41"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="dd/d40/structVec2D" kindref="compound">Vec2D</ref><sp/>velA<sp/>=<sp/>velocities[i];</highlight></codeline>
<codeline lineno="42"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="dd/d40/structVec2D" kindref="compound">Vec2D</ref><sp/>posA<sp/>=<sp/>component-&gt;<ref refid="d9/d15/classIPhysicsComponent_1abfaa678eb1c7312e9bf098bc1473f794" kindref="member">GetPosition</ref>()<sp/>+<sp/>component-&gt;<ref refid="d9/d15/classIPhysicsComponent_1abb67c9f5741590c7ebcca1434175386a" kindref="member">GetDimensions</ref>()/2;</highlight></codeline>
<codeline lineno="43"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">float</highlight><highlight class="normal"><sp/>massA<sp/>=<sp/>component-&gt;<ref refid="d9/d15/classIPhysicsComponent_1a5a88a9979998bcfe46ec45d4a6c4966b" kindref="member">GetMass</ref>();</highlight></codeline>
<codeline lineno="44"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="dd/d40/structVec2D" kindref="compound">Vec2D</ref><sp/>velB<sp/>=<sp/>velocities[j];</highlight></codeline>
<codeline lineno="45"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="dd/d40/structVec2D" kindref="compound">Vec2D</ref><sp/>posB<sp/>=<sp/>other-&gt;<ref refid="d9/d15/classIPhysicsComponent_1abfaa678eb1c7312e9bf098bc1473f794" kindref="member">GetPosition</ref>()<sp/>+<sp/>other-&gt;<ref refid="d9/d15/classIPhysicsComponent_1abb67c9f5741590c7ebcca1434175386a" kindref="member">GetDimensions</ref>()/2;</highlight></codeline>
<codeline lineno="46"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordtype">float</highlight><highlight class="normal"><sp/>massB<sp/>=<sp/>component-&gt;<ref refid="d9/d15/classIPhysicsComponent_1a5a88a9979998bcfe46ec45d4a6c4966b" kindref="member">GetMass</ref>();</highlight></codeline>
<codeline lineno="47"><highlight class="normal"></highlight></codeline>
<codeline lineno="48"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="dd/d40/structVec2D" kindref="compound">Vec2D</ref><sp/>newVelA<sp/>=<sp/><ref refid="dd/d40/structVec2D" kindref="compound">Vec2D</ref>(0,0);</highlight></codeline>
<codeline lineno="49"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal">(component-&gt;<ref refid="d9/d15/classIPhysicsComponent_1a4136b164031d8fa821316e1664264392" kindref="member">IsElastic</ref>()){</highlight></codeline>
<codeline lineno="50"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>newVelA<sp/>=<sp/>velA<sp/>-<sp/>((2<sp/>*<sp/>massB)/(massA<sp/>+<sp/>massB))<sp/>*<sp/></highlight></codeline>
<codeline lineno="51"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(Dot(velA<sp/>-<sp/>velB,<sp/>posA<sp/>-<sp/>posB)<sp/>/<sp/></highlight></codeline>
<codeline lineno="52"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>Magnitude(posA<sp/>-<sp/>posB)*Magnitude(posA-posB))<sp/>*</highlight></codeline>
<codeline lineno="53"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(posA<sp/>-<sp/>posB);</highlight></codeline>
<codeline lineno="54"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="55"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>get<sp/>component<sp/>of<sp/>velocity<sp/>that&apos;s<sp/>colliding<sp/>and<sp/>cancel<sp/>it</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="56"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>TODO:<sp/>placeholder</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="57"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>newVelA<sp/>=<sp/><ref refid="dd/d40/structVec2D" kindref="compound">Vec2D</ref>(0,0);</highlight></codeline>
<codeline lineno="58"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="59"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="dd/d40/structVec2D" kindref="compound">Vec2D</ref><sp/>newVelB<sp/>=<sp/><ref refid="dd/d40/structVec2D" kindref="compound">Vec2D</ref>(0,0);</highlight></codeline>
<codeline lineno="60"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">if</highlight><highlight class="normal">(other-&gt;<ref refid="d9/d15/classIPhysicsComponent_1a4136b164031d8fa821316e1664264392" kindref="member">IsElastic</ref>()){</highlight></codeline>
<codeline lineno="61"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>newVelB<sp/>=<sp/>velB<sp/>-<sp/>((2<sp/>*<sp/>massA)/(massA<sp/>+<sp/>massB))<sp/>*<sp/></highlight></codeline>
<codeline lineno="62"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(Dot(velB<sp/>-<sp/>velA,<sp/>posB<sp/>-<sp/>posA)<sp/>/<sp/></highlight></codeline>
<codeline lineno="63"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>Magnitude(posB<sp/>-<sp/>posA)*Magnitude(posB-posA))<sp/>*</highlight></codeline>
<codeline lineno="64"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>(posB<sp/>-<sp/>posA);</highlight></codeline>
<codeline lineno="65"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="66"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>newVelB<sp/>=<sp/><ref refid="dd/d40/structVec2D" kindref="compound">Vec2D</ref>(0,0);</highlight></codeline>
<codeline lineno="67"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight></codeline>
<codeline lineno="68"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>TODO:<sp/>This<sp/>needs<sp/>significant<sp/>testing<sp/>with<sp/>multi-collision<sp/>effects</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="69"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>velocities[i]<sp/>=<sp/>newVelA;</highlight></codeline>
<codeline lineno="70"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>velocities[j]<sp/>=<sp/>newVelB;</highlight></codeline>
<codeline lineno="71"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="72"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>TODO:<sp/>Broadcast<sp/>collision,<sp/>but<sp/>don&apos;t<sp/>affect<sp/>velocity</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="73"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="74"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}<sp/></highlight><highlight class="keywordflow">else</highlight><highlight class="normal"><sp/>{</highlight></codeline>
<codeline lineno="75"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>TODO:<sp/>Broadcast<sp/>collision,<sp/>but<sp/>don&apos;t<sp/>affect<sp/>velocity</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="76"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="77"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="78"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="79"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="80"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="comment">//<sp/>Apply<sp/>the<sp/>array<sp/>of<sp/>velocities<sp/>to<sp/>the<sp/>array<sp/>of<sp/>components</highlight><highlight class="normal"></highlight></codeline>
<codeline lineno="81"><highlight class="normal"><sp/><sp/><sp/><sp/></highlight><highlight class="keywordflow">for</highlight><highlight class="normal">(</highlight><highlight class="keywordtype">int</highlight><highlight class="normal"><sp/>i<sp/>=<sp/>0;<sp/>i<sp/>&lt;<sp/><ref refid="db/df5/classPhysicsEngine_1add4a407cb22c67709b399c68c99b621e" kindref="member">m_components</ref>.size();<sp/>++i){</highlight></codeline>
<codeline lineno="82"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="db/df5/classPhysicsEngine_1add4a407cb22c67709b399c68c99b621e" kindref="member">m_components</ref>[i]-&gt;SetVelocity(velocities[i]);</highlight></codeline>
<codeline lineno="83"><highlight class="normal"><sp/><sp/><sp/><sp/><sp/><sp/><sp/><sp/><ref refid="db/df5/classPhysicsEngine_1add4a407cb22c67709b399c68c99b621e" kindref="member">m_components</ref>[i]-&gt;ApplyVelocity();</highlight></codeline>
<codeline lineno="84"><highlight class="normal"><sp/><sp/><sp/><sp/>}</highlight></codeline>
<codeline lineno="85"><highlight class="normal">}</highlight></codeline>
<codeline lineno="86"><highlight class="normal"></highlight></codeline>
<codeline lineno="87" refid="db/df5/classPhysicsEngine_1a65b58126356b154d20e3081ccb6a402e" refkind="member"><highlight class="normal"></highlight><highlight class="keywordtype">void</highlight><highlight class="normal"><sp/><ref refid="db/df5/classPhysicsEngine_1a65b58126356b154d20e3081ccb6a402e" kindref="member">PhysicsEngine::SetGravity</ref>(</highlight><highlight class="keywordtype">float</highlight><highlight class="normal"><sp/>newGravity){</highlight></codeline>
<codeline lineno="88"><highlight class="normal"><sp/><sp/><sp/><sp/><ref refid="db/df5/classPhysicsEngine_1aac07745baaaa47e949089444ecd41247" kindref="member">m_gravity</ref><sp/>=<sp/>newGravity;</highlight></codeline>
<codeline lineno="89"><highlight class="normal">}</highlight></codeline>
    </programlisting>
    <location file="src/PhysicsEngine.cpp"/>
  </compounddef>
</doxygen>
