Debian Codegraph @

doc/examples/DynamicStatic.html

raw symbols SCIP
1 <pre style="text-align:left;color:#000000; background-color:#ffffff; border:solid black 1px; padding:0.5em 1em 0.5em 1em; overflow:auto;font-size:small; font-family:monospace; "><span style="color:#236e25;"><em>// This example is pulled from the Plink demo.
2 </em></span><strong><span style="color:#881350;">if</span></strong>(ChipmunkDemoRightDown){
3 <span style="color:#236e25;"><em>// Find the shape under the mouse.
4 </em></span> cpShape *nearest = <span style="color:#003369;">cpSpaceNearestPointQueryNearest</span>(space, ChipmunkDemoMouse, <span style="color:#0000ff;">0.0</span>, GRABABLE_MASK_BIT, CP_NO_GROUP, <strong><span style="color:#881350;">NULL</span></strong>);
5 <strong><span style="color:#881350;">if</span></strong>(nearest){
6 cpBody *body = <span style="color:#003369;">cpShapeGetBody</span>(nearest);
7 <strong><span style="color:#881350;">if</span></strong>(<span style="color:#003369;">cpBodyIsStatic</span>(body)){
8 <span style="color:#236e25;"><em>// If the body is static, convert it to dynamic and add it to the space.
9 </em></span> <span style="color:#003369;">cpSpaceConvertBodyToDynamic</span>(space, body, pentagon_mass, pentagon_moment);
10 <span style="color:#003369;">cpSpaceAddBody</span>(space, body);
11 } <strong><span style="color:#881350;">else</span></strong> {
12 <span style="color:#236e25;"><em>// If the body is dynamic, remove it from the space and convert it to static.
13 </em></span> <span style="color:#003369;">cpSpaceRemoveBody</span>(space, body);
14 <span style="color:#003369;">cpSpaceConvertBodyToStatic</span>(space, body);
15 }
16 }
17 }
18 </pre>