#Avian Physics

1 messages · Page 40 of 1

snow urchin
#

As well as normal compound.

visual sparrow
#

the latter factors in the GlobalTransform's scale

#

@vestal minnow do you know if mutating a collider at runtime is supported by parry?

echo parcel
#

If I'm using Collider::trimesh_from_mesh(&mesh),, is there some automatic way to just not add a mesh, if there are no triangles? E.g. empty chunk. To avoid this error:

#

Like, match it and add collider::none or something like that if it exists

#

If I do this instead:

let chunk_entity = commands.spawn((
                //,
            //    Mesh3d(mesh_handle),
                MeshMaterial3d(ground_material.material_handle.clone()),

                RigidBody::Static,
                Transform::from_translation(location),
            )).id();

            match Collider::trimesh_from_mesh(&mesh) {
                None => {
                    let mesh_handle = meshes.add(mesh);

                    commands.entity(chunk_entity).insert((
                        Mesh3d(mesh_handle)
                    ));
                }
                Some(collider) => {
                    let mesh_handle = meshes.add(mesh);

                    commands.entity(chunk_entity).insert((
                        collider,
                        Mesh3d(mesh_handle)
                    ));
                }
            }

It still crashes with the exactly same error. Why?

visual sparrow
#

A panic there is just not sensible

echo parcel
#

Collider::trimesh_from_mesh doesn't make any simplifications for the collider, right?

visual sparrow
#

At least for my meshes, it always looked like a 1:1 match

#

Just be aware that trimeshes are hollow

echo parcel
#

It would be like one big lag fiesta

visual sparrow
echo parcel
visual sparrow
#

It’s on the main branch

#

I haven’t used it, but maybe it could be useful?

snow urchin
#

Apparently "cannot borrow data in dereference of SharedShape as mutable
trait DerefMut is required to modify through a dereference, but it is not implemented for SharedShape"

#
collider.get_mut(entity).unwrap().shape_scaled().as_convex_polygon_mut().unwrap().points();
echo parcel
royal helm
#

I'm always so impressed by how stable avian is

#

situations where I'd expect the physics to freak out, it just resolves it calmly

knotty thicket
#

Today I discovered that the (avian/serialize feature) serde implementations on marker structs like Sensor change the required serialization format from:

{ "avian3d::collision::collider::Sensor": {} }

to

{ "avian3d::collision::collider::Sensor": null }

The information about alternative serializations is generally not available in the reflection information, so my first question is:

What is the purpose of the serialization feature and is this change in format intentional?

sweet sundial
#

looks like it's just a #[cfg_attr(feature = "serialize", derive(serde::Serialize, serde::Deserialize))] #[cfg_attr(feature = "serialize", reflect(Serialize, Deserialize))] on Sensor, no intention beyond a conditional derive

knotty thicket
sweet sundial
#

feature-flag serde impls on most types
if there wasn't a feature, serde would always be pulled in, and a chunk of compile compute would always be used, even if the user crate doesn't use serde

#

sometimes extraneous derives even bloat the final binary somehow

knotty thicket
#

I understand what serde is, what a cfg flag is, and what that's doing;

The question is why, not what. To clarify, the serialize feature breaks reflection based use cases attempting to seemingly duplicate the functionality of the reflection infrastructure.

#

the serialization changes when the feature is enabled, and that change breaks one feature (reflection) in exchange for what seems like the same feature but with less capability

sweet sundial
#

it sounds like it's a bevy_reflect (or serde?) issue; why would #[reflect(Serialize)] break reflect's serialization?

knotty thicket
#

if you're interested in why I'm asking, for more context, I left a message in #reflection-dev that also covers this topic: #reflection-dev message

knotty thicket
#

A similar example is glam's Vec3, which is a struct with x, y, and z fields, but implements serde to make that an array serialization. This information is unavailable to consumers so you can not produce a valid value that is accepted as a Vec3 (the consumer only has the information to produce the struct variant of the serialization)

sweet sundial
#

seems like semver prevents that being too much of an issue?

knotty thicket
#

that comment would suggest that reflection users should hardcode the arbitrary serialization logic for every third party crate, for every version of that crate

#

which is not really a scalable solution imo

sweet sundial
#

more like, using the same version to ser and de at arbitrary times

knotty thicket
#

from other languages?

#

clients written in javascript and python have to handle producing these values

sweet sundial
#

i didn't know that was part of this

knotty thicket
#

yeah, "reflection user" includes any client who needs to say, produce a valid component value from the introspected reflection information

#

so inspector use cases, or in my case a blender addon

#

BRP exposes the reflection information for the types, but serde's serialization isn't part of that information

sweet sundial
#

this is getting very offtopic
can still just sync versions between interfaces, though

knotty thicket
#

you can't though. I don't think serde's serialization can be exposed that way since they can be arbitrary code

#

in any case, the core question I was asking earlier is "why does the serialization feature exist", because I'm considering suggesting that the ecosystem and upstream no longer uses it

#

it currently seems like an anti-feature

vestal minnow
knotty thicket
vestal minnow
vestal minnow
#

Okay interesting

#

What is reflect(Serialize, Deserialize) for / what does it do then 🤔

knotty thicket
# vestal minnow What is `reflect(Serialize, Deserialize)` for / what does it do then 🤔

I'm not 100% sure tbh. I've only ever seen it in reference to serde's Serialize/Deserialize types, and the ReflectSerialize ident would be for serde too.

but SerializationData is already automatically registered, so I think the Serialize stuf is just serde and not serialization in general: https://docs.rs/bevy/latest/bevy/prelude/derive.Reflect.html#default-registrations

vestal minnow
#

Mm yeah

#

It seems like the serialize feature stuff is mostly unnecessary for Avian then, but I'll probably keep it around until upstream Bevy chooses whether it's necessary

#

I'm not really familiar with the details of reflection and serde stuff, and in general I try to follow Bevy's upstream conventions and design for this sort of stuff

knotty thicket
#

yeah, my plan right now is to make a suggestion via PR to upstream with reasoning and a brief survey of ecosystem usage, so knowing Avian's usage was very helpful for that

#

taking serialize off of the marker components would fix a bug a skein user has right now, but my current plan is to hardcode a fix so as to not put presssure on avian to make/release the change

vestal minnow
knotty thicket
#

yeah, and with ColliderConstructor the need to adjust the Collider stuff is less necessary anyway

vestal minnow
#

However, not all shapes in Parry can actually be transformed or edited

#

For example, you cannot modify the vertices or indices of a TriMesh

past cargo
#

Why

vestal minnow
#

It's not just a vertex buffer and index buffer, it also stores a Qbvh, pseudo normals, topology information, connected components, etc.

#

All of this must be updated

past cargo
#

Just update?

vestal minnow
#

There could probably be some API for this, but Parry doesn't have that

past cargo
#

I see

#

Is Parry the best option rn? I see lot of others ppl use

#

Just curiosity

vestal minnow
vestal minnow
#

hopefully my WIP crate Peck when I get time to work on it more

past cargo
#

Wait Ragdoll is possible rn with Avian?

vestal minnow
#

Possible yes, I've made a 2D ragdoll once and I think some people have made simple 3D ragdolls

past cargo
#

I see, thanks jondolf

vestal minnow
#

the wrapper needs to be unsafely transmutable to SharedShape

abstract tendon
#

when i spawn a hidden scene like this, everything is fine

commands.spawn((
        SceneRoot(asset_server.load("models/ammo-box.glb#Scene1")),
        ColliderConstructorHierarchy::new(ColliderConstructor::TrimeshFromMesh),
        Visibility::Hidden,
    ));

but when i add rigidbody::dynamic, scene become visible. why is that?

zinc talon
#

@vestal minnow this got a bit buried #1124043933886976171 message

I'm working on an impl, don't want to get too far in just to hear it's not something Avian wants. Does this look reasonable?

vestal minnow
#

So this would be basically like adding a child collider for the ball to act as the "collision proxy", except that the proxy may move in a different frame of reference than the ball? For example if the body was moving left into a portal and the other side of the portal points up, the "left" movement would be treated as "up" movement for the proxy, and vice versa

#

That seems quite difficult to implement properly since it's not enough to just transform positions and contact data and whatnot, you need to consider things like velocity, which is a per-body property, not a per-shape property

zinc talon
#

That would allow a lot of latitude in what the feature could be used for

vestal minnow
#

I think I'd prefer this to be done in user-space and not built-in, though we could have an example for it

zinc talon
#

Could this be done in user space? I'd love that actually

#

I just assumed that'd be hard/impossible/result in duplicating tons of avian code

vestal minnow
#

Mm I imagine it's possible to implement some version of it, though I need to think through the implications more

#

(brb need to be afk for a bit)

zinc talon
vestal minnow
# zinc talon *Could* this be done in user space? I'd love that actually

So for a Portal-like portal, my intuition would be to start with this sort of approach.
At every fixed update:

  1. If a body overlaps a portal, create proxy body on exit side
  2. Write source body transform and velocity to proxy, transforming based on the portal
  3. Simulate physics like normal, treating the source body and proxy body as independent physics objects
  4. Compute total impulse applied to proxy body as (vel - prev_vel) / delta_secs, and apply it to the source body
  5. If the center of mass of the proxy has crossed the portal, promote it to the source body
  6. If the source body no longer overlaps the portal, remove the proxy
#

This approach shouldn't need any changes to Avian internals, you just treat the source body and proxy body as their own objects, but sync the source transform and velocity to the proxy each frame, and write back impulses applied to the proxy to the source body

#

It may not be perfectly accurate since it's not integrated into the actual solver or substepping loop, but I would suspect that it's "good enough" for most cases

#

I feel like actual two-way syncing for individual contact impulses and whatnot between the source body and proxy body would be too expensive and add a lot of complexity that I would prefer not to have for our internals

#

For more fully featured portals you may also need portal-aware joints and spatial queries, which will be its own challenge

snow urchin
vestal minnow
vestal minnow
#

for example you only want gravity for the source body

#

otherwise, you'd have double gravity, and also if you had the portal exit pointing downwards, you'd get sucked in as soon as you overlap the portal even a little bit, which you probably don't want

#

I guess you do kinda want a single body with just a collision proxy on the exit side

zinc talon
#

aka if body A collides with proxy B, we generate a single contact between A and B, rather than (A, proxy(B)) and (B, proxy(A))

vestal minnow
#

Yeah that makes sense

vestal minnow
#

I think you'd probably need to mess with the ColliderTransform, AABB updates, and narrow phase velocities

zinc talon
#

Who knows, maybe the impl won't be too complicated, but if it stays on a fork, that's not the worst thing

dreamy viper
#

Are position <> transform only kept in synced via the SyncPlugin? (i.e. in the schedule provided to the sync plugin)
or are there other places? (like in PostUpdate)?

I see that we have

app.register_required_components::<Position, Transform>();

Do we also have the reverse?

sweet sundial
#

that seems like an unrelated line of code

viral goblet
#

Is there a way to define something like a global maximum velocity?
(My player keeps getting knocked out of bounds 🥹 )

vestal minnow
vestal minnow
snow urchin
vestal minnow
#

Ye

snow urchin
vestal minnow
#

Note that the main branch also has hooks that compute the global physics transform from the Transform right after spawn, whereas previously this was handled by a system

#

In 0.3 it was messier, but yeah there it was done mostly by the SyncPlugin. I think the PreparePlugin handled computing initial transforms though

#

Avian doesn't run any systems outside the schedule given to PhysicsPlugins, excluding maybe some visual things like debug rendering

dreamy viper
#

By global physics transform you mean Pos/Rot?
So the only sources of sync are:

  • hooks for Transform -> Pos/Rot
  • required components for Pos/Rot -> Transform
  • systems in PhysicsTransformPlugin (usually FixedPostUpdate)
#

I see cases where my entity's Transform doesn't match its Position, even though I have a system in PostUpdate that sets the Transform from the Position. Still trying to figure out why

vestal minnow
#

The hooks are kinda confusing but right now it initializes Position/Rotation based on Transform, unless the user has manually specified Position/Rotation, in which case those override the Transform instead. I might change it to just always use the Transform though

#

The required components just make sure that every entity with Position/Rotation has Transform if position-to-transform syncing is enabled

dreamy viper
#

thanks

snow urchin
#

"cannot borrow data in dereference of SharedShape as mutable
trait DerefMut is required to modify through a dereference, but it is not implemented for SharedShaperustcClick for full compiler diagnostic"

avian2d::collision::collider::parry::Collider
pub fn shape_mut(&mut self) -> &mut SharedShape
sweet sundial
#

there's an arc in the way

#

SharedShape::make_mut

snow urchin
dreamy viper
#

How can I avoid a SpatialQuery::cast_ray from matching with the origin? I need to use the filter: SpatialQueryFilter? or is there a more elegant way

acoustic spoke
#

&SpatialQueryFilter::from_excluded_entities([origin]) i believe

golden python
#

Hello, does ColliderConstructor::TrimeshFromMesh also generates collider for other scene roots that are childrens of the entity ? If yes is there a way to have it not do that ?

golden python
#

bump btw, curious why it happens

golden python
#

Also I couldn't find a spring joint, is it a thing in avian or should I make it myself

snow urchin
#

Apparently

let points = collider
            .get_mut(entity)
            .unwrap()
            .shape_mut()
            .make_mut()
            .as_convex_polygon_mut()
            .unwrap()
            .points();

Doesn't give you a vector to push new points/indices in, so I might need an rc vector and edit it that way

sweet sundial
#

i think "add a point to this convex hull" is going to be something more like fn append_polygon(shape: &ConvexPolygon, additional: &[Point<f32>]) -> ConvexPolygon { ConvexPolygon::from_convex_hull(&shape.points().iter().chain(additional).copied().collect::<Vec<_>>()) } + a core::mem::replace

#

(apparently this operation makes like half a dozen vecs??)

snow urchin
sweet sundial
#

there aren't any mut methods on ConvexPolygon

snow urchin
#

Well what I mean is I would put the vectors you first give to the colliders into an rc and then clone it into it

#

Then you can edit it while it's in the collider right?

sweet sundial
#

the best you can do is skip the convex hull op and use from_polyline

#

the vecs are all parry internals

snow urchin
sweet sundial
#

no, ConvexPolygon::from_convex_polyline

#

_unmodified maybe

snow urchin
#

"no method named from_convex_polyline found for mutable reference &mut avian2d::parry2d::shape::ConvexPolygon in the current scope"

sweet sundial
#

... might be too new lol

snow urchin
#

No choice but to place hold by replacing the Collider with another then

sweet sundial
#

no, it's there, it's just not a method

#

_unmodified doesn't exist though

sweet sundial
snow urchin
#

Rip

#

Is there a way to at least get the indices and vertices?

sweet sundial
#

points is already ordered

snow urchin
#

points that is

tall willow
#

It seems a little more jittery than Rapier, but might be because Rapier is doing some form of interpolation by default

halcyon dew
#

it may even be appropriate to add TransformExtrapolate only to the render player

#

nice FPS controller by the way, it works well and is very lightweight

dreamy viper
#

I use this and the in the logs i can see that the target that was hit is still the shooter

acoustic spoke
#

does your shooter have multiple colliders

dreamy viper
#

it might have child colliders, yes

acoustic spoke
#

could it be that it hit one of the child colliders instead?

dreamy viper
#

but then shouldn't the hit_data.entity be the entity corresponding to the child collider?

acoustic spoke
#

yeah...

acoustic spoke
dreamy viper
#

I'm doing something like

            if let Some(hit_data) = query.cast_ray_predicate(
                hitscan.start,
                Dir2::new_unchecked(direction),
                HITSCAN_COLLISION_DISTANCE_CHECK,
                false,
                &mut SpatialQueryFilter::from_excluded_entities([shooter]),
                &|entity| target_query.get(entity).is_ok(),
            ) {
                let target = hit_data.entity;
                info!(
                    ?hit_data,
                    ?shooter,
                    ?target,
                    "Hitscan hit detected"
                );
            }

and I get

 Hitscan hit detected tick=Tick(7984) hit_data=RayHitData { entity: 258v1#4294967554, distance: 20.000002, normal: Vec2(0.1064226, -0.994321) } shooter=258v1#4294967554 target=258v1#4294967554
#

let me double check

#

ah you're right i was doing something wrong

acoustic spoke
#

what was it lol

#

(that normal vector looks very not normalized)

dreamy viper
#

the normal vector should be normalized?

acoustic spoke
#

maybe not

dreamy viper
#

I was intercepting the spatial query and was doing some custom stuff on top of it

acoustic spoke
dreamy viper
#

The docs on the predicate are wrong, no?

/// - `predicate`: A function called on each entity hit by the ray. The ray keeps travelling until the predicate returns `false`.

///     // Cast ray and get the first hit that matches the predicate
///     let hit = spatial_query.cast_ray_predicate(origin, direction, max_distance, solid, &filter, &|entity| {
///         // Skip entities with the `Invisible` component.
///         !query.contains(entity)
///     });
#

it seems to be that the ray keeps travellign until the predicate returns 'true'

tall willow
#

Might do a small update

snow urchin
#

@vestal minnow Is a fluid solver on the agenda?

snow urchin
#

in the future that is

open mortar
#

omg it's my issue

vestal minnow
#

pairs nicely with Avian

#

(and yes I'm aware that "peck" can mean other things too like giving a kiss :P)

thin osprey
#

well yeah I was more wondering why you were keeping up with the bird thing since it sounded like Peck wasn't really a bevy thing.
used in avian sure but a separate and generic rust collision lib
but I guess if avian is a bird thing then makes fair play

vestal minnow
#

It's not tied to Bevy, and can be used as a generic thing, but it is still driven by the needs of Avian (and Bevy) and does use e.g. Bevy's primitive shapes and math types

runic tinsel
vestal minnow
#

eventually yes, hopefully

#

I'd like to work on it a lot more next cycle

visual sparrow
vague pebble
#

😖

little maple
vestal minnow
visual sparrow
calm sundial
#

Hi. Godot has some issues with implementing Gltf physics extension:

Known issues
Godot Physics does not support mesh-mesh collisions; this plugin will create meshes whenever the input file has requested them, even if it may result in a collision pair which is unsupported by Godot.
Godot constraint spaces are parameterized on a single world-space transform (rather than specifying a coordinate system in the space of each body), which implies that the pivots of both bodies are aligned at scene load. When this is not the case in the input file, we lose information about the pivot on body B.

#

Will we have similar issues?

vestal minnow
#

Avian supports mesh-mesh collisions, and also joints support local frames on each body as of #803

golden python
#

Hello, i'm working on my car controller still, it's getting there but it sometimes freaks out, i'm sanity checking all of my code, and i'm curious of this:

fn get_point_velocity(linear_velocity: Vec3, angular_velocity: Vec3, point: Vec3) -> Vec3 {
    linear_velocity + angular_velocity.cross(point)
}

Is the point supposed to be global space or local space ?
In my head it's local space since the velocity and angular velocity are local afaik but I could be completely wrong.
(this is for getting the velocity at a point of a rigidbody)

sweet sundial
#

should be in whatever space the inputs are in

lyric sorrel
#

The point does need to be relative to the centre of mass, but yeah, the rotation of the frame doesn't matter (so long as it's the same for all 3 inputs) (and the output will be in the same frame ofc)

vestal minnow
#

you can convert to local space by transforming by the inverse rotation

lyric sorrel
#

On first glance the world_axis calculation looks a little suspect - I think .down() is already rotation * -y so the end result will have the transform's rotation in it twice. Try just let world_axis = object_a.down();?

golden python
#

Thanks, that is correct, I deleted my code because I'm going to rewrite a lot of it to go back to raycasts

snow urchin
vestal minnow
#

Well, Unity doesn't have official fluid sim, and neither does Godot :P but yeah a good fluid simulation crate for Bevy would be nice

cinder summit
#

There's so many different approaches to fluid sims too, depending on what properties you want

#

In my game for example I'm gonna specifically want to simulate water flows in some performant way. But some games want a fill volumetric thing. Others just want boyuancy + waves ... Would be hard to get this right in 1 crate

vestal minnow
#

Buoyancy is definitely something I'd like to add to Avian, it just needs some geometry stuff to be added to Parry (or Peck if/when we switch to it)

#

SPH, FLIP, MPM, position-based fluids, etc. are better implemented as separate crates with an Avian integration for rigid body coupling though

cinder summit
#

What do these abbreviations stand for lol

vestal minnow
#

there's also a bunch of sub-variants like DFSPH, IISPH, XSPH, WCSPH...

#

Oh and then there's liquidfun's approach, which I think is not quite SPH but its own thing? I'm not sure how exactly it works

#

it was last updated 8 years ago bavy

vague pebble
#

I know this sounds weird but is there a contain method that checks if a vector is inside a collider?

#

Ah there is contains_point

cinder summit
#

Yea, or point_intersections if you want it at the SpatialQuery level

#

Requires non-hollow shapes though I think

cinder summit
#

You mean clippy #4298?

vague pebble
#

Idk what is the hashtag or what does that meam i just menbered you used an anime pfp

cinder summit
vague pebble
cinder summit
#

If the collider hasn't been spawned you'd need the contains_point approach at least

vague pebble
#

thank you friend you are friend

fickle quail
#

Does setting gravity to 0, with GravityScale(0.) removes solver body from the entity?

vestal minnow
#

Nope, if it did then you wouldn't have any physics for that entity

#

(collisions, joints, forces, etc. wouldn't do anything)

fickle quail
vestal minnow
#

I'm guessing it's marked as Sleeping since the velocity is so low and the body is effectively resting

#

This "removes" it from the simulation by removing SolverBody until something wakes it up

fickle quail
#

How can disable sleeping?

vestal minnow
#

You can add the SleepingDisabled component

#

I'm curious why you're querying for SolverBody? Running some custom logic inside the solver?

vestal minnow
#

If this is outside the solver then you should just use LinearVelocity and AngularVelocity, but yeah inside the solver you'd access the SolverBody

fickle quail
stuck hull
#

can multiple collisions be handled at the same time?

vague pebble
#

This might sound weird but is it possible to check out if two colliders are overlapping each other, even if they dont technically exist (arent spawned)?

cinder summit
#

There should be, hold on let me check if I can find what it is

vague pebble
#

hmm

golden python
#

Hello, a bit of a math question but i'm wondering if there are built-in tools to solve it:
Is applying forces tied to the mass ? For example if I have a vehicle at a velocity of 100 m/s, if I want to apply a wheel resistance of 20% of it's velocity, do I need to take mass into account and what would be the best way ? (also I would probably have to multiply the 20% by delta_secs no) ?

I know some engines have some way to apply force regardless of mass or smth

zinc talon
golden python
zinc talon
#

Mmmmm yeah I misremembered a linear acceleration component. Ok, in that case you either directly modify velocity after dividing by timestep, or you... apply force after multiplying by mass 😬

#

So yeah. Probably just apply force, taking target mass into account

#

But you don't need to worry about timestep that way

vestal minnow
#

(note that on the main branch we do have APIs for applying acceleration, just not in 0.3)

cinder summit
#

That's the plan ... Who knows if Jondolf will be able to fix the many bugs on main in time though 🤣

vestal minnow
#

yeah that's the plan, we'll see when 0.17 releases

cinder summit
#

Though I guess islands isn't on main yet so that's less bugs on main 🤔

vestal minnow
#

I believe 0.17 should be at least two or three weeks away still, considering even the RC isn't out yet

#

but I'm guessing the RC will come early-ish next week

cinder summit
#

Minimum for RC -> release is 2 weeks iirc

vestal minnow
cinder summit
#

Oh no ... I guess we'll have to hope cart does the same and delays the RC super_bavy

vague pebble
#

i am curious how is it possible for a collision event to start

#

but not have a secondary body

#

it is a ghost collision?

little maple
cinder summit
#

Damn that's crazy, my game literally crashes consistently when I do totally normal actions, and that's just on main ferris_sob

little maple
vague pebble
#

Math question convertin lin vel to dir woudl give me the direction that mesh is going?

knotty thicket
little maple
#

you could use one of the Vec3 (or 2) normalize functions if you want to keep the type

vague pebble
knotty thicket
#

its unclear to me what you're using this answer for, but its worth noting that if you have a bullet's linear velocity, then you already have the direction its moving it. Its the linear velocity vector. normalizing that won't change the direction its moving in.

vague pebble
frail robin
#

I'm looking for a solution to interpolate Transform on a listen server (when the server is also a client).
bevy_transform_interpolation looks like a perfect fit. However, it seems to trigger change detection every frame, which is problematic because it causes networking crates like bevy_replicon to replicate the component even if it hasn't actually changed.
It's possible to replicate a custom position/rotation component instead, but that’s quite inconvenient.
Would it be possible to add an option to bypass change detection during interpolation to make the crate compatible with networking crates?

sweet sundial
#

that'd break GlobalTransform and therefore rendering

golden python
#

#math-and-physics message
Hello, this is not a problem with avian itself but i'm stuck trying to make my car controller's traction work so i'm curious if anyone can help (since i'm using avian).

frail robin
frail robin
#

In networking, we also need interpolation between network ticks for clients. I can create my own backend that writes replicated values from history, but I also need a way to control the overstep value.
@vestal minnow, would you be open to extending the crate to support this use case, or would it be out of scope?

vestal minnow
#

I suppose it'd either be some OverstepFraction resource or alternatively some t value on the easing state components, and then there'd be some configuration option to update it automatically (using Time<Fixed>) or manually with your own logic

frail robin
# vestal minnow I suppose it'd either be some `OverstepFraction` resource or alternatively some ...

Great!

What your plans with this PR?
https://github.com/Jondolf/bevy_transform_interpolation/pull/10
Asking to avoid possible merge conflicts.

GitHub

Objective
Currently, changing the Transform of an interpolated or extrapolated entity outside of the fixed time step (e.g. in Update) disables easing until the start of the next fixed time step. It...

vestal minnow
#

Not sure when I'll get back to that, it was mostly working in my testing but it caused some weird problems for someone who tried it, so I left it for now

#

So yeah you don't have to worry too much about conflicts there

frail robin
#

Thanks, I'll start experimenting then!

cinder pilot
#

How can I serialzie a collider at runtime?

I have a level editor where players can draw physics lines and save the file.

I see that a ColliderConstructor seems like a fit, however, as soon as it is spawned, it is deleted and replaced with a real Collider. I want to actually KEEP the ColliderConstructor so that when I serialize my scene, whoever loads the scene will get the collider

#

It feels like the only solution I have would be to implement a wrapper around ColliderConstructor, which feels like an ugly alternative.

vague pebble
#

Moving a kinematic body will convert it is transform to linear_velocity correct?

#

That means independently of what dynamic body type you have

#

You always gonna have the trajectory of where it is going, somewhat

zinc talon
#

That's my understanding

vague pebble
#

@zinc talon oi

#

okay

#

another queston does inserting a collider continously disable collisionlayers fillering?

frail robin
# vestal minnow I suppose it'd either be some `OverstepFraction` resource or alternatively some ...

In my case, I need to set the overstep fraction per entity, because it's possible to receive updates for some entities and miss updates for others. What if I add OverstepFraction component? If it's present, use its value. Otherwise, just take overstep_fraction from Time.

I also looked at the open issues. I agree with https://github.com/Jondolf/bevy_transform_interpolation/issues/13, but I think customization is also important. For example, this use case makes sense to me. I can also imagine situations where someone might want to interpolate position but apply rotation immediately.

What if we store booleans that configure this directly on Transform(Interpolation/Extrapolation)? We could create constants like TransformInterpolation::ALL and TransformInterpolation::NONE. This would allow initializing them like this:

TransformInterpolation {
    x: true,
    y: true,
    ..TransformInterpolation::NONE,
}

And I would Default it to transform + rotation without scale.
Another option is to use bitsets, but the name is a bit long, writing something like this would be a bit repetetive: TransformInterpolation::X | TransformInterpolation::Y. But if we rename the components into TransformInterp and TransformExtrap it might be fine. Bitsets also allow us to create a nice constants, like TransformInterp::TRANSLATION. This is probably my fav option.

Any of these ways would allow to keep flexibility (and even increase it, if you agree to split translation to x, y, and z), but reduce the amount of systems significantly.

Please, let me know what you think. If you like the second suggestion, I can PR it too.
BTW, your code is very clean, I like it 🙂

vague pebble
vestal minnow
#

For the axis bitmask, I'm also somewhat concerned by the added branching. I'd like interpolation to have very minimal overhead since people might run it for hundreds of thousands of entities, and it feels like something that should be heavily vectorizable. We could make it branchless and SIMD-accelerated if we used a BVec3A and Vec3A::select, which takes advantage of hardware intrinsics, but Transform translation uses Vec3, not Vec3A :/ Anyway, maybe it'd be negligible or get optimized by the compiler either way. Would again need some profiling to verify.

#

Aside from performance, I would mildly contest to the idea of supporting interpolation only for specific axes. So far, the only use case I'm aware of is y-sorting, where you want full control over the z coordinate and don't want it to be interpolated; are there any other realistic use cases? For the y-sorting problem, my ideal solution would just be "add Transform2d to Bevy, and handle interpolation for it separately". To me, it seems like the use cases for limiting interpolation to specific axes are primarily scoped to 2D, so I feel like we should implement that as a first-class citizen rather than special-casing 3D to work for 2D.

frail robin
vestal minnow
#

hmm, yeah that's valid

frail robin
vestal minnow
frail robin
vestal minnow
#

Some people have been wanting to get bevy_transform_interpolation upstreamed in some form, so in general for questions like this I try to consider "would upstream Bevy accept this?"

#

Interpolating only specific axes feels somewhat niche to me, and I haven't seen it in other engines, which is part of why I'm kind of on the fence there

#

(also this feels like a #physics-dev discussion maybe?)

minor sandal
#

I have a small question, i'm currently trying to run some unit tests using avian. But with just Minimal plugins I run into some panics. Are there unit tests laying around somewhere of what pluggins to put to use avian ?

I don't get any errors when running my setup however and I'd like to avoid adding plugins or resources that should be added by Avian.

Here is a snippet of what I'm trying to run

#[test]
fn dies_on_impact() {
    // Setup app
    let mut app = App::new();

    app.add_plugins(MinimalPlugins);
    app.add_plugins(TransformPlugin);
    app.insert_resource(bevy::scene::SceneSpawner::default());
    app.add_plugins(PhysicsPlugins::default());
    app.insert_resource(Gravity(Vec2::ZERO));

    app.add_systems(Update, track_target);

    let target = app
        .world_mut()
        .spawn((
            Collider::circle(1.0),
            RigidBody::Dynamic,
            Transform::from_xyz(0.0, 0.0, 0.0),
        ))
        .id();

    let missile = app
        .world_mut()
        .spawn((
            Collider::circle(1.0),
            RigidBody::Dynamic,
            Transform::from_xyz(0.0, 0.0, 0.0),
            SimpleMissileAI {
                target: Some(target),
                previous_target_pos: Some(Vec2::new(0.0, 0.0)),
            },
            SubsystemEngine::default(),
            Explodes::default(),
        ))
        .id();

    app.world_mut()
        .resource_mut::<Time<Virtual>>()
        .set_relative_speed(200.0);

    while app.world().resource::<Time>().elapsed_secs() < 0.1 {
        app.update();
    }

    assert!(app.world().get_entity(missile).is_err());
}

And I get

Encountered an error in system `avian2d::collision::broad_phase::collect_collision_pairs<()>`: Parameter `ResMut<CollisionDiagnostics>` failed validation: Resource does not exist
golden python
paper maple
#

How much does Collider::compound do ? Does it optimize away redundant vertices and internal faces at all ? If the resulting geometry is concave, how well does that work ?

vestal minnow
#

It's pretty much equivalent to just having separate colliders, except it has its own BVH acceleration structure to accelerate various queries

paper maple
#

I see. is there anything in avian that I can use to simplify the geometry before turning it into a collider ? or do i need to rely on third party methods ?

vestal minnow
#

If your shape is a mesh, you can use its convex hull or convex decomposition for the collider. Beyond that, not really; Avian currently uses Parry for its collision shape types, and I don't think it supports simplification like that

paper maple
#

Does convex decomposition make an effort to simplify geometry ?

vestal minnow
#

Oh and also trimeshes do support some preprocessing too, mainly to do stuff like remove duplicate vertices or fix internal edges. But that's just for trimeshes

vestal minnow
paper maple
#

I dont really know what a trimesh is, can't think why it would be hollow either

glad wraith
#

I'm looking to make a game with a ton of bullets flying around, and I'd like to use Avian to handle collisions, but I'm not sure what the best way is to process the collisions. The docs seem to indicate that I should use events for batch processing

So, I have bullets with a collider and collision events enabled. (not sure if I should be using hooks or observers or something else.)

With my current code it feels weird having to check which entity is the bullet and which is the one being hit, so I feel I'm doing something wrong

paper maple
#

btw i am working with avian2d if that changes aynthing

vestal minnow
#

Most of the same things apply in 2D too though, except there is no trimesh collider

#

Nvm yes there is, I'm actually not sure what that's like 🤔

paper maple
#

my bad

vestal minnow
#

But yeah I guess for 2D the main shapes for more complicated geometry would be polylines, convex hulls, convex decompositions, and maybe triangle meshes

#

I think polylines and trimeshes probably aren't simplified at all (by default at least)

paper maple
#

Basically i have a tilemap of squares and triangles and stuff and i just want to combine that into a single collider lol. Was considering compound, but was concerned about how much redundant data would be held in that (redundant vertices and faces)

vestal minnow
#

On the main branch there's a dedicated voxel collider shape that can be good for tilemap collisions like that

paper maple
#

V-HACD seems like that is simpliying the geometry and would probably optimize away redundant data right ?

vestal minnow
#

Yeah, kinda. It's not really intended for tilemap use cases though and is more for approximating detailed meshes with approximate convex parts. It may not approximate everything correctly or retain all your desired geometry, and it's also really expensive to run the decomposition algorithm, at least in 3D

#

I don't think I've tested it much in 2D

#

(V-HACD is from Parry, not Avian, we just expose APIs to create colliders with it)

#

vanishes to continue silksong

minor sandal
minor sandal
placid reef
modern quartz
#

How can I have an entity (E) that has collision filters with only one other group (A), but as a trigger to another group (B)? As in, E will collide and bounce off A, and E will not physically interact with B. I want to know when E touches B. I tried a mix of CollisionLayers and Sensor on E but does not seem to trigger an event. Should I be looking at CollisionHooks for this scenario?

visual sparrow
#

Hmm, how hard would it be to implement a collider (for shape casts specifically) that is a cone that uses a different radius for its X/Z and Y axes?

#

I need a (view) cone that is slim but tall

vestal solstice
#

for floating charactes to go down ramps without hopping is it necessary intervation on our side or does avian deal with that by default?

visual sparrow
#

Pretty sure you need that with Avian too, since "hopping" is the realistic response. In real life, you'd try to go down the ramp, but a character controller usually only tries to move horizontally, so it will lift off the ramp

vestal solstice
#

how much worse would round_cuboid be compared to capsule for dynamic collisions?

#

of a player

dry jolt
#

hi. how would one Pause the physics simulation? i need to wait till all my objects are loaded in before starting things up. and also for pause game...

sweet sundial
#

pause Time<Virtual>

vestal minnow
#

@rigid cipher moved discussion here :)

#

I think instead of an example of a first-person character controller with networking, I would prefer separate minimal examples for a first-person character controller and for a networked scene. This way, the examples are more scoped and focused on a specific thing

#

For character controllers specifically, I'm also a bit wary of adding more examples for now, until we have an actually good one. The current examples are not very great, and especially the kinematic character should be updated to use something more like a collide-and-slide algorithm. We have a working group for this (link), though progress has stalled a bit / people are busy with other things right now

vestal minnow
visual sparrow
vestal minnow
#

Basically just derive Shape, SupportMap, RayCast, and PointQuery for the shape type, and then you can create a SharedShape from it and convert to a Collider

#

The support map allows GJK to be used for the ray cast and point query impls (and other queries) unless you want to come up with analytic solutions

#

The support map is a function that returns the point that maximizes the dot product with the given direction (a support point), i.e. the "farthest point in a given direction" for a convex shape

visual sparrow
#

Which trait do I impl for that?

vestal minnow
#

Oh right specifically for shape casts, I... don't think there's a dedicated trait for that

#

If you implement SupportMap then it'll use that, but afaik custom implementations would require a custom dispatcher

visual sparrow
#

I suppose that could also be done with a sensor that I toggle on for just one frame hmm

vestal minnow
#

Then it can do everything that convex polyhedra support

#

Or another possible approach could be to use aabb_intersections_with_aabb to get collider entities overlapping the given AABB region where the elliptical cone should be, and then you can manually run whatever checks you want on them, including a more accurate analytic elliptical cone intersection test

#

Or the (non-analytic) custom shape with a support map

vestal solstice
#

is there any significant performace hit using ShapeCaster component over doing spatial queries?

rigid cipher
# vestal minnow For character controllers specifically, I'm also a bit wary of adding more examp...

Totally makes sense, mine may help improve, I think the amount of networking code would be very difficult for others to understand. So I’d focus on a controller that can easily be networked. Mine also improves on this because it doesn’t use delta time while moving the same distance given the same inputs. If this sounds good to you I can help improve the examples. I’m not sure how to do the collide and slide though

#

I would also think stubbing out a function where to put send inputs in the .chain() of kinematics would be nice because it needs to go after an accumulated inputs function. But obviously I don’t want to add stuff others deem unnecessary

vestal solstice
visual sparrow
#

(I don’t need the cone to be super accurate)

sweet sundial
#

could use a rectangular pyramid or frustrum

snow urchin
#

How do you do point colliders?

cinder summit
vestal minnow
#

if you want to test if a point is contained within some shape, there are methods for that, but yeah you can't just have a collider that is only a point, the next best thing is a small circle/sphere

vestal minnow
#

I suppose it could maybe be possible to implement a point collider, though I haven't seen that anywhere and it'd be rather cursed

vestal minnow
#

zero volume, no surface area at all...

snow urchin
vestal minnow
#

wdym?

snow urchin
#

the only usable implementation is aabb I guess

#

Which is what I want it for

vestal minnow
#

Parry doesn't really have a point shape

snow urchin
#

and technically you could give it a circle surface

#

since like a circle it has no sides

vestal minnow
#

a point is just a position in space that has no size or shape at all

visual sparrow
visual sparrow
#

It sounds to me like you're trying to use the wrong tool for the job

vestal minnow
#

Hmm might actually be worth trying if you can make a circle/sphere collider with a radius of 0.0 and whether that works at all

#

I think that technically works in some engines at least

snow urchin
#

those "directions" being points

#

they're attached to a fake cursor

snow urchin
snow urchin
vestal minnow
vestal minnow
snow urchin
#

understood

modern quartz
snow urchin
#

How do I put in a component into "with_excluded_entities" from SpatialQueryFilter?

cinder summit
#

You can't but if you iterate trough the results you could run a query on each hit to see if it has your component. Or alternatively make use of collision layers

snow urchin
#

"mismatched types
expected (), found bool"

let directions = ({
        //filter out spellradiuses
        for entity in spatial
            .point_intersections(magic_mouse.translation.xy(), &SpatialQueryFilter::default())
        {
            if m_matrix.contains(entity) {
                return true
            }
        }
        false
    },);
#

regarding return true

tough zealot
#

Hey! I have been planning to port my game to avian for a while now. Last time I tried it I remember having some issues with rigid bodies that had children with colliders. As that is not a use case explicitly shown in the examples (at least to my knowledge), is it something I can expect to work?

This code seems to work fine but I figured I'd ask before spending a bunch of time on it.

    commands
        .spawn((
            RigidBody::Dynamic,
            Transform::from_translation(Vec3::new(0.0, 10.0, 0.0)).with_rotation(Quat::from_euler(
                EulerRot::XYZ,
                0.5,
                0.4,
                -0.4,
            )),
            Visibility::Inherited,
        ))
        .with_children(|parent| {
            parent.spawn((
                Mesh3d(cube_mesh.clone()),
                MeshMaterial3d(materials.add(Color::srgb(0.2, 0.7, 0.9))),
                Transform::from_translation(Vec3::splat(cube_size))
                    .with_scale(Vec3::splat(cube_size)),
                Collider::cuboid(1.0, 1.0, 1.0),
            ));
            parent.spawn((
                Mesh3d(cube_mesh.clone()),
                MeshMaterial3d(materials.add(Color::srgb(0.2, 0.7, 0.9))),
                Transform::from_translation(Vec3::splat(-cube_size))
                    .with_scale(Vec3::splat(cube_size)),
                Collider::cuboid(1.0, 1.0, 1.0),
            ));
        });
sweet sundial
#

that pattern should move to the children![] macro
otherwise no problem

halcyon dew
tough zealot
#

Neat! Thanks a lot

plush mica
#

I'm having an issue with my physics, I have a capsule collider but it looks like it keeps jumping when it hits an edge

#
                    RigidBody::Dynamic,
                    PlayerMarker,
                    Name::new("PlayerControlledObject (Avian2D physics)"),
                    Collider::capsule(4., 4.),
                    CollisionLayers::new(GameLayer::Player, [
                        GameLayer::Ground
                    ]),
                    Friction::ZERO.with_combine_rule(CoefficientCombine::Min),
                    Restitution::ZERO.with_combine_rule(CoefficientCombine::Min),
                    GravityScale(GRAVITY_SCALE),
                    RayCaster::new(Vector::ZERO, Dir2::NEG_Y).with_ignore_self(true),
                    LockedAxes::new().lock_rotation(),
                    Transform::from_xyz(50., -50., 0.),
                ));```
#
        let left = keyboard_input.any_pressed([KeyCode::KeyA, KeyCode::ArrowLeft]);
        let right = keyboard_input.any_pressed([KeyCode::KeyD, KeyCode::ArrowRight]);
        let horizontal = right as i8 - left as i8;

        rb_vel.x = horizontal as Scalar * MOVE_SPEED * time.delta_secs();```
sweet sundial
#

doing anything to apply vertical forces (eg tnua)?

plush mica
#

no I don't think so

sweet sundial
#

what's the geometry of the platforms? (debug gizmos may help)

plush mica
#

the map physics are being generated by bevy_ecs_tiled

plush mica
sweet sundial
plush mica
#

thanks

#

ok that's weird it jumped even higher now lol

sweet sundial
#

also probably shouldn't be multiplying your velocity by the dt

plush mica
sweet sundial
#

if you angle the raycaster does it change

plush mica
#

oh the examples I read on github had it multiplying by dt

#

i'll try

sweet sundial
#

dt is small

#

what's with the slowfall

plush mica
#

gravity

halcyon dew
#

do you have any code using the raycaster data? like for grounded check or jump input

plush mica
#

yeah but i'm not doing anything with it

#

still work in progress

#

I can check if the player is grounded, near an edge, etc. but I don't know why being near an edge causes it to jump ?

sweet sundial
#

these gifs are destroying my client

plush mica
#

sorry

sweet sundial
#

most people are not on a pixel 2

#

probably fine

#

anyway try replacing the level with a single hardcoded rectangle

plush mica
#

using a rectangle collider instead seems to have fixed the issue

vestal minnow
#

Is that a polyline collider? Afaik our collision detection library Parry doesn't fix internal edges for those

#

We need something like Box2D's chain shape, but Parry doesn't have that yet

visual sparrow
tough zealot
vestal minnow
#

Collision detection isn't done between static rigid bodies, but if they don't have RigidBody, they (currently) will compute contacts between each other

#

so you probably had a ton of unnecessary contacts being computed

#

this will most likely change in the near-ish future

halcyon dew
#

avian's docs really are something else, may well be the best I've seen in a crate

vague ether
#

Has anyone done pressure plates in avian? I tried but they spaz between pressed/released every frame

#

CollidingEntities alternates between detecting and not detecting my player entity every single frame/physics tick, causing my pressure plate to rapidly toggle on/off. I've tried sensors, FixedUpdate schedule, and various debouncing approaches but the underlying collision detection is still unstable

past escarp
vague ether
vague ether
past escarp
# vague ether

🤔 what does the spawn code for the pressure plate look like?

plush mica
wet niche
#

BTW, regarding Aiden's issue, I have been fighting this same issue for weeks now in my own project. It seems that e.g. using a capsule shape for a player controller collides with different bits of world colliders in each frame, leading to this repeated start/end collision toggling.

It seems like the (unreleased) "contact pruning" commit in avian/main (0aadef0c5267952197d76a51d328fa23ccf8e597) might resolve this. But currently I'm loath to use the branch from git since it's unreleased, and Cargo.toml still claims 0.3.0 so I can't use it with bevy_trenchbroom which pulls in 0.3.1 and conflicts. (And I don't feel like maintaining a fork just to fix the version 😉

Until then, I'm using a "debouncing" layer to consume OnCollisionStart/End events and only emit them to the rest of my app after the moving collider has actually moved more than 0.01 units.

visual sparrow
visual sparrow
#

A floating character controller can help with this

#

since it's never colliding anyways

wet niche
plush mica
vague ether
drifting marsh
#

question about cross platform determinism. I see code like this that uses cos

fn mass_properties(&self, density: Scalar) -> MassProperties {
        let volume = self.area().adjust_precision();
        let mass = volume * density;

        let half_external_angle = PI / self.sides as Scalar;
        let angular_inertia = mass * self.circumradius().adjust_precision().powi(2) / 6.0
            * (1.0 + 2.0 * half_external_angle.cos().powi(2)); // here

        MassProperties::new(Point2::origin(), mass, angular_inertia)
    }

Does using the enhanced-determinism feature somehow change the implementation of the cos?

visual sparrow
#

it uses a slower implementation that is guaranteed to work the same on all platforms

drifting marsh
#

how is it changing the implementation? I looked and Scalar seems to just be type Scalar = f64

visual sparrow
#

Or I guess a trait that is implemented for f32 could be used there?

#

Not sure honestly

sweet sundial
#

clearly it's linker shenanigans

halcyon dew
visual sparrow
vestal minnow
#

Both for generic math code and for automatically choosing between the std and libm versions based on features

vestal solstice
#

i have a ShapeCaster that is a child of the controller, and the ShapeCaster trails behind the controller

#

i already have another ShapeCaster on the controller itself

#

and it follows the controller 1:1

#

is there a way to have the ShapeCaster on the child follow the parent 1:1?

visual sparrow
#

@vestal minnow do you need help with the migration? 🙂

vestal minnow
vestal solstice
golden python
#

Hello, for those that remember, I've been having trouble getting the traction working for my avian physics based car controller for more than a week now, if anyone is interested, you can find the repo and more info in this message:
#math-and-physics message

little maple
visual sparrow
vestal minnow
#

So we'll need to change our collision events a bit to work with the event rework. I was thinking that perhaps it'd be best to just combine them into CollisionStart and CollisionEnd events that are used for both the observer API and MessageReader API.

#

For example, the CollisionStart event would be like this:

#[derive(EntityEvent, Message, Clone, Copy, Debug, PartialEq)]
pub struct CollisionStart {
    #[event_target]
    pub collider1: Entity,
    pub collider2: Entity,
    pub body1: Option<Entity>,
    pub body2: Option<Entity>,
    // flags: CollisionStartFlags, TODO
}

If used with observers as an EntityEvent, collider1 is the event target, while collider2 is the "other" collider. And if used as a Message, it's basically arbitrary which entity is which, like in Avian 0.3.

#

We could also keep the EntityEvent type and Message type separate, like CollisionStart and CollisionStarted, but uhh.. that naming isn't ideal, and I think it makes sense to combine them

#

(also in the future I'll most likely force colliders to be attached to bodies to have collision detection work for them, which would remove the Options here)

visual sparrow
fiery mortar
#

I am using avian3d when an object is set to Kinematic it passes through the floor if set to Dynamic it stops. I don't see anything in docs about this. To my knowledge Kinematic bodies should respect collisions but not be effected by forces. What could be wrong?
I am using linear velocity to move

wet niche
summer acorn
#

kinematic means you are fully in control of its position

#

so you can put it inside the floor if you want

fiery mortar
summer acorn
#

then dont use kinematic, just use dynamic and use impulses

fiery mortar
summer acorn
#

not really, afaik

fiery mortar
summer acorn
#

unity for example

fiery mortar
#

The way they are used collisions are respected. Maybe under the hood they don't and additional logic is provide so that they do

fiery mortar
summer acorn
#

im just talking about unity's api

visual sparrow
summer acorn
#

yeah this is pretty standard

fiery mortar
#

// Let animation control the rigidbody and ignore collisions.
void DisableRagdoll()
{
rb.isKinematic = true;
rb.detectCollisions = false;
}

#

detectCollisions is manually turned off

#

so it can't be Kinematic and respect collisiosn

#

but all of this doesn't matter

summer acorn
#

thats for other things colliding against the kinematic rigidbody

#

kinematic rigidbodies still generate collisions against other things, they just arent affected by them

wet niche
#

Does this mean you can get [On]CollisionStarted/Ended events for kinematic bodies interacting with the world, but you have to apply them to the position yourself?

visual sparrow
#

But you can also let them not be affected and force the dynamic rigid bodies out of the collision instead

wet niche
#

@ArticNative Are you making a character controller? There are some crates to assist with this (e.g. bevy-tnua, bevy_fps_controller which are recently updated)

fiery mortar
#

bevy tuna is not well documented

#

I need some hand holding here

#

I would prefer not to use external crates

#

I don't see it listed but is there a way to freeze rotations on an axis?

#

I am assuming I could set MaXAngularSpeed to 0

#

and make mass infinite so that is behaves as if it is kinematic

#

while respecting collisions

wet niche
#

I should take my own suggestions since I am using a dynamic body and not these crates. I use ```
LockedAxes::new()
.lock_rotation_x()
.lock_rotation_y()
.lock_rotation_z(),

fiery mortar
#

Do you set that at spawn?

wet niche
fiery mortar
#

That gives me exactly what I am looking for thank you

#

If I wanted to prevent other forces from acting on them how would you suggest I do that

#

I think the mass could have problems down the road

vestal minnow
#

It will act as if it had infinite mass from the POV of other dynamic bodies colliding with it, but it will still collide with kinematic and static bodies

vestal minnow
#

The bevy-0.17 branch now has the migration to 0.17.0-rc

#

I still need to update a lot of examples and docs, but it seems to compile at least

#

(cc @visual sparrow)

#

I should also rename our system sets to follow the FooSystems convention, though maybe in a follow-up

visual sparrow
#

This means I can port avian_pickup later broovy

#

And then rerecast

visual sparrow
#

Bad news: I'm getting this warning:
WARN bevy_app::plugin_group: You are replacing plugin 'avian3d::dynamics::solver::schedule::SolverSchedulePlugin' that was not disabled.

#

I don't think I actually am doing anything disallowed with that plugin? To my knowledge, my crate internals never add any Avian plugins, and my examples just add PhysicsPlugins

#

Hmm my Cargo.lock also exploded in size for some reason (+ 600 lines)

#

ran cargo duplicated-deps and... what?!

#

yes, I ran a cargo update before. I didn't check how it was in 0.16, but something looks mighty wrong here just at the first glance hmm

bold garnet
visual sparrow
#

@vestal minnow what do I use instead of GlobalAngularInertia now?

#

Just AngularInertia?

#

Or I guess ComputedCenterOfMass?

#

This is the context (I'm migrating tnua)


#[allow(clippy::type_complexity)]
fn apply_motors_system(
    mut query: Query<(
        &TnuaMotor,
        &mut LinearVelocity,
        &mut AngularVelocity,
        &ComputedMass,
        &GlobalAngularInertia,
        &mut ConstantForce,
        &mut ConstantTorque,
        Option<&TnuaToggle>,
        Option<&TnuaGravity>,
    )>,
) {
    for (
        motor,
        mut linare_velocity,
        mut angular_velocity,
        mass,
        inertia,
        mut external_force,
        mut external_torque,
        tnua_toggle,
        tnua_gravity,
    ) in query.iter_mut()
    {
        match tnua_toggle.copied().unwrap_or_default() {
            TnuaToggle::Disabled | TnuaToggle::SenseOnly => {
                *external_force = Default::default();
                return;
            }
            TnuaToggle::Enabled => {}
        }
        if motor.lin.boost.is_finite() {
            linare_velocity.0 += motor.lin.boost;
        }
        if motor.lin.acceleration.is_finite() {
            external_force.0 = motor.lin.acceleration * mass.value();
        }
        if motor.ang.boost.is_finite() {
            angular_velocity.0 += motor.ang.boost;
        }
        if motor.ang.acceleration.is_finite() {
            external_torque.0 = 
            // NOTE: I did not actually verify that this is the correct formula. Nothing uses
            // angular acceleration yet - only angular impulses.
            inertia.value() * motor.ang.acceleration;
        }
        if let Some(gravity) = tnua_gravity {
            external_force.0 += gravity.0 * mass.value();
        }
    }
}
#

Also, ExternalForce is now ConstantForce

#

am I correct in the assumption that ExternalForce used to be on every RigidBody, but ConstantForce isn't?

visual sparrow
#

Otherwise it looks to me like the gravity just explodes?

vestal minnow
#

However you can actually use ConstantLinearAcceleration/ConstantAngularAcceleration if you want to apply mass-independent "forces"

#

You can also try the Forces API

#

That one doesn't require manually adding components, and forces or accelerations get automatically cleared

visual sparrow
#

I'm just trying to port it

vestal minnow
#

In 2D, angular inertia is just a scalar value and doesn't change under rotation. So just ComputedAngularInertia

visual sparrow
vestal minnow
#

With Forces, yes

#

With the constant ones (the components), no

visual sparrow
#

Alright, let's see if I can get tnua running

#

I wish we had an Avian KCC

#

so I didn't have to port this haha

#

If no one tackles it before me, I'll have to work on that Avian KCC eventually

#

Since I need some features beyond Tnua and I'm definitely not patching that

vestal minnow
#

I wait for the day when I can work on fun stuff like that instead of the mess that is all the simulation island and contact graph stuff ferris_sob

vestal minnow
#

perchance

visual sparrow
#

I'd be delighted to team up again if you have time heart_lime

#

but also, no pressure, feel free to join another team then if you want 🙂

#

(or not at all if you don't have time lol)

vestal minnow
#

of course, it's always fun to jam with you 😄 we'll see how busy things are when it's jam time again

visual sparrow
visual sparrow
#

@vestal minnow just to confirm:
apply_acceleration(a) and apply_linear_impulse(a * mass) are the same, right?

#

And instead of querying &mut LinearVelocity and Forces in the same system (which gives me a conflict), I should use forces.linear_velocity_mut(), right?

#

asking because something clearly went wrong here hmm

vestal minnow
vestal minnow
#

accelerations and forces: applied continuously across the time step
impulses: applied immediately directly to the velocity

visual sparrow
#

Context: before:

#
#[allow(clippy::type_complexity)]
fn apply_motors_system(
    mut query: Query<(
        &TnuaMotor,
        &mut LinearVelocity,
        &mut AngularVelocity,
        &ComputedMass,
        &GlobalAngularInertia,
        &mut ExternalForce,
        &mut ExternalTorque,
        Option<&TnuaToggle>,
        Option<&TnuaGravity>,
    )>,
) {
    for (
        motor,
        mut linare_velocity,
        mut angular_velocity,
        mass,
        inertia,
        mut external_force,
        mut external_torque,
        tnua_toggle,
        tnua_gravity,
    ) in query.iter_mut()
    {
        match tnua_toggle.copied().unwrap_or_default() {
            TnuaToggle::Disabled | TnuaToggle::SenseOnly => {
                *external_force = Default::default();
                return;
            }
            TnuaToggle::Enabled => {}
        }
        if motor.lin.boost.is_finite() {
            linare_velocity.0 += motor.lin.boost;
        }
        if motor.lin.acceleration.is_finite() {
            external_force.set_force(motor.lin.acceleration * mass.value());
        }
        if motor.ang.boost.is_finite() {
            angular_velocity.0 += motor.ang.boost;
        }
        if motor.ang.acceleration.is_finite() {
            external_torque.set_torque(
                // NOTE: I did not actually verify that this is the correct formula. Nothing uses
                // angular acceleration yet - only angular impulses.
                inertia.value() * motor.ang.acceleration,
            );
        }
        if let Some(gravity) = tnua_gravity {
            external_force.apply_force(gravity.0 * mass.value());
        }
    }
}
#

after:

#

#[allow(clippy::type_complexity)]
fn apply_motors_system(
    mut query: Query<(
        &TnuaMotor,
        &ComputedAngularInertia,
        &Rotation,
        Forces,
        Option<&TnuaToggle>,
        Option<&TnuaGravity>,
    )>,
) {
    for (motor, inertia, rotation, mut forces, tnua_toggle, tnua_gravity) in query.iter_mut() {
        match tnua_toggle.copied().unwrap_or_default() {
            TnuaToggle::Disabled | TnuaToggle::SenseOnly => {
                return;
            }
            TnuaToggle::Enabled => {}
        }
        if motor.lin.boost.is_finite() {
            *forces.linear_velocity_mut() += motor.lin.boost;
        }
        if motor.lin.acceleration.is_finite() {
            forces.apply_linear_acceleration(motor.lin.acceleration);
        }
        if motor.ang.boost.is_finite() {
            *forces.angular_velocity_mut() += motor.ang.boost;
        }
        if motor.ang.acceleration.is_finite() {
            forces.apply_torque(
                // NOTE: I did not actually verify that this is the correct formula. Nothing uses
                // angular acceleration yet - only angular impulses.
                inertia.rotated(rotation.0).value() * motor.ang.acceleration,
            );
        }
        if let Some(gravity) = tnua_gravity {
            forces.apply_linear_acceleration(gravity.0);
        }
    }
}
visual sparrow
#

lemme revert that

#

wait it used to be a force

#

so the acceleration should behave the same now, right?

#

Hmm I guess it could be expecting a constant force

#

AFAICT that was how this piece of code worked before

#

this intentional?

#

oh I need to deref it, silly me

vestal minnow
#

I guess the main difference is that the old code overwrites the force and torque, while the new one adds to it. But that only matters if there were existing forces that should be cleared for whatever reason, it gets cleared at the end of the time step anyway

vestal minnow
#

just, more performant to add acceleration directly

#

internally it turns it into acceleration anyway, so it's kinda pointless to convert an acceleration to a force only to have it converted back again

visual sparrow
visual sparrow
# vestal minnow Or yeah those two are actually exactly the same in this case

I also tried a version with constant forces, just in case:

#[allow(clippy::type_complexity)]
fn apply_motors_system(
    mut query: Query<(
        &TnuaMotor,
        &mut LinearVelocity,
        &mut AngularVelocity,
        &ComputedAngularInertia,
        &Mass,
        &Rotation,
        &mut ConstantForce,
        &mut ConstantTorque,
        Option<&TnuaToggle>,
        Option<&TnuaGravity>,
    )>,
) {
    for (
        motor,
        mut linare_velocity,
        mut angular_velocity,
        inertia,
        mass,
        rotation,
        mut external_force,
        mut external_torque,
        tnua_toggle,
        tnua_gravity,
    ) in query.iter_mut()
    {
        match tnua_toggle.copied().unwrap_or_default() {
            TnuaToggle::Disabled | TnuaToggle::SenseOnly => {
                *external_force = Default::default();
                return;
            }
            TnuaToggle::Enabled => {}
        }
        if motor.lin.boost.is_finite() {
            linare_velocity.0 += motor.lin.boost;
        }
        if motor.lin.acceleration.is_finite() {
            **external_force = motor.lin.acceleration * mass.0;
        }
        if motor.ang.boost.is_finite() {
            angular_velocity.0 += motor.ang.boost;
        }
        if motor.ang.acceleration.is_finite() {
            **external_torque =
                // NOTE: I did not actually verify that this is the correct formula. Nothing uses
                // angular acceleration yet - only angular impulses.
                inertia.rotated(rotation.0).value() * motor.ang.acceleration;
        }
        if let Some(gravity) = tnua_gravity {
            **external_force += gravity.0 * mass.0;
        }
    }
}
visual sparrow
# visual sparrow

The screen shake here looks like a typical artifact of interpolation not working

#

OOOH

#

Now I wonder if my migration of the crate is correct and the test playground is just borked

#

let me try in another project

calm sundial
#

We really need some builtin solution. Collide and slide or something.
This would help to test Avain before release and help users a lot.

visual sparrow
#

someone just needs to pick up the bits and pieces

visual sparrow
#

I blame the playground app then

#

but not fixing that

#

HOWEVER

#

I do get this one here too:

WARN bevy_app::plugin_group: You are replacing plugin 'avian3d::dynamics::solver::schedule::SolverSchedulePlugin' that was not disabled.
#

and sometimes, but not always, these here when the crates on the right spawn hmm

2025-09-16T17:41:58.565993Z  WARN avian3d::dynamics::rigid_body::mass_properties: Dynamic rigid body 89v0 has no mass or inertia. This can cause NaN values. Consider adding a `MassPropertiesBundle` or a `Collider` with mass.
2025-09-16T17:41:58.566006Z  WARN avian3d::dynamics::rigid_body::mass_properties: Dynamic rigid body 88v0 has no mass or inertia. This can cause NaN values. Consider adding a `MassPropertiesBundle` or a `Collider` with mass.
2025-09-16T17:41:58.566010Z  WARN avian3d::dynamics::rigid_body::mass_properties: Dynamic rigid body 87v0 has no mass or inertia. This can cause NaN values. Consider adding a `MassPropertiesBundle` or a `Collider` with mass.
2025-09-16T17:41:58.566012Z  WARN avian3d::dynamics::rigid_body::mass_properties: Dynamic rigid body 86v0 has no mass or inertia. This can cause NaN values. Consider adding a `MassPropertiesBundle` or a `Collider` with mass.
#

It's just this:

fn spawn_crate(trigger: Trigger<OnAdd, Crate>, mut commands: Commands, assets: Res<AssetServer>) {
    let model_path = Crate::CLASS_INFO.model_path().unwrap().to_string();
    let scene_path = GltfAssetLabel::Scene(0).from_asset(model_path);
    commands.entity(trigger.entity).insert((
        SceneRoot(assets.load(scene_path)),
        RigidBody::Dynamic,
        ColliderConstructorHierarchy::new(ColliderConstructor::ConvexHullFromMesh)
            .with_default_density(ColliderDensity(100.0)),
    ));
}
#

which IMO looks correct to me?

#

so I blame Avian for that warning 😛

vestal minnow
vestal minnow
visual sparrow
visual sparrow
visual sparrow
# visual sparrow

I suspect this doesn't happen when that warning is not present, let me try

vestal minnow
#

wat

visual sparrow
viral goblet
#

How would you get the ContactManifold for CollisionStarted?
(Since it has less information than ContactPair in Collisions)
Asking because I'm trying to find a way to detect the exact point of collider intersection from a CollisionStarted event

vestal minnow
#

Get the ContactPair from Collisions based on the colliders involved

#

(via Collisions::get)

clever quail
#

Is there going to be a release before 0.17?

I have code that relies on the main branch to work, I am unlikely to be ready to migrate before Avian, should I just use latest hash before main breaks 0.16?

vestal minnow
#

Most likely no release before 0.17

#

I think I'm going to keep main on 0.16 at least until I've sorted out some of the contact graph bugs and simulation island stuff, and keep the 0.17 migration on the bevy-0.17 branch for now

viral goblet
vestal minnow
#

Also, tangentially related: I've been thinking that I might change some of our "release processes" moving forward, to have things progress at a nicer cadence and to reduce the stress and time drain involved with each release

#

Namely, smaller releases, more often (maybe aim for 2 per cycle), and also consider finally moving migration guides and release notes to be stored in-repo similar to Bevy

visual sparrow
#

I would like to do RC releases, but that's blocked by Avian

#

It's fine if it's buggy

vestal minnow
#

but frankly that's hella stressful and I always have way too much work at the end of each cycle lol

visual sparrow
#

Nowadays I like to get a release out that is just "old version + migration"

#

that way the real next release can cook however long it wants

vestal minnow
#

I really want to get the simulation island stuff fully done and working but Nise's networking problems with it are killing me bavy

#

I spent some time today learning more about the basics of game networking to at least understand the core concepts of what's happening better lol

vestal minnow
#

Which in the case of e.g. Avian can often differ quite a lot

visual sparrow
clever quail
viral goblet
# viral goblet How would you get the `ContactManifold` for `CollisionStarted`? (Since it has le...

I've made this to extract the intersection locations:

    let mut contact_points = Vec::new();
    for manifold in &contact_data.manifolds {
        for point in &manifold.points {
            contact_points.push(point.local_point1);
        }
    }
    contact_points
}```

but it's unclear (to me) from the docs:
1. Why should it matter whether I use `local_point1` vs `local_point2`
2. Are these locations global? Are they relative to the collision entity's transform?
sweet sundial
#

they're relative to, respectively, entity1 and entity2

viral goblet
dire viper
#

Why do joints have damping set to 1.0 by default? Seems to be a bit annoying and surprising design.

Currently bolting two bodies together with a FixedJoint will slow their movement down.

sweet sundial
#

are you sure? that doesn't sound like what damping should be doing

vestal minnow
#

It should also only dampen the relative velocity of the bodies, so it's a bit weird if it meaningfully slows down the bodies for a fixed joint 🤔

golden python
#

Hello, what is the easiest way to make a ColliderConstructorHierarchy not affect children ? Only making a collider for the scene root contained on the same entity

knotty thicket
sweet sundial
#

does that have a mesh component option? thought it'd need an observer at least

visual sparrow
dire viper
#

Is there a recommened way to get LinearVelocity from a child Entity that doesn't have it but has a parent with it (and rigid body) somewhere in the hierarchy?

visual sparrow
dire viper
#

Not a collider

clear dew
#

ahh

#

.iter_ancestors()

#

one sec

vestal minnow
#

You can manually compute the velocity at a point using lin_vel + ang_vel.cross(offset), where offset is a vector from the rigid body's center of mass to the desired point, in this case the child's position

dire viper
#

I was cooking this:

fn component_from_ancestor<'a, T: Component>(
    start: Entity,
    parents: &'a Query<&'a ChildOf>,
    components: &'a Query<&'a T>,
) -> Option<QueryItem<'a, &'a T>> {
    if let Ok(component) = components.get(start) {
        return Some(component);
    }

    for ancestor in parents.iter_ancestors(start) {
        if let Ok(component) = components.get(ancestor) {
            return Some(component);
        }
    }

    None
}
clear dew
clear dew
#

i stole this from jan

vestal minnow
#

If you're just asking for how to get the rigid body's LinearVelocity, and not strictly the velocity of the child (if it is offset) then yeah something like that'd work

visual sparrow
dire viper
#

Ideally it would be the offset velocity, but that might be good enough in this case

thin osprey
#

does fixedupdate run before or after update?

knotty thicket
thin osprey
#

yeah :( I was hoping it was wrong lol

knotty thicket
#

There's no way to tell when colliders have generated is there?

#

like if you're doing a convex hull or trimesh or whatnot in a ColliderConstructor?

visual sparrow
knotty thicket
#

it doesn't come up that often, but I think that's because people are working around it by basically sleep(frames)ing

visual sparrow
little maple
#

I have a loading state that checks every frame to make sure all the colliders are loaded

knotty thicket
quaint parcel
glad wraith
#

I can't seem to despawn bullets without it crashing when they collide with something in the 0.17 version. Should I be despawning them some other way?

little maple
# glad wraith I can't seem to despawn bullets without it crashing when they collide with somet...

🤔 I kinda already think despawning can be a bit of a footgun and this might be an indication of an underlying issue in avian, but I personally despawn by adding a marker component (I just call it Despawn) and then I have a system that despawns entities with that component in FixedPostUpdate (with .after(TransformSystem::TransformPropagate) but I honestly haven't checked if that's necessary)

knotty thicket
#

also, there's no 0.17 version published, so it would be useful to specify what branch you're using 😅

glad wraith
#
avian2d = { git = "https://github.com/ChristopherBiscardi/avian.git", branch = "bevy-0.17-temporaries", features = ["serialize", "simd", "parallel"] }
glad wraith
little maple
vestal minnow
#

It should hopefully be fixed on a local branch of mine, I just still need to properly figure out why/how Nise's networked game crashes

#

As for why these things panic instead of e.g. emitting warnings, a lot of these bugs can leave the internal structures in invalid states that could completely break collisions and cause things to phase through each other, report non-existent contacts, or otherwise mess things up in a game-breaking way. They're invariants that should never be broken

#

And to be clear there should pretty much never be crashes, they're just bugs that need to be fixed

little maple
vague pebble
visual sparrow
#

(When using ColliderConstructorHierarchy)

knotty thicket
vague pebble
knotty thicket
#

I haven't looked into it at all yet but it's on my list for .. some day I guess lmao

glad wraith
dreamy viper
#

For some reason the debug plugin doesn't seem to work properly for me; I'm using

        app.add_plugins(PhysicsDebugPlugin::default())
            .insert_gizmo_config(
            PhysicsGizmos {
                aabb_color: Some(Color::WHITE),
                collider_color: Some(BLUE.into()),
                raycast_color: Some(GREEN.into()),
                raycast_point_color: Some(RED.into()),
                hide_meshes: true,
                ..default()
            },
            GizmoConfig::default(),
        );

Is there anything else I need to do?

little maple
dreamy viper
#

Actually I think i didn't have a collider on my entity.
But for example I don't see the raycast_point_color ; is it possible to show a dot at the raycast point of impact?

royal helm
#

wd

vestal solstice
#

is there any utility that just gets the min distance between 2 colliders?

visual sparrow
pulsar bone
#

There's a distance function

visual sparrow
paper maple
#

In 2D, is there a provided way to triangulate a polygon for convex_decomposition ? I don't see anything obvious

#

sorry i cant remove the embed

visual sparrow
#

<https://some_link.com>

paper maple
#

Is there any point in removing holes from my geometry ? or will it be fine with a collider with holes produced by convex_decomposition ?

sweet sundial
#

it doesn't care if there are holes, pretty sure it's (at least equivalent to) just taking the hull of all vertices

paper maple
#

Also it's parameterized to take edges, rather than vertex indices ? a bit confusing

sweet sundial
#

pretty sure (again) that's basically just an optimization

#

there's a param struct that makes it possible to have concavity, so that's not a complete picture

#

regardless the result of a convex decomp is a compound of convex polyhedra

snow urchin
#

I forgot, what do you call the thing you do to preserve color?

vestal solstice
paper maple
#

I don't understand... convex_decomposition seems to be messing with the triangulation I gave it, generating what is effectively a convex hull of my input. All the holes are getting removed (even though my index buffer should specify how to construct the triangles such that the holes are preserved) ??

#

Maybe I can just use triangle + compound to get my desired result ?

sweet sundial
#

what are you trying to do? sounds like you just want a mesh collider

sweet sundial
#

or otherwise check various still states

abstract tendon
#

when two colliders touch, i want to get where they are touching. ive looked at the docs but couldnt find something similar

sweet sundial
#

do you have the collision pair?

#

from the contact graph

paper maple
#

the triangles are quite scuffed though

#

Should add some Steiner points, but i don't know how to get them

sweet sundial
#

do a trimesh instead, there's some kind of internal corner detection

#

where are you getting the mesh?

paper maple
sweet sundial
#

it looks tile-based, so there's something turning tiles to triangles

paper maple
#

im generating them with i_overlay and i_triangle

sweet sundial
#

from where?

paper maple
abstract tendon
# sweet sundial do you have the collision pair?

no but lemme explain you more detailed. i have a player collider with kinematic rigidbody and wall with static rigidbody. since i want to do my own player movement physics i need to know if my player is touching a collider and if it does, where is the contact point

halcyon dew
abstract tendon
#

damn thanks

halcyon dew
echo parcel
#

When will avian be compatible with 0.17?
Currently getting error hell from avian components

Version is the newest from the github's main branch:

avian3d = { git = "https://github.com/Jondolf/avian" }
vestal solstice
echo parcel
knotty thicket
#

try cargo tree -i bevy

#

I've been using that branch successfully since I made the temporaries patch, which is still the latest commit

little maple
#

is it possible to wake a sleeping body with a sensor?

vestal minnow
echo parcel
little maple
# vestal minnow `commands.queue(WakeUpBody(entity))`

hmm, I'm wondering if there's a way to do that with a sensor.. actually not even wake up, just get a collision event. I have a sensor that represents a force field and it expands by modifying it's scale.. but if it hits a sleeping rigid body it doesn't detect that as a collision

#

I'm wondering if that's an intentional commission or maybe I'm doing something wrong 🤔

vestal solstice
# echo parcel

since the issue is glam it is best if you do cargo tree -i glam

echo parcel
vestal solstice
#

oof

#

cargo update

#

#1124043933886976171 message

vestal solstice
#

does kinematic bodies use ExternalForces or is it trully only LinearVelocity and AngularVelocity?

vestal minnow
little maple
#

I feel like someone asked about something similar recently... creating a collider that is a sensor and scaling it.. specifically to just track what it collides with. If it hits something that is sleeping... is there any way to get what entity that is?

or is this not the right way to approach this problem?

arctic fulcrum
#

If I have two rigid bodies and I want them in an arbitrary (programmatic) relative position and orientation with a bit of springiness- how do I do that?

The FixedJoint can set an anchor position, but not an anchor rotation - is this an oversight or do I not understand how it's supposed to be used?

vestal minnow
#

On the main branch it supports a full local frame, i.e. anchor point and basis orientation

#

It was just something that wasn't implemented before

vestal minnow
vestal minnow
little maple
vestal minnow
#

Nah it's just the 2D sensor example from the repo, but moving the sensor instead of the character, and having the character sleep

#

I can try scaling too

#

same thing when changing scale

#

oh btw I'm using main for this, are you on the simulation island branch?

little maple
#

hmm, ok, that's good to know. I must be setting up something incorrectly, but I should be able to reference that example. I only really care about the collisionstarted event

#

yeah I'm using the simulation island branch because it felt more tropical to me

vestal minnow
#

hmmm interestingly everything seems to work correctly on that branch

#

in my scene

#

even fixing the bug on main

little maple
#

hah, ok. interesting, hmm. I'll re-check and compare against the example. Sorry about that

vestal minnow
#

No worries, it's very possible there's still something weird going on there so it's good to test things

#

could also try the sensor with/without a RigidBody, and see if the type of rigid body affects anything

#

(if it's static then iirc it won't detect other static bodies at the moment)

#

once we have the BVH broad phase stuff setup, I'll very likely split out sensors to have their dedicated logic separate from "normal" colliders, which should both significantly simplify some internals and also improve sensor perf

rocky seal
#

post-force-rework, should i prefer accessing e.g. LinearVelocity thru the component itself or via Forces::linear_velocity?

vestal minnow
vestal solstice
#

does avian work well having the collider as a child so that the parent entities position is at the ground?

glad wraith
#

How can I despawn stuff without crashing with 0.17 + Avian?

visual sparrow
#

And despawning things in a dedicated despawning system set

#

That’s not Avian specific though

little maple
visual sparrow
#

Oh I see

#

Then yeah, change the error handler to not panic until you figure out something better

pseudo mirage
#

It seems like I found a bug? Not sure if it's already known or an error on my side.
Basically, when I put a collider with a sensor as the child of a moving entity and give it a Rigidbody component (important!) then the collider seems to not be affected by the Transform of the child. Any rotation or translation of the child gets reset to 0.0 even if the visible mesh is in the correctly translated place (my usecase is a hitbox for an attack and I use the mesh for debugging, took me a while to understand that the collider isn't aligned with the mesh).
It works fine without the Rigidbody component but then it starts lagging badly the moment it collides with anything so that is not an option.

#

Here is a picture, the blue box is the correctly translated hitbox visualized by a mesh. But when I put the Rigidbody component on it, the actual collider is exactly on the player character and not translated to the right like the mesh.

#

I am using Tnua… could that cause some sort of desync between the physics position and the transform?

#

Will investigate further when I have time

fallow pike
#

Can someone help?

#

Why my wheels moving left right

vestal solstice
#

do you have locked axis?

fallow pike
#

But why i need this?

#

I want my car rotating

vestal solstice
#

but your wheel should only rotate on 2 of 3 axis

fallow pike
fallow pike
#

Im in 2d

#

If i add locked axis car seems normL

#

But

#

I want rotating car

vestal solstice
#

on the wheel rigid body

fallow pike
fallow pike
vestal solstice
fallow pike
#

Really

#

You can run code and thee what they moving left-right and car not moving

vestal solstice
fallow pike
#

?

fallow pike
vestal solstice
#

since it is 2d, you want to see the wheels pitch, right? but they are rolling or yawing?

fallow pike
#

I mean they moving

#

Like i set torque

#

And when transform changes

vestal solstice
#

Friction then?

fallow pike
#

I maybe recorda video

vestal solstice
#

hmm, the joints are very springy

fallow pike
#

They really moving left right as i sayed

fallow pike
#

I set stiffness like in normal car

#

And wheels in my car not moving left right

vestal solstice
#

yeah, i've never used joints so i don't know how to set the proper constraints

fallow pike
#

Maybe creator of physica plugin can help me?

sweet sundial
#

share the parameters of the joints?

#

also, how are you applying power (if you are)

vestal solstice
sweet sundial
#

ah, no embed on mobile lol

fallow pike
#

How i can make what

fallow pike
vestal minnow
# fallow pike Maybe creator of physica plugin can help me?

If you want a wheel that can rotate, and can only move up and down with some springiness, I think you'd maybe want a combination of a PrismaticJoint (to restrict translation to the local vertical axis), DistanceJoint (to emulate the suspension), and RevoluteJoint (to pin the wheel to a point it can rotate around).

#

This approach will just need two bodies for each wheel:

  • An "axle" body that is attached to the frame of the car with a PrismaticJoint, and maybe also a DistanceJoint for the suspension. This body does not rotate relative to the car frame, it just moves up and down.
  • The actual wheel body that is attached to the axle body with a RevoluteJoint.
#

Since the axle body exists just to make the joint setup work, it probably doesn't have a collider, so you'll need to specify its Mass and AngularInertia manually

fallow pike
#

But yeah

#

Will be cool, if avian have wheel joint

vestal minnow
#

Yeah, there's still a lot of improvements to be made to our joint stuff. It'd also be cool to have some official examples for cars and other vehicles in the repo

#

On another note, a quick update: Since I've still been struggling to get the persistent simulation island PR working properly with (Nise's) networking, and 0.17 is looming around the corner, I just spent yesterday making it so that you can simply disable the IslandPlugin if it's causing problems. I think I'm going to merge that PR today, iterate on further improvements or alternative approaches later, and switch gears to polish + release prep

fallow pike
#

If collider is normal -> ok

fallow pike
#

Without collider like 0.2 car always go through ground

vestal minnow
#

If it works with a collider for the axle, then that's fine yeah

#

I'm guessing it goes through the ground because our current joints can kinda overpower contacts sometimes

#

When I have the newer impulse-based joint solver working eventually, it hopefully shouldn't do that 🤔

vague pebble
#

If I add an transform to an entity that has position and rotation, will it inherti the transform? Meaning will it convert position rotation to transform?

vague pebble
visual sparrow
#

I wouldn't bet money on it

#

well maybe

#

like uuh

#

CHF 2.-

#

I'm like

#

65% sure it's the case

#

does that answer it? broovy

vague pebble
#

So there is a 35% chance yo uwould lie to me

#

interesting

#

hahhaha

visual sparrow
vague pebble
visual sparrow
#

-# ||Actually it was Blastoise||

little maple
#

||gengar is clearly the best pokemon||

little maple
#

or try to assist at least

vestal minnow
visual sparrow
#

@vestal minnow I need to do some raycasts to nearby lights to get a CPU estimate of the illumination, and I thought I could do that by first doing a sphere or AABB check to gather the lights that are close enough to even be considered. Do you have a tip on how this should be done? I guess I could use the point collider hack we recently discussed to add colliders and collision layers to each PointLight and co. and then do SpatialQuery::shape_intersections with a sphere and the light source collision layer filter.

#

Would that be a sensible approach, assuming point colliders even work?

fallow pike
vestal minnow
#

If a "point collider" with a radius of zero doesn't work, you can just try a tiny sphere

clear dew
vestal minnow
#

yeah I'm aware, it was around the same time as AVBD

vestal minnow
#

I've updated the bevy-0.17 branch to latest main (includes simulation islands!), updated docs, removed manual type registrations, and renamed our system sets to the new FooSystems naming convention. That branch is now more or less "ready" for the 0.17 release :)
https://github.com/Jondolf/avian/pull/815

GitHub

Objective
Update Avian to Bevy 0.17!
Solution

Migrate to Bevy 0.17.0-rc
Rework collision events to work with the new event architecture

Combine CollisionStarted, CollisionEnded, OnCollisionStart,...

#

I noticed a bad perf regression for debug builds after the simulation island PR, but I discovered that it's just because it runs some rather expensive correctness validation if debug_assertions are enabled. I just opened #826 to fix that with a new validate feature flag

visual sparrow
vestal minnow
#

uhh not sure, didn't test that yet

#

if it was somehow related to sleeping, then probably yeah

visual sparrow
#

Alright, compiling now

visual sparrow
#

Bad news: I still get this

vestal minnow
#

yeah that isn't fixed still

visual sparrow
#

When you're touching that part anyways, mind using NameOrEntity in that warn message?

vestal minnow
#

Yeah good idea, there's probably some other places where we could do that too

visual sparrow
#

Interested in some Foxtrot benches?

vestal minnow
#

Sure! Though it's probably not the heaviest thing in terms of physics

visual sparrow
vestal minnow
#

true

visual sparrow
#

though I would love to see how this influences Chainboom with max body parts hehe

vestal minnow
#

simulation islands may help a lot of larger scenes by letting more dynamic bodies sleep properly

visual sparrow
vestal minnow
#

the next big thing would probably be the BVH broad phase, which I'll try to finally get done after the release

visual sparrow
#

Probably still easier to just have point colliders

#

@vestal minnow there ya go

#

some lovely frame times!

#

Also, the sleeping looks much more stable than last time I checked

#

You can see that there are two bugged instances though

#

It's a little bit confusing how non-sleeping dynamic bodies have the same color as static bodies though

#

because it feels like "strong color = doing computation"

#

(this is in release mode ofc)

visual sparrow
# visual sparrow

the lamp standing still and sleeping after wiggling around is something I distinctly remember not being possible last time I checked 😄

#

So it's cool that that works now!

#

Weird that the comparatively simple cuboid crate doesn't seem to sleep on the flat table

vestal minnow
#

You can also increase the SleepThreshold to allow them to sleep easier

#

Can't make it too large though, or you will have stuff like rolling objects stopping abruptly when they should keep rolling

vestal minnow
visual sparrow
# vestal minnow You can also increase the `SleepThreshold` to allow them to sleep easier

In birds, sleep consists of "periods of eye closure interrupted by short periods of eye-opening." During the short periods of eye-opening, electroencephalographic (EEG) studies indicate that the birds are still sleeping; the voltage level in the brain is identical. Birds restore their arousal thresholds during sleep. During their short eye-open ...

#

JK. Since there are no docs yet for the newest avian, where can I find the SleepThreshold?

#

Is that on a plugin?

vestal minnow
visual sparrow
#

It uses a translucent Mesh3d and retained gizmos

visual sparrow
#

I suppose it goes on the collider?

vestal minnow
#

It should be in the prelude

#

yeah

#

*on the body

visual sparrow
# vestal minnow *on the body

That will fit right into this observer I have anyways bavy

fn enable_interpolation(
    add: On<Add, RigidBody>,
    rigid_body: Query<&RigidBody>,
    mut commands: Commands,
) {
    let Ok(rigid_body) = rigid_body.get(add.entity) else {
        return;
    };
    if rigid_body.is_dynamic() {
        commands.entity(add.entity).insert(TransformInterpolation);
    }
}
vestal minnow
pseudo mirage
#

Also something else, when I dont have a Rigidbody component on there it correctly syncs with the globaltransform and thus the sensor collission detection works. But… it starts lagging baad the moment any collission is detected (on 0.3.1 btw)

visual sparrow
#

is there an intuitive meaning behind that number?

#

like, does 0.45 have a physical meaning like "0.45 newtons are treated as 0"?

#

oh it says in the docs

#

it's velocity

#

so 45 cm per second are treated as sleeping?

#

that... doesn't sound right