73 lines
14 KiB
HTML
73 lines
14 KiB
HTML
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="User-defined functions called by the physics engines during one timestep in order to customize its behavior."><title>PhysicsHooks in rapier3d::pipeline - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="rapier3d" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.0 (9fc6b4312 2025-01-07)" data-channel="1.84.0" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../rapier3d/index.html">rapier3d</a><span class="version">0.23.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Physics<wbr>Hooks</a></h2><h3><a href="#provided-methods">Provided Methods</a></h3><ul class="block"><li><a href="#method.filter_contact_pair" title="filter_contact_pair">filter_contact_pair</a></li><li><a href="#method.filter_intersection_pair" title="filter_intersection_pair">filter_intersection_pair</a></li><li><a href="#method.modify_solver_contacts" title="modify_solver_contacts">modify_solver_contacts</a></li></ul><h3><a href="#foreign-impls">Implementations on Foreign Types</a></h3><ul class="block"><li><a href="#impl-PhysicsHooks-for-()" title="()">()</a></li></ul><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In rapier3d::<wbr>pipeline</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">rapier3d</a>::<wbr><a href="index.html">pipeline</a></span><h1>Trait <span class="trait">PhysicsHooks</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/rapier3d/pipeline/physics_hooks.rs.html#161-240">Source</a> </span></div><pre class="rust item-decl"><code>pub trait PhysicsHooks: <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> + <a class="trait" href="https://doc.rust-lang.org/1.84.0/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> {
|
|
// Provided methods
|
|
fn <a href="#method.filter_contact_pair" class="fn">filter_contact_pair</a>(
|
|
&self,
|
|
_context: &<a class="struct" href="struct.PairFilterContext.html" title="struct rapier3d::pipeline::PairFilterContext">PairFilterContext</a><'_>,
|
|
) -> <a class="enum" href="https://doc.rust-lang.org/1.84.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="../geometry/struct.SolverFlags.html" title="struct rapier3d::geometry::SolverFlags">SolverFlags</a>> { ... }
|
|
<span class="item-spacer"></span> fn <a href="#method.filter_intersection_pair" class="fn">filter_intersection_pair</a>(&self, _context: &<a class="struct" href="struct.PairFilterContext.html" title="struct rapier3d::pipeline::PairFilterContext">PairFilterContext</a><'_>) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.bool.html">bool</a> { ... }
|
|
<span class="item-spacer"></span> fn <a href="#method.modify_solver_contacts" class="fn">modify_solver_contacts</a>(
|
|
&self,
|
|
_context: &mut <a class="struct" href="struct.ContactModificationContext.html" title="struct rapier3d::pipeline::ContactModificationContext">ContactModificationContext</a><'_>,
|
|
) { ... }
|
|
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>User-defined functions called by the physics engines during one timestep in order to customize its behavior.</p>
|
|
</div></details><h2 id="provided-methods" class="section-header">Provided Methods<a href="#provided-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="method.filter_contact_pair" class="method"><a class="src rightside" href="../../src/rapier3d/pipeline/physics_hooks.rs.html#186-188">Source</a><h4 class="code-header">fn <a href="#method.filter_contact_pair" class="fn">filter_contact_pair</a>(
|
|
&self,
|
|
_context: &<a class="struct" href="struct.PairFilterContext.html" title="struct rapier3d::pipeline::PairFilterContext">PairFilterContext</a><'_>,
|
|
) -> <a class="enum" href="https://doc.rust-lang.org/1.84.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="../geometry/struct.SolverFlags.html" title="struct rapier3d::geometry::SolverFlags">SolverFlags</a>></h4></section></summary><div class="docblock"><p>Applies the contact pair filter.</p>
|
|
<p>Note that this method will only be called if at least one of the colliders
|
|
involved in the contact contains the <code>ActiveHooks::FILTER_CONTACT_PAIRS</code> flags
|
|
in its physics hooks flags.</p>
|
|
<p>User-defined filter for potential contact pairs detected by the broad-phase.
|
|
This can be used to apply custom logic in order to decide whether two colliders
|
|
should have their contact computed by the narrow-phase, and if these contact
|
|
should be solved by the constraints solver</p>
|
|
<p>Note that using a contact pair filter will replace the default contact filtering
|
|
which consists of preventing contact computation between two non-dynamic bodies.</p>
|
|
<p>This filtering method is called after taking into account the colliders collision groups.</p>
|
|
<p>If this returns <code>None</code>, then the narrow-phase will ignore this contact pair and
|
|
not compute any contact manifolds for it.
|
|
If this returns <code>Some</code>, then the narrow-phase will compute contact manifolds for
|
|
this pair of colliders, and configure them with the returned solver flags. For
|
|
example, if this returns <code>Some(SolverFlags::COMPUTE_IMPULSES)</code> then the contacts
|
|
will be taken into account by the constraints solver. If this returns
|
|
<code>Some(SolverFlags::empty())</code> then the constraints solver will ignore these
|
|
contacts.</p>
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.filter_intersection_pair" class="method"><a class="src rightside" href="../../src/rapier3d/pipeline/physics_hooks.rs.html#210-212">Source</a><h4 class="code-header">fn <a href="#method.filter_intersection_pair" class="fn">filter_intersection_pair</a>(&self, _context: &<a class="struct" href="struct.PairFilterContext.html" title="struct rapier3d::pipeline::PairFilterContext">PairFilterContext</a><'_>) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Applies the intersection pair filter.</p>
|
|
<p>Note that this method will only be called if at least one of the colliders
|
|
involved in the contact contains the <code>ActiveHooks::FILTER_INTERSECTION_PAIR</code> flags
|
|
in its physics hooks flags.</p>
|
|
<p>User-defined filter for potential intersection pairs detected by the broad-phase.</p>
|
|
<p>This can be used to apply custom logic in order to decide whether two colliders
|
|
should have their intersection computed by the narrow-phase.</p>
|
|
<p>Note that using an intersection pair filter will replace the default intersection filtering
|
|
which consists of preventing intersection computation between two non-dynamic bodies.</p>
|
|
<p>This filtering method is called after taking into account the colliders collision groups.</p>
|
|
<p>If this returns <code>false</code>, then the narrow-phase will ignore this pair and
|
|
not compute any intersection information for it.
|
|
If this return <code>true</code> then the narrow-phase will compute intersection
|
|
information for this pair.</p>
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.modify_solver_contacts" class="method"><a class="src rightside" href="../../src/rapier3d/pipeline/physics_hooks.rs.html#239">Source</a><h4 class="code-header">fn <a href="#method.modify_solver_contacts" class="fn">modify_solver_contacts</a>(&self, _context: &mut <a class="struct" href="struct.ContactModificationContext.html" title="struct rapier3d::pipeline::ContactModificationContext">ContactModificationContext</a><'_>)</h4></section></summary><div class="docblock"><p>Modifies the set of contacts seen by the constraints solver.</p>
|
|
<p>Note that this method will only be called if at least one of the colliders
|
|
involved in the contact contains the <code>ActiveHooks::MODIFY_SOLVER_CONTACTS</code> flags
|
|
in its physics hooks flags.</p>
|
|
<p>By default, the content of <code>solver_contacts</code> is computed from <code>manifold.points</code>.
|
|
This method will be called on each contact manifold which have the flag <code>SolverFlags::modify_solver_contacts</code> set.
|
|
This method can be used to modify the set of solver contacts seen by the constraints solver: contacts
|
|
can be removed and modified.</p>
|
|
<p>Note that if all the contacts have to be ignored by the constraint solver, you may simply
|
|
do <code>context.solver_contacts.clear()</code>.</p>
|
|
<p>Modifying the solver contacts allow you to achieve various effects, including:</p>
|
|
<ul>
|
|
<li>Simulating conveyor belts by setting the <code>surface_velocity</code> of a solver contact.</li>
|
|
<li>Simulating shapes with multiply materials by modifying the friction and restitution
|
|
coefficient depending of the features in contacts.</li>
|
|
<li>Simulating one-way platforms depending on the contact normal.</li>
|
|
</ul>
|
|
<p>Each contact manifold is given a <code>u32</code> user-defined data that is persistent between
|
|
timesteps (as long as the contact manifold exists). This user-defined data is initialized
|
|
as 0 and can be modified in <code>context.user_data</code>.</p>
|
|
<p>The world-space contact normal can be modified in <code>context.normal</code>.</p>
|
|
</div></details></div><h2 id="foreign-impls" class="section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor">§</a></h2><details class="toggle implementors-toggle"><summary><section id="impl-PhysicsHooks-for-()" class="impl"><a class="src rightside" href="../../src/rapier3d/pipeline/physics_hooks.rs.html#242-252">Source</a><a href="#impl-PhysicsHooks-for-()" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.PhysicsHooks.html" title="trait rapier3d::pipeline::PhysicsHooks">PhysicsHooks</a> for <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.unit.html">()</a></h3></section></summary><div class="impl-items"><section id="method.filter_contact_pair-1" class="method trait-impl"><a class="src rightside" href="../../src/rapier3d/pipeline/physics_hooks.rs.html#243-245">Source</a><a href="#method.filter_contact_pair-1" class="anchor">§</a><h4 class="code-header">fn <a href="#method.filter_contact_pair" class="fn">filter_contact_pair</a>(
|
|
&self,
|
|
_context: &<a class="struct" href="struct.PairFilterContext.html" title="struct rapier3d::pipeline::PairFilterContext">PairFilterContext</a><'_>,
|
|
) -> <a class="enum" href="https://doc.rust-lang.org/1.84.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="struct" href="../geometry/struct.SolverFlags.html" title="struct rapier3d::geometry::SolverFlags">SolverFlags</a>></h4></section><section id="method.filter_intersection_pair-1" class="method trait-impl"><a class="src rightside" href="../../src/rapier3d/pipeline/physics_hooks.rs.html#247-249">Source</a><a href="#method.filter_intersection_pair-1" class="anchor">§</a><h4 class="code-header">fn <a href="#method.filter_intersection_pair" class="fn">filter_intersection_pair</a>(&self, _: &<a class="struct" href="struct.PairFilterContext.html" title="struct rapier3d::pipeline::PairFilterContext">PairFilterContext</a><'_>) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.bool.html">bool</a></h4></section><section id="method.modify_solver_contacts-1" class="method trait-impl"><a class="src rightside" href="../../src/rapier3d/pipeline/physics_hooks.rs.html#251">Source</a><a href="#method.modify_solver_contacts-1" class="anchor">§</a><h4 class="code-header">fn <a href="#method.modify_solver_contacts" class="fn">modify_solver_contacts</a>(&self, _: &mut <a class="struct" href="struct.ContactModificationContext.html" title="struct rapier3d::pipeline::ContactModificationContext">ContactModificationContext</a><'_>)</h4></section></div></details><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"></div><script src="../../trait.impl/rapier3d/pipeline/physics_hooks/trait.PhysicsHooks.js" data-ignore-extern-crates="std" async></script></section></div></main></body></html> |