#Avian Physics
1 messages ยท Page 4 of 1
but in general just striving for unified APIs and nativeness, like in this case using Time instead of completely separate resources just for physics
Honestly using Time seems like the right call ... I'm definitely gonna do that refactor once I migrate to 0.12 ๐
These constants get used everywhere troughout my code, and it's pretty messy
/// The desired time between ticks
pub const TIMESTEP: f32 = 1.0 / 60.0;
/// The time between ticks but in nano seconds
pub const TIMESTEP_NANO: u64 = 1_000_000_000 / 60;
Luckily they live in a separate crate so it doesn't create dep cycles
This is literally the whole crate ๐
I like the missing_docs warning there
Gotta make sure the 4 types in this crate are documented ๐
Also 0.12 uses a fixed timestep of 64 Hz to avoid a refresh rate pitfall and to have a lossless conversion into f32/f64, so idk if physics should also use it
I changed the default for bevy_xpbd to match it but I don't know how useful it is in our case
Doesn't actually fix the refresh rate pitfall, but rather makes it guaranteed it always behaves roughly the same .... The lossless conversion is important if you're working with Duration <-> f32 conversions tho I think
TIMESTEP and TIMESTEP_NANO aren't actually the same value, but they're fairly close, but if you convert between them it becomes less close
Honestly I see physics run at pretty arbitrary speeds, if there's some interpolation it's impossible to notice
Bevy doesn't have interpolation but I suspect Joy has plans for that, since I've heard a lot of mentions of not wanting workarounds that would merely hide the lack of interpolation
yeah that'd be nice
I think it's fixed now but I remember godot defaulting to 50FPS physics
I don't want to deal with the Transform spagetti required to get interpolation working when the SyncPlugin is already quite an abomination :P
And it gets worse too, because you might need to raycast on those interpolated entities ๐
Tho tbf that sounds like a GPU picking problem ...
it's on main yeah, not in 0.2
Everything is on main ๐
Ask me anything, main is the answer
Where's the SDF collisions? 
Ummm...
main in my game's repo ๐
Just wait for the day after 0.3 releases, massive features drop instantly... at least if we look at 0.2's release
Watch as bevy_xpbd 0.3 releases with my SDF collisions
A few days left unless there's another delay ๐
I could've released for bevy 0.11 but I don't want to do a massive 0.3 and then a tiny 0.4 right after
Luckily bevy_xpbd main is still 0.11
- 0.12 was supposed to be released over a week ago
no, that'd be breaking
semver
mainly the Time thing and maybe updating the character controller examples to handle movement in PhysicsSchedule, and proper release notes and the blog post
and maybe a migration guide for once, if I can remember what needs to be migrated
And you only have until this weekend ๐
I'm also going to a nuclear power plant for a school trip on thursday
Sounds less intimidating that migrating a whole game to sdf collisions before 0.12 tho ... I mean it's not like I need to migrate to 0.12 on day 1 ... But who else is gonna migrate a dead UI library to 0.12 when the 0.11 PR didn't even get merged? 
Better make sure to not cause contact stability issues there ... That would be very bad
Some explosive contacts
An hour ago I thought Bevy 0.12 somehow made the contact stability issues reappear since the cubes example was drifty/jittery again, got some severe ptsd from that
but turns out I had changed the cubes example to trigger velocity changes every frame which makes sleeping not work correctly
Understandable, I'm already getting PTSD every time I think of how to construct an SDF for my dungeons and realize they would be bound 
https://iquilezles.org/articles/interiordistance/
Specifically this problem but in reverse
you had that link ready lmao
I have it bookmarked
I've only been struggling with this issue a few days, ever since I realized that the reason spheres sometimes float is because my test SDF is wrong
But now every time I think of an SDF I realize it's bound
Bevy doesn't have anything SDF built in I think
My game uses kayak_ui which has msdf fonts, and my sdf collisions ... That's not enough tho ...
Sadly I also need to define my own logic for all primitives, even tho they could easily be shared with other things ... primitives shapes when
sdf text with sdf collisions and physics
one day after 0.3
Make a UI element out of SDFs, then make it so that you can pick it up and the text will shake around inside it ๐
The button will then do whatever the letters spell out
Collisions with letters might actually be somewhat possible if I implement support for arcs and the font is rounded ๐ค
Or just figure out the math for true SDFs of each character in the font 
https://www.shadertoy.com/view/clVXWc
I mean we have a true SDF for an S already ๐ค
Wow, I just noticed that this became the crate-help thread with the most comments today or yesterday
even though half of the questions seem to be in #math-and-physics :p
I mean bevy_xpbd is one of the most important bevy plugins
There is no rapier. Only xpbd
Honestly I'm not even sure who's telling all the beginners to use rapier 
I looked into it a while ago ... And I'm not sure if the gizmos have a delay ... The main thing you notice it with on xpbd is the aabbs
But that's because the aabbs are from before physics runs
idk it seems weirdly big in that video
yeah I think colliders should work but AABBs are delayed
I mean technically the AABBs are correct they just show you weird data ... Like "Here's the swept aabb for the latest physics update"
I don't want to convert people personally at least ๐ feels kinda weird considering I'm the author (along with Johan, kinda the original creator)
and rapier is still better for some people
We already have a lot more users than back in the 0.1 days at least ๐ค
I remember when I switch to xpbd ... So many bugs ... But now almost all issues I have in my game are caused by parry
yeah I feel like 0.3 is the first release where I feel comfortable recommending it to people unless they need specific features that are missing
0.1 and 0.2 were too buggy and filled with caveats
also I'm really proud of the 0.3 docs for the most part
code example coverage is pretty great
- much better crate-level docs
Now we just need a BVH-accelerated broadphase so it also performs well ... At least I can start testing my BVH once I migrate my game to SDFs ๐ค
Performs well with many colliders*
Because with a low number of colliders rapier has a ton more overheaad
At some point I might also make a lot more components optional, like a static body doesn't need any mass properties, velocity or forces, so we could just not insert them automatically
main caveat is that queries can be a bit more annoying
but for an ECS and its composable nature I think it makes sense to not have a bunch of unnecessary components, because at that point it resembles a fixed RigidBody object or something
Not adding components you don't need sounds like general good practice
I wanna ask: are deltas necessary (for movement, etc.)? I'm looking through the examples, but it looks like some examples use it but some don't. I'm also having a weird bug where the character gets launched at light speed when the startup is a bit laggy (I'm guessing the delta was too high).
It depends on what you are using. If you overwrite velocity you don't need to set deltas. If you're applying a force you probably want to multiply it by the fraction of a second it was active for
I see, I guess I misassumed that this is not necessary for bevy for some reason
. Also, what's the apply_deferred system for? I saw it being used in the kinematic controller, but I'm not sure what it's for.
apply_deferred executes anything spawned with Commands, might be necessary when you add components or spawn resources
apply_deferred applies command buffers. In that example it makes the Grounded updates work since they're needed during the same frame
I could've made Grounded contain a boolean which wouldn't require commands, but making it a marker component allows nice query filter stuff
Ah, that makes sense! Without the buffer, the Grounded status will only be reflected in the next frame right?
yes
Rather than next frame, it'll apply after whenever the next one is scheduled, probably whenever the next schedule runs, which is most likely not where the code runs
Run the character controller in Last 
yeah that's a more accurate description
PhysicsSchedule also has some apply_deferreds
I'm not an expert on this, but in general, if you're doing a continuous operation in a non-fixed update schedule, you should multiply by delta time, but for instantaneous operations it's not required. Multiplying by delta time can help make things less dependent on frame rate, as e.g. Update has a variable timestep.
Use delta time for these:
// Move continuously over time
position += velocity * delta_time;
// Accelerate continuously
velocity += acceleration * delta_time;
For these, it's not required:
// Apply a single "explosion" once (e.g. jumps)
velocity += impulse;
// Set velocity to a specific value
velocity = target_velocity;
This is also a pretty good answer: https://stackoverflow.com/a/63604204
In PhysicsSchedule with a fixed timestep, delta time isn't required for being independent of frame rate, but still recommended so that units might make more sense
And with the time unification thing I'm doing, you can have a system use Time and have it work both in Update and PhysicsSchedule (and other schedules)
I should probably have this in the docs even though it's not bevy_xpbd specific ๐ค
delta time confusion is very common (for me as well)
Yea just try unlocking the FPS on a console port ๐
Thanks for the explanation! I'll start using delta times then.
I also have a weird problem with the camera being jittery when following the player. Trying to record it, but screen recording is basically broken on NixOS right now ๐ญ. Is there an appropriate schedule for a camera system like this? Right now I'm just chaining it after the movement code.
It should be
.add_systems(
PostUpdate,
camera_follow
.after(PhysicsSet::Sync)
.before(TransformSystems::TransformPropagate)
)
but for some people that doesn't seem to fix it completely
and opt-level = 3 seems to cause camera jitter for some people (like me) for some reason
HOLY, that works perfectly for me (so far). The quirk has been haunting me all night yesterday, thanks for the laser-precision fix ๐ .
Cool that it works in your case, it's weird though how I've suddenly had like 6 people ask this in the last few days even though it has always been a thing ๐
The weirdest thing about the bug is that it makes it looks like that the object being followed is the thing jittering (relative to the environment). It really drove me crazy and had me questioning things...
yeah it's a very cursed issue
now I just need to figure out why the time PR has jitters every 0.25 seconds...
it's probably not even that visible in the video
Yeah, I'm not seeing the jitter in the video 
FPS related maybe?
I know people in my game used to have a lot of jitter at >60FPS
Which I never test because uh ... I don't think I have good excuses for that tbh ๐
Interestingly enough, the jitter is caused by using 64 Hz ๐ค I get the same behavior with 64 Hz even in Bevy 0.11, but the old default of 60 Hz is fine
Is that 60Hz refresh with 64Hz tickrate?
I think it's because it is jittery. Some frames do multiple updates, but the timeframe is long enough that it is still very noticable
but I have the issue in 0.11 and 0.12, so with both 60Hz and 64Hz (when physics ticks are 64Hz)
With 64Hz you get 1 refresh with 2 physics updates every 0.25s
2 physics updates means everything moves twice as fast for that frame, which would look like jitter ... It also happens on 60 if you get that cursed 0 2 0 2 pattern
yeah that'd match with the visual jitter frequency at least
<60 would probably end up looking like it occasionally drops a frame, which is less noticable because we're more used to seeing that
I guess I'll keep 60 Hz as default?
idk it seems weird
you'd think 64 Hz works since it's the new default in 0.12
In many ways 64Hz just makes an issue 60Hz had more obvious
yeah I tested, with 60 Hz it's pretty much always running once a frame, but with 64 Hz there's a second run every 0.25 seconds
With 60Hz you need a slightly unstable framerate (which it always is to some extent) and it aligning to the exact right accumulated time, and suddenly it looks like 30FPS (still less noticable than 4 jitters per second tho)
The more frequent the jitters are the easier it is to not notice them, and they would also only be 1/70th of a second of motion instead of 1/60th for example
I wonder if we have the components necessary to do interpolation in SyncPlugin ๐ค
Since we just want Transform to be somewhere between the current and last update
@vestal minnow do you have any apply_deferred in xpbd?
There's quite a few in there I think
There's 4 in just PhysicsSet::Prepare for example
I think Prepare should be the main one tho, since that's where missing components get added
There seem to be 4 instances of transform propagation as well ๐
yeah, let's not talk about that...
supporting user-made changes to Transform is a pain
If only more people used Position/Rotation directly 
imo that doesn't feel native so I generally recommend Transform, but it'd be nice to have a better approach
4 transform propagations seems excessive tho ๐ค
the transform propagation can't take up frametime if there are no entities with Transform or GlobalTransform
- Run propagation for changes made between end of last frame and start of the schedule physics is run in
- Run propagation in
PhysicsSet::Prepareto make sure initial positions are correct, but only if new bodies/colliders have been added
3 and 4. Run propagation for changes made duringPhysicsSchedule, before and after applyingPositionandRotationto transforms
you can also just disable 3 of the propagation runs with SyncConfig property transform_to_position
Isn't 4 unnecessary because PostUpdate already propagates those transforms to global transform?
there's a questionable update_previous_global_transforms system that requires up-to-date transforms... but maybe that could run in Last
Could even schedule it right after the propagation in PostUpdate
yeah, that
I'm also not sure if I understand 2 ... Aren't they already propagated from 1? ๐ค
I put those in the wrong order actually, 1 runs after Prepare but before StepSimulation
What does the simulation use Transform/GlobalTransform for? ๐ค
just user API for reading/writing to Position/Rotation, and also for child colliders and collider scale
Ah for people scheduling stuff inside PhysicsSchedule?
people can use Transform basically anywhere, except in the SubstepSchedule it's not up to date
Yea that sounds pretty cursed ... Treating Transform like a rendering component feels so much simpler ๐
If there's interpolation Transform would also just be straight up wrong most of the time, so it would make sense to use Position/Rotation as simulation coordinates, and Tranform as a purely graphical thing
yeah but using Position/Rotation in projects just feels wrong to me unless touching engine internals
Yea the real issue here is that bevy just gives us Transform ... Which is probably exactly because bevy doesn't have any physics ... Transform isn't designed for physics ... Having Scale in there is especially cursed
like if you use Unity, Unreal or Godot, you'd just change the transform/basis, there is no separate "physics transform" afaik
if people change transform and nothing happens, they'd be confused
The whole Transform situation in bevy is generally not ideal ... GlobalTransform also sounds like a normal component you should use
But that always leads to problems ... And I'm not sure if Scale on Transform behaves as I'd expect (I never use it with hierarchies tho, so idk)
I'm pretty sure it causes shear in nested hierarchies where parents are rotated
at least I noticed it with child colliders since the meshes become warped and the colliders no longer match them
I could eventually also revisit #16 experimentally to try and see if there's any way to make transforms viable for use in physics directly, but idk if that would just be more cursed than our separate components, and we'd also lose stuff like f64 support (but idk if official bevy_physics would care about that)
also Transform2d would be required
Hmmm yea messing around in godot it's clear it just accepts whatever nonsense you throw at it, if the parent is rotated and scaled it will just give you a weird collider
allowing shear for colliders is interesting, idk how gjk/epa works with that
Might be worth asking what the general opinion on that is ... There's also other options for handling more precision than f32, godot does some pretty cursed stuff to get f64 accuracy while having real f32s for shaders
The SyncPlugin is just probably the biggest code smell right now imo so it'd be nice to find some way to make it cleaner/redundant
You might have to convert scaled space into normal space ... That's the only way I could sample SDFs correctly too I think, since SDFs break from non-uniform scaling
500 lines of code I don't want to touch to avoid breaking things ๐ญ
eh, more like 150-200 lines of actual code
I mean just the SyncPlugin is probably not that concerning to touch
But there's propagations scattered in different places too
the logic and scheduling intricasies required to make it work just break my brain
Do you have any images of what this ends up looking like? I don't think I can get anything in godot that really breaks the collider in any significant way
In theory if you just rotate and scale points by a chain of their parent's transforms you'd still end up with valid points ... But the way it's accumulated in GlobalTransform might introduce some issues
iirc if you have a non uniformly scaled parent and a rotated child you get shearing
@cinder summit What even are the odds of FixedUpdate falling out of sync when it's running at the same rate as the refresh? I kinda need physics to be fixed but I really don't wanna deal with stutter. As of right now I have it fixed at 120hz which looks perfectly fine testing at 30/60/120/240/uncapped, can't really tell if there are any skips. I understand why for pure simulation it makes more sense to have a finite float, but in practice is it a real issue (or more so than having consistent stutter)?
Maybe until we get real interpolation I can just add another fixed schedule that's used for noticeable parts of the game like transforms/physics that runs at a multiple of 30
The higher the tickrate is the harder it is to notice ... If you have 60 tickrate at 60FPS it works fine most of the time, but once it goes wrong it will just keep doing that for quite a long time ... There's some ugly hacks to work around the issue, but a real solution definitely requires interpolation (and possibly making more time for FixedUpdate, tho that seems to be something only Godot has experimented with)
The main thing that makes it obvious is actually the event issues with FixedUpdate, telling 30 and 60FPS apart when the camera still moves smoothly and animations play like normal is pretty hard
64 is a tickrate that just perfectly highlights the issue non-stop. It happens often enough that it doesn't seem like a small glitch, and the tickrate is low enough that the jumps are still fairly big
If you had animations, camera movement, and camera smoothing that play independant of tickrate it wouldn't be as noticable. But most games that use 64tickrate are online games and they always have interpolation (for more reasons than just physics)
@cinder summit Thanks, I see. I do have camera movement/smoothing that's independent so maybe that's part of why I don't notice it, though it sounds like it doesn't correct itself when it goes out of sync... The other day I was curious about that so I let the game run for a few hours and it was still fine when I got back, so beats me haha
Maybe I should just bite the bullet and figure out how to make my game work with delta lol
If it goes out of sync it will probably eventually drift back
Working with delta isn't really a solution either, since then you just get incorrect physics
well, I'm just going to look at implementing a simple move_shape kind of thing
either that or just modify wanderlust to be incredibly aggressive with its stopping/starting
Is this the case with fixed framerate? Thinking of those japanese PC ports where everything is fixed fps (e.g. dark souls, fighting games) and then they maybe offer a few modes like 60hz/120hz mode
That's ignoring delta but you get what I mean
Well the main thing is you want to use delta, but the delta should be the fixed amount of your physics
Games like dark souls have the fun issue where the physics are tied to FPS, and I think some things do multiply by delta, but then others just assume it's the capped FPS
Which causes it to not quite speed up as intended, but also break in stupid ways
Right, so in that case do they implement things like interpolation for their transforms? Or just by virtue of having both a fixed framerate and logic being executed per-frame, if it goes out of sync it goes out of sync together so it's not really jarring?
I think the main reason many console ports have these issues it because their physics don't run on a separate cycle, it avoids needing interpolation, which means slightly less visual latency and no weird alignment issues
With that approach if you drop down from 30FPS to 20FPS, the game just moves at 2/3rd the speed
Similarly if someone mods the FPS cap from 30 FPS to 120FPS it now moves 4x as fast
Yeah exactly
Isn't that essentially the same as just using Time and not multiplying by delta?
If you make your forces smaller and don't multiply by delta when you should, you get roughly that behavior yea
xpbd does internally use the delta for some things, so presumably things would still behave differently if FPS changes
Ahhh gotcha
With 0.12's unified Time you pretty much always want to multiply constant changes by Time.delta_seconds(). Since that time will automatically be FixedUpdate's period in FixedUpdate, and there is a PR to have the same with xpbd's loop in the 0.12 migration
It's kind of funny how devs rarely notice these issues during development ... If your game runs decently, disabling vsync would result in obvious changes if you didn't use delta correctly, or anything uses the wrong delta
Ohh that's pretty clean, I was wondering why it wasn't like that before
Yeah I'm really paranoid so I test at every FPS using gamescope...
I feel like I could also get rid of PhysicsTimescale and PhysicsLoop with Time<Physics> ๐ค Then we would have just a single resource for managing all of the simulation scheduling and timing logic since it's all related anyway
You could have the relative speed (time scale) in Physics itself, similarly to Virtual, and same for pausing/resuming
or maybe it'd be better to have Virtual control Physics, but then you wouldn't be able to e.g. pause physics independently of Time<Virtual> which might be annoying
All in all, Time<Physics> might replace 4 resources while also making things more unified, logical and schedule-agnostic :P
I'm really enjoying the time rework
it'll also make scheduling docs more grouped together which is nice
I take all the credit because the original idea of unifying time came from me! (jk. I didn't help at all with the actual implementation :p)
excluded_entities is an alloc type so I don't think so ... Tho tbh that's something that should probably be fixed ๐ค
I'm also not sure if HashSet really makes sense when it's almost always empty
Or well 1 item I guess ๐ค
Something like a SmallVec might also work up to the defined capacity ๐ค
I don't understand how it could be const, const are methods that are precomputed at compile time essentially, you can't do that with a physics sim that has inputs from a player, etc.
Smallvecs aren't good, they sound good but in practice are usually worse than if you did nothing at all
I think HashSets are fine, sure it's an alloc, but usability of the method is worthwhile here
The problem here is that you rarely reuse filters. Which means you now need an alloc every time, and it probably excludes exactly 0 or 1 entity
HashSet::new doesn't alloc, similar to Vec::new I'm pretty sure
so if you don't insert it isn't allocing
Doesn't help if you fill it with exactly 1 entity tho, which is pretty common .... Wouldn't want a cast to find a player to find the player that activated it
Ideally you'd be able to either reuse a collection you already have or pass in [Entity; 1], not sure if it would be possible to impement the necessary generics here tho ๐ค
I don't know if that matters much, shapecasting isn't cheap
this alloc is an order of magnitude lower than everything else
you could make it take a impl Iterator<Item = Entity> I guess
but that would need to be collected
or some form of preprocessing otherwise it can't be reused internally
You'd need to take an impl of some trait that gives you .contains(&Entity)
sure that'd be fine
I'd just frame this as a usability thing rather than performance
the performance of an alloc isn't going to be noticeable with a shapecast
It's definitely a usability thing, since you can get around the performance penalty by reusing the HashSet ... Which would probably make for some very messy code
And besides shapecasts there are also cheaper things, raycasating into the void is cheap, shape intersections with no overlapping AABBs is also cheap
Both could be cheap when you just have a small number of primitives too, tho parry's dynamic dispatch and potential qbvh bugs might mess with that math a bit
My BVH was subtly broken yesterday and that makes it really clear how much of a performance hit that can cause (and incorrect results)
Wait really? How can I learn more about this? Does it not alloc until you insert the first entry?
https://doc.rust-lang.org/std/collections/struct.HashSet.html#method.new
Answered my own question. TIL!
Hey, guys! Thanks so much for the help last time. Is there an example of making more complex shapes, like the ones Lyon tesselates, and have it work with XPBD? I am thinking ideally bezier curves. If it doesn't need tesselation that is also obviously fine.
I am trying to make levels, and I don't want to go down the LDTk-route, but perhaps rather import some SVGs.
You can get the vertices of the geometry made with Lyon, right? You could probably make polyline colliders from those points
but you can't have infinite precision like what SVG paths have, it has to be an approximation of the shape (like a polyline)
if it's a filled object without concavity (holes etc.) then you could also create a convex hull collider
Hi, I've been trying to get xpbd working with LDTK.
use bevy_inspector_egui::quick::WorldInspectorPlugin;
use bevy_xpbd_2d::prelude::*;
const PLAYER_SPEED: f32 = 128.0; // pixels per second
fn main() {
App::new()
.add_plugins(
DefaultPlugins.set(ImagePlugin::default_nearest()), // prevents blurry sprites
)
.add_plugins(LdtkPlugin)
.add_systems(Startup, setup)
.insert_resource(LevelSelection::Uid(0))
.add_plugins(WorldInspectorPlugin::new())
.register_ldtk_int_cell::<WallBundle>(1)
.register_ldtk_entity::<PlayerBundle>("Player_Start")
.add_plugins(PhysicsPlugins::default())
.add_systems(Update, handle_player_movement)
.run();
}
fn setup(mut commands: Commands, asset_server: Res<AssetServer>) {
commands.spawn(Camera2dBundle {
transform: Transform::from_xyz(100.0, 100.0, 0.0),
..default()
});
commands.spawn(LdtkWorldBundle {
ldtk_handle: asset_server.load("my_project.ldtk"),
transform: Transform::from_scale(Vec3::splat(3.0)),
..Default::default()
});
}
#[derive(Default, Bundle, LdtkEntity)]
struct ColliderBundle {
collider: Collider,
rigid_body: RigidBody,
}
impl From<&EntityInstance> for ColliderBundle {
fn from(entity: &EntityInstance) -> Self {
match entity.identifier.as_ref() {
"Player_Start" => Self {
collider: Collider::cuboid(8., 8.),
rigid_body: RigidBody::Static,
},
_ => Self::default(),
}
}
}
#[derive(Default, Component)]
struct Player;
#[derive(Default, Bundle, LdtkEntity)]
pub struct PlayerBundle {
#[sprite_sheet_bundle]
sprite_bundle: SpriteSheetBundle,
#[from_entity_instance]
collider_bundle: ColliderBundle,
#[worldly]
worldy: Worldly,
player: Player,
}
fn handle_player_movement(){...}
#[derive(Bundle, LdtkIntCell)]
pub struct WallBundle {
#[from_int_grid_cell]
collider_bundle: ColliderBundle,
}
impl From<IntGridCell> for ColliderBundle {
fn from(int_grid_cell: IntGridCell) -> Self {
match int_grid_cell.value {
1 => Self {
collider: Collider::cuboid(8., 8.),
rigid_body: RigidBody::Static,
},
_ => Self::default(),
}
}
}
Whenever I use the physics bundle it keeps moving my player sprite from where I set them up in LDTK to the world origin. I guess the issue is that the position is being set afterwards, but it isn't respecting the transform that the LDTK importer sets. Has anyone had this issue before and found a solution?
This is an issue in bevy_xpbd 0.2, should be fixed on main (and 0.3 when Bevy 0.12 releases)
See #1124043933886976171 message and #1124043933886976171 message
Thanks, I'll try the main branch!
I'm having a weird issue where a kinematic character isn't jumping when you linear_velocity.y = jump_impulse.0;. I know that it's applied correctly because I had a debug print right before it. It usually happens when the player is currently moving on the X axis. Anyone know what could be causing this?
Yep, I can reproduce this with basic_kinematic_character too. Make the ground bigger like this:
commands.spawn((
PbrBundle {
mesh: meshes.add(Mesh::from(shape::Plane::from_size(80.0))),
material: materials.add(Color::rgb(0.3, 0.5, 0.3).into()),
..default()
},
RigidBody::Static,
Collider::cuboid(80.0, 0.005, 80.0),
));
Then, try to run in a straight line for as long as you can before jumping. Sometimes, the character simply won't jump
Thanks, this makes sense. I think I can make that work.
Which version are you using? 0.2 has a lot of bugs similar to this that are fixed in the github version
@peak marsh ^
Using the latest main.
ah
My guess is that the KCC example is setting the vertical velocity to zero when grounded, and if you're moving in a certain way then it might think you're grounded even when jumping
I'm on my phone rn but I can test in about half an hour
I can't reproduce this in that example, even with frame rate limiting using bevy_framepace
but my guess would be this y = 0 in apply_gravity
// Reset vertical velocity if grounded, otherwise apply gravity
if is_grounded {
linear_velocity.y = 0.0;
} else {
linear_velocity.0 += gravity.0 * delta_time;
}
it could maybe have a timer where it can't reset the velocity for e.g. 0.1 seconds after jumping
or remove Grounded on jump
Yeah, I personally prefer to remove gravity during the ascent part of the jump. I noticed unreal's character controller has a toggle for this behavior. If you keep applying gravity during a jump the feel will be more like having a jetpack, in my experience.
Tried removing Grounded on jump but it still won't work.
Did you try pressing just one horizontal movement key for a while, before jumping?
yes
So weird...
Is there a way to debug what's going on with velocity values behind the scenes?
okay I managed to repro the issue twice now, the jumps had to be timed with these weird jitters
this has other issues, but does this work?
if is_grounded && linear_velocity.y < 0.0 {
linear_velocity.y = 0.0;
} else {
linear_velocity.0 += gravity.0 * delta_time;
}
Interesting, it seems to fixes it!
yep, so it is in fact that y = 0
this just makes the ground collision kinda floaty
Never mind, sorry. I think I can reproduce it again...
It's feels really inconsistent tbh...
I feel like it's harder to reproduce it now. This is vague, but I think the jump sometimes fails when there's a lag.
Yeah, I pretty much can't reproduce it anymore, so adding it definitely helps. It happens like a couple of times when my CPU gets busy, but I can't see it anymore.
I'll try with a jump timer, should be more robust probably
Actually this might work too, although it's somewhat questionable
fn update_grounded(
mut commands: Commands,
mut query: Query<(Entity, &ShapeHits, &CollidingEntities), With<CharacterController>>,
) {
for (entity, hits, colliding) in &mut query {
let touching_ground = hits.iter().any(|hit| colliding.contains(&hit.entity));
if touching_ground {
commands.entity(entity).insert(Grounded);
} else {
commands.entity(entity).remove::<Grounded>();
}
}
}
this adds Grounded only if the character is actually touching the ground, not just if the shape caster is close enough
also seems to make the jitters less frequent for me
Nice, it seems to work great! This seems like a more robust approach, though it does feel a bit awkward.
I might make Grounded contain the distance from the ground. This way, things like jumps can work even if the player is close enough but not quite touching the ground, but gravity can require a distance of 0
Actually, with just the update_grounded fix, I can still experience the issue. I need to also add the && linear_velocity.y < 0.0 to apply_gravity. Is this expected?
No, that's weird...
Yeah, I can reproduce it with basic_kinematic_character too. It looks like the update_grounded fix alone isn't enough...
Okay iteration number 56, you could try this apply_gravity
fn apply_gravity(
time: Res<Time>,
mut controllers: Query<(&ControllerGravity, &mut LinearVelocity)>,
) {
// Precision is adjusted so that the example works with
// both the `f32` and `f64` features. Otherwise you don't need this.
let delta_time = time.delta_seconds_f64().adjust_precision();
for (gravity, mut linear_velocity) in &mut controllers {
linear_velocity.0 += gravity.0 * delta_time;
}
}
and this kinematic_character_collisions
fn kinematic_controller_collisions(
collisions: Res<Collisions>,
mut bodies: Query<(&RigidBody, &mut Position, &Rotation, &mut LinearVelocity)>,
) {
// Iterate through collisions and move the kinematic body to resolve penetration
for contacts in collisions.iter() {
// If the collision didn't happen during this substep, skip the collision
if !contacts.during_current_substep {
continue;
}
if let Ok(
[(rb1, mut position1, rotation1, mut linear_velocity1), (rb2, mut position2, _, mut linear_velocity2)],
) = bodies.get_many_mut([contacts.entity1, contacts.entity2])
{
for manifold in contacts.manifolds.iter() {
for contact in manifold.contacts.iter() {
if contact.penetration <= Scalar::EPSILON {
continue;
}
let normal = contact.global_normal1(rotation1);
if rb1.is_kinematic() && !rb2.is_kinematic() {
position1.0 -= normal * contact.penetration;
// Clamp vertical velocity to prevent gravitational acceleration
// when on ground or sliding on slopes.
if normal.y > 0.0 {
linear_velocity1.y = linear_velocity1.y.max(0.0);
}
} else if rb2.is_kinematic() && !rb1.is_kinematic() {
position2.0 += normal * contact.penetration;
// Clamp vertical velocity to prevent gravitational acceleration
// when on ground or sliding on slopes.
if normal.y > 0.0 {
linear_velocity2.y = linear_velocity2.y.max(0.0);
}
}
}
}
}
}
}
everything else can be reverted to what it was
This basically moves the y = 0 into the actual collision response, and it could be modified to allow things like sliding on slopes with some specified steepness
It's improving, but I can still reproduce the issue in really rare occasions
. The movement also gets a bit weird, like you can stick to walls mid-air by pushing your characters to it, the character sometimes falls too fast from small platforms, etc.
Why is this so cursed 
I'll make a quick demo scene in Blender with slopes and walls and stuff, it'd be nice to have in the example anyway
That sounds great. Any chance for a 2d version of something like that also?
Tbh, I'd also love to see a 2D example too in the repo.
Nice 
I am making a game with the hope of mass appeal, I think most people have a hard time with 3D still. Unfortunately, I cannot seem to wrap my head around making a 1D-game, so I am ending up with 2D at this point.
Lol, wouldn't a 1D-game just be a straight line...?
Yeah, but. What's the game, right? ๐ I am just being silly.
But what I am actually saying is that a super stable 2D physics engine is why I left Godot for Bevy and why I left Rapier for XPBD.
Yeah XPBD is cool
It looks like that in the end, the linear_velocity.y < 0.0 trick produces the most consistent result, so I'll just stick to that now.
Arguably a lot of those action-cutscene things where you don't really have any control but have to push the right buttons at the right time are 1D. At least, conceptually. ๐
I don't know if the missed jump issue is fixed, but otherwise this is looking pretty good now
Walls work properly, and the slope sliding angle is configurable
child colliders (like the ones required to get that glTF scene working) should also be supported
Looks really nice! I'll try to fiddle with it again once the example gets pushed to the repo.
Where's the stairs? ๐
don't tempt me ๐ค
at this rate, this example will soon be a fully featured character controller
"no built-in character controller" they said
Is xpbd gets a built-in character controller we can say it's better than the rapier kcc tho 
I don't like how rapier's kcc requires you to use all of these separate APIs
like normal collision filters and CollidingEntities don't work iirc
It's also just generally quite buggy, doesn't perform great, etc
In terms of usability it was probably about as jank as using xpbd with a different collider type tho ... All the things that require Collider or the times I use the wrong type by accident ...
Well I actually fixed that last one because I just import a custom physics::prelude::*; which doesn't have the wrong types ... Now we just need a feature flag in xpbd so I can yeet the parry dep 
yeet parry + nalgebra
Funny part is I still rebuild a BVH each frame
And that BVH takes about 5x as long to build .... But I get 80% less server load 
Why is the load so much smaller?
Because trimeshes no longer exist
ah yeah
I think the SDFs perform about 30x better than trimeshes
Oh and I implemented sphere casts, which are just raycasts with a radius ... They are a lot faster than shapecasts, pretty SDF specific tho
Have you compared the overall performance and stability to normal colliders?
like let's say you had a stack of cubes, is that stable?
I still need to implement the ability for cubes to collide with other cubes ๐
There is only points and lines with radii touching other shape atm ...
Capsules and spheres seem pretty stable even with mostly empty contact manifolds, but I'd imagine cubes would still explode without them ๐ค
yeah things like capsules and spheres should only ever have 1 or 2 contact points in most cases so they're probably quite stable
Yea there's only some rare exceptions like dropping a sphere on a torus. That's one case where they can actually explode
But I mean ... Who even makes torus colliders in a real game? ๐
some donut factory game
No donut factory support for me yet 
Torus { ring_radius: _, inner_radius: _ } => {
todo!();
}
I can extrude 2D sdfs tho ... Just uh ... Need a few more 2D sdfs now ...
pub enum Sdf2d {
Arc {
radius: f32,
thickness: f32,
segment: f32,
},
}
You know it's serious when you rename basic_kinematic_character to kinematic_character and break up the example into multiple files
I figured it'd be nice to have the character controller be a plugin in a separate file since it's a good idea to do that in projects anyway
Although it's looking more and more like I should make it an actual crate...
This is like how I started with sdf/src/lib.rs, but I'm starting to split it out and rethink the design because I'm getting too many SDFs
And that's with collisions being an entirely separate crate which has a few common things and then an xpbd module with a narrow phase and spatial query stuff
Since I'm starting to implement 2d SDFs I guess I also need to make 2D collision handling 
Tho in reality I still don't want to start the 2d vs 3d thing until we know what that should look like for bevy crates
@cinder summit As I understand it, SDF can pretty easily be used to deform objects on collision. That opens up a whole bunch of amazing new physics engine possibilities!
SDFs by themselves aren't deformable in that sense, but they could be used to do cool cloth stuff
You can do some pretty fancy stuff with SDFs, but you do want to be careful with them since it's not very hard to end up with wrong exterior distances or gradients
They also have some interesting game-specific usecases ... Sampling the distance to surrounding colliders is extremely cheap even if they are complex colliders. Would be rather useful for something like collision avoidance for AI agents
I would love to see all of that encapsulated in the library so I can have the fancy stuff without having to be careful. ๐
Yea that's pretty much what I'm planning. Having only operations that can create valid SDFs, with very clear warnings in the docs for cases where certain inputs can make the SDF bound
Merging overlapping or connected SDFs makes the interior distances wrong, which isn't that big of a deal, until you invert the SDF
Hmm, 90% of the code for the dynamic and kinematic character controller is shared, and it should also be basically the same for 2D and 3D ๐ค
And besides SDFs having interesting properties, there's also interesting benefits like being able to do cloth simulations that don't glitch out
I'll definitely have to set up a way to slap accurate SDFs onto player characters so I can do cloth and hair physics at some point ...
Tho for now it's just a capsule which is very easy ๐
This maybe goes into different channel, but: are you creating bevy meshes as the "output", or do you have a shader / material implementation that replaces bevy's?
I just take the SDFs and make a mesh out of them, and slap this green color on them ... You can probably see some weird edges and round corners, which is because the mesh library doesn't use gradients which means the meshes are wrong
And the round room is 3 arc sdfs and 2 cylinder sdfs in case anyone was wondering ... The rest is just boring boxes tho ๐
The updated examples are here: https://github.com/Jondolf/bevy_xpbd/pull/222
I'll also try to add 2D versions now
It is an example, the plugin is just in a separate file
next to the main file which just has setup stuff
also a nice way to see how it is to actually use the engine, I mainly just develop it so I don't have that much first-hand experience haha
yep
2D version looks pretty good as well now
(this is the dynamic one, still need to do kinematic)
should probably move everything up a little since the top is so empty
nah it took like 15 seconds, I just added 50px to the y values
there's already a collision layer example so that's unnecessary imo
I'd say this
but it'd probably be possible to some extent
(if we're talking about spatial query filters here)
excluded_entities doesn't get filled except for some specific queries, but those could probably be handled differently as well
we could probably remove excluded_entities tbh, it could be done manually in callbacks when needed
also 0.12 omg ๐
It would probably still be nice to have on the component (but there the hash set isn't an issue anyway)
yep it can be on RayCaster/ShapeCaster but probably not on SpatialQueryFilter
It's also more useful on shapecast than raycast
Since raycasts are cheap, but with shapecasts filtering first might be useful
Also my sdf spatial query stuff has been getting quite cursed ... To the point where I feel like the parry names might not even be that bad 
And it doesn't even support DFS vs BFS or anything vaguely ordered yet
It's happening ๐
wait just a sec
yes, that
I'm making a post in #crates rn
Here #crates message
The GitHub release has a (non-exhaustive) migration guide
The blog post will come later
Congrats!
Comparing release notes for 0.2 and 0.3 side-by-side is pretty insane
Thanks! There were a lot more contributors for 0.3 as well, so I'd want to thank everyone else too โค๏ธ
And that's without secretly merging the SDF collisions into xpbd? ๐
That's for the day after the release like I mentioned
alongside joint motors, a parallel solver running on the GPU with unified memory, and fully featured perfectly stable soft bodies
Ah yes
The SDF collisions work better on the GPU too ofc
And it's gotta be unified memory otherwise the arete devs won't fall into despair about how much better physics for bevy is 
Exactly
I can't decide if I should post about the release on reddit now or after the blog post is done, usually I've had the post ready for release already
I guess I could just link to the GH release and docs, and say that the post is coming soonโข
if you mean the debug plugin, you need to add it manually now, but debug-plugin is a default feature
I would add that to the migration guide, but there was barely any debug rendering prior to 0.3
just .add_plugins(PhysicsDebugPlugin::default())
which bug?
Maybe someone can help me out here, not sure the best approach to the problem I'm having. I have a 2d game, and i spawn in some circles, I have set Restitution(0.0) on all my dynamic rigid bodies, but sometimes when they collide, one still bounces a lot off the other. Maybe a better solution is to change mass or something?
Which version of bevy_xpbd is this?
close to main, i pulled it a number of days ago
okay yeah nothing should've changed in terms of restitution behavior in the last few days
it's expected that they might bounce just a little bit due to the discrete nature of the collisions, but you could try to increase SubstepCount if that helps
something like 20 maybe
it should make the simulation more accurate, but at the cost of performance
do I need to do something if I get a bunch of
2023-11-04T23:07:41.504938Z WARN physics_xpbd: some agents have an unreachable target, increasing delta to 0.03
2023-11-04T23:07:41.512408Z WARN physics_xpbd: some agents have an unreachable target, increasing delta to 0.089999996
2023-11-04T23:07:41.520675Z WARN physics_xpbd: some agents have an unreachable target, increasing delta to 0.26999998
2023-11-04T23:07:41.529132Z INFO physics_xpbd: resetting delta
and then a freeze
that might or might not be related
is that from oxidized_navigation?
bevy_pathmesh
francois' polyanya for bevy
wait
those errors are from the example
I'm getting index out of bounds after a while
yeah same
on native it didn't show any errors
even with a debugger hooked up
actually I got capacity overflow
not index out of bounds
at least it finally panicked
ok, I think it's probably an issue in bevy_pathmesh, not xpbd
yeah, I haven't used bevy_pathmesh so I don't know why it'd freeze
I'm also not getting issues now that I'm trying the demo a second time ๐
nvm
literally as I sent that
phew, it's only xpbd that uses parry here
it just uses parry through bevy_xpbd
parry issue is https://github.com/dimforge/parry/pull/161 ๐
Thanks, looks like it yeah ๐
The real reason you aren't building collisions yet
technically yes, but that might be less discoverable
yeah I might do that, but it's moving even further in the direction of having built-in character controllers :P if they're just plugins that are used in a bunch of examples
you could do that for built-in character controllers too
but I think it does make sense to have it in common, I've been planning on adding the grabber plugin I made a while ago there as well
bevy_xpbd is designed to be very moddable and extendable with the idea that you can take e.g. the narrow phase and customize it a little
like NiseVoid's SDF narrow phase
not really
but yeah I'll probably do this, and next to the plugin initialization I can maybe add some comment mentioning that the character controllers are in the common module (although you can infer it from the imports)
the current demos can become something like platformer_2d and platformer_3d
wdym?
yeah I think I should at least group them somehow
My game physics seems to run really fast now, with the new xpbd, is that expected?
really fast in terms of objects moving very fast?
i do have a 144hz monitor and a 360hz monitor
not sure if that matters
it felt like it was 60fps before
now feels like it's running a lot faster
well, i'm formulating this improperly, not the framerate, but actual physics simulation speed
it's very possible that I messed something up in the unified time PR but I haven't really noticed it in the examples
i'll try running examples on my machine to see if i can repro it in any of those
wow, chain_2d runs like crazy on my machine
I swear I checked that ๐ญ
it does freak out
probably wrong initial positions tho
*hopefully
that looks otherwise right but they sometimes fall weirdly fast in your video
yeah
I'm not getting that myself
Gotta get the physics starter pack featuring:
- SDFs
- A whole 3 papers on the subject
- Lots of xpbd features that subtly break because Collider isn't as optional as it should
yeah seems to be on and off sort of
sometimes it falls very fast, sometimes normal
Yea idk there's not that many papers on SDF collisions
There's a lot of robotics simulation stuff that uses it, but they don't publish papers 
Outside of collisions there's a lot more info
Tho not that many info about gradients, which sucks because gradients are quite important for physics
Ah and can't forget implementing your own BVH so you can have spatial queries without parry, except that doesn't benefit you that much cause parry isn't an optional dep in xpbd 
yet
how do I make my frame rate not locked to 60fps
oh I got it
Disable vsync
yep the issue is frame rate ๐
the issue i'm experiencing?
SDFs are used very often for some rendering stuff. As for collisions I found like 3 whole usecases:
- Robotics simulations
- Cloth physics
- Marble marcher
wow lol
Honestly if it wasn't for the cloth physics, I doubt I'd even have heard about them ... Since it was just a thing Jondolf mentioned randomly
Marble marcher is a very important use case
Yea it's probably roughly like this:
- Cloth physics
- Marble marcher
- My game
- ????
- Robotics simulation
I'm glad I could throw you into this endless SDFification rabbit hole
I mean fwiw it all started when I heard about SDFs for the first time cause kayak_ui has SDF text
wait wtf, is this fps real?
Isn't your simulation just running at 60FPS?
the physics timestep is 60fps yeah
FPS totally makes sense then
yeah it is accurate, move_marbles with a lot of bodies still goes from > 1000 FPS to 10 FPS real quick lmao
Yeah I can easily get <10 fps on move_marbles lol
but yeah I know what the issue is, I just need to find a nice fix
Is it the broadphase?
probably narrow phase + solver
Hmmm yea I guess the narrow phase can get expensive too since it's not all sphere-sphere
move_marbles is 99% sphere-sphere
Actually how much room for optimization is there in the narrow phase? Besides replacing parry with something that doesn't dynamic dispatch
we could reuse contact manifolds, but otherwise probably not that much
Ah right that vec in vec thing ... With enough contacts that might actually add up fast ๐ค
I rather meant that we can use slightly transformed versions of previous contact manifolds if the bodies haven't moved much instead of always running gjk/epa on them
Ah ... That wouldn't do much for sphere-sphere tho
Tho I guess if it doesn't account for it being sphere-sphere it still has to deal with rotations and some other fairly expensive math
I haven't profiled my sdf physics, but I'd imagine the most expensive part of it is transforming the sample points into the local space of the other collider
Just like the absolute insanity where the highest cost to building my BVH is calculating the surface area of merged AABBs 
I can fix the weird physics speed issue but it kills my fps
nvm I have a fix but it's really sketchy
I'm pretty sure PhysicsTimestep::Fixed was already broken in earlier releases and just ran 0 or 1 times per frame instead of consuming the entirety of the accumulated time
if I use that behavior, the fps and behavior is basically the same as before, but if I accumulate time using Time<Real> and consume that, FPS is way worse since it can death spiral more easily
now, do I implement the old incorrect behavior or the intended but much slower behavior ๐ค
I guess I could have some max_steps property on the fixed timestep to prevent death spirals, where a value of 1 would correspond to the old behavior
0.3.1 tomorrow??
if y'all happen to encounter other unexpected issues, let me know
ty!
Regarding my earlier issue, itโs not just a small bounce, itโs a sort of explosive one
It seems inconsistent
I can send a video if that would help
And I mean not the issue with 0.3
I think the new Time<Fixed> is supposed to avoid the death spiral
Wow, that is insane.
I just tried to pull and run that example and here it dips into mid 30FPS on main.
I just updated to Bevy 0.12 and xpbd 0.3. Is it supposed to behave the same given the same code or are there some breaking changes? I can notice some stark differences in how some basic shapes seem to interact. I won't harp on it if it is expected to behave differentely. I didn't see a changelog.
I can make a video describing the difference without much hassle. 0.2 seems more correct to me.
Again, it is super fair that it is my implementation of despawning of stuff and the order of systems is wrong, etc.
But are there known bugs? Should I just kick back and relax and see if it's fixed in 0.3.1? I didn't see anything reported in the repo.
I am actually seeing something that is way more basic than that. Let me show you on a video. It is a little puzzling to me. It will take me 30 minutes to make it, tho, I think. I will make it just in case it is an unknown, if it is fixed implicitly with 0.3.1 that is also great. ๐
Great. I will share it here before I start making issues. It might be just a default that has changed, or something.
Cool, I'll test that.
This could just as easily be a Bevy 0.12-thing. It has to do with what forces are carried on when an object is despawned. It seems like in Bevy 0.11 and XPBD 2.0, the force from colliding with an object resulting in that object being despawned would carry over to the object that isn't despawned. With 0.12/0.3, that doesn't seem to be consistent. It happens sometimes.
But it seems to depend on the impact angle of the objects.
Odd behavior in 0.3.
Also, happy to share code if that is helpful. But it naive at this point.
You would think that if it had to do with system order and despawning that it would work consistently correctly when falling straight from the top and down.
Could this be related to what I am seeing?
Adding the debug-plugin doesn't really reveal anything to my untrained eye.
This is an absolute yes. I think this is probably the culprit.
If you send me your github, I can share the code, no problem. Is there an example of how to move from EventReader<Collision> to what is in vogue now?
I had a small issue with it previously moving from desktop on Win/Mac to WASM.
But still an EventReader?
But I do need Collision if I want to despawn what is collided with, right?
/giphy tell me more
Ah. Nice.
I try this on for size. It looks clean.
Sure, I am happy to share code with anyone interested. I will make a debug-video, but it really just shows a debug-overlay on the existing shapes that are static and where expected. Let me try this other thing first.
Even using CollisionStarted, it falls through. So I will make a short video with the debug-rendering enabled.
This here, does it describe the issue OK?
I am in no real rush with this. I was thinking of making an "Advent" but that's in December. And I can have a different WASM every day.
I woke up
Thanks, that'd be nice, I haven't really seen ball colliders be explosive
@merry tide thanks, I'll look into that issue and try to repro. Where are you running the despawning system?
Shapecasting with ShapeCaster or SpatialQuery? One of the only things I remember changing about ShapeCaster is that it now ignores the self entity by default, but this can be reverted using .with_ignore_self(...)
I am not sure I fully understand the question. I can share the full repo if you want.
It is pretty small.
I mean is the system that despawns the ball that was hit in Update or somewhere else
The system that despawns the crystals run as part of the Update-cycle and reads events.
Gotcha
But yeah the repo would be nice so that I don't have to make a repro from scratch
What is your github ID? Happy to share with anyone interested. The last commit has the PhysicsDebugPlugin and all that on it.
I'm just Jondolf
https://github.com/Jondolf
I feel I already knew that. ๐ Sorry. Been up all night.
I sent you an invite. The README should be somewhat informative, but it really should just be cargo run.
Thanks, I'll try it in a bit
No rush. Thanks so much for looking into it.
@merry tide Hmm, I think I found the issue with the inconsistent collisions when despawning, but it might be a somewhat tricky one.
For now, this should fix it in your case:
.insert_resource(NarrowPhaseConfig {
prediction_distance: 0.0,
})
The prediction distance basically determines the maximum distance between two bodies for a collision to be counted. It's normally a bit over 0.0 to make sure that collisions aren't missed. This is because if bodies move into a colliding state mid-solve, the collision would only be detected during the next frame unless the prediction distance is large enough.
The issue in your case is that the bodies may not have actually touched yet, but it's still sending a collision event if the distance is within the prediction distance. I should be able to fix this by only sending events for actual touches though
And the reason it worked in 0.2 is that it didn't have any prediction distance stuff, but it was also a lot more unstable and collision events had other issues
I made an issue for the collision event problem and added it to the 0.3.1 milestone along with the timestep issue
I have fixes for both but I need to check if I caused other issues for the collision events since the logic for them is kinda error-prone
I'll also check the spatial query thing .โงฒ. mentioned
Fixed timestep fix: https://github.com/Jondolf/bevy_xpbd/pull/225
Thank you, it does indeed seem to fix the issue! ๐
It is just me again! I am testing it on my MacBook and it seems to be running at what I can only describe as "double speed" somehow. Is this also known/easily fixable thing?
this
I sort of understand. Do you recommend using XPBD from source, or wait for an update? Because this isn't something I can remedy in my code, right?
you can use that branch for now but I'm trying to get the 0.3.1 patch ready today or tomorrow
you can't easily do anything to the speed issue in your own code
OK, great. Thanks again for the help. I will wait for 0.3.1. ๐
Does it look similar to these weird explosions? (at the end)
It's been a thing pretty much forever I think, but I've only noticed it in this very specific example of having stacks of balls bouncing, so I haven't encountered anyone else experiencing it
also this should hopefully be fixed on main now
Yeah that seems similar, I should be able to send a video over later today
thanks
also this is fixed now, it was missing a minus sign so the chain was getting spawned in the wrong direction ๐
don't ask how that happened
0.2 had a lot of contact stability issues but I believe this is a separate issue
if it's a really quick test though, then feel free to test
it's quite inconsistent in my tests
I hate how expanding the AABBs just a little extra in all directions fixes some collision event issues
// (pixels in this case)
aabb.mins.x -= 1.0;
aabb.mins.y -= 1.0;
aabb.maxs.x += 1.0;
aabb.maxs.y += 1.0;
This feels so wrong, but if it works, then why not...
wait... does this also fix this??
I think it does
no, they cast against colliders and not AABBs
or I think the Qbvh uses AABBs for optimization, but not for the actual casts
You don't use AABBs for optimization, they are the whole thing that make up the structure
Doesn't the qbvh get filled with the real aabbs rather than the swept ones?
I wonder if it's some kind of floating point issue? Maybe the AABBs need to be expanded by 1 or 2 floating point units? ๐ค
yeah I worded that badly, I meant that the Qbvh is built from AABBs, and the Qbvh is an acceleration structure that optimizes the actual shapecasts
Ah yes it .... optimizes*
- as long as you don't do incremental updates
and yeah the Qbvh AABBs aren't the expanded versions
Always read the fine print on your spatial acceleration structures ๐
mhmm
It doesn't look like a floating point issue, they have to be expanded by at least over 0.5 pixels in this case to work correctly
(0.5 chosen arbitrarily, just tested with 0.1 and it was kinda broken while 1.0 works)
Hmmm ... Do you get collisions for things that don't quite touch?
yes, this is what I'm fixing #1124043933886976171 message (and apparently the explosion thing as well)
While fixing it, I noticed that CollisionStarted events were also sometimes getting sent every frame when it looks like a body should be continuously colliding, and it turns out it's because of the AABBs
I guess expanding AABBs by prediction distance would be a reasonable approach? ๐ค
Meanwhile my SDF collisions still don't use prediction distance
Even tho I can kind of just get those values for free ๐
I think it's working correctly, but the values are kinda arbitrary
for the broad phase I can use 0.1x the prediction distance without issues
but idk if that just means that the prediction distance is unnecessarily high
also what are the chances that I randomly happen to fix this issue the exact same day it's reported for the first time, even though I was trying to fix a different issue lmao
I mean it's pretty common for you to fix issues the same day it's reported, but usually the ones you fix by accident are the bugs relating to big things, like with contact manifolds
I swear the AABB expansion logic has been the main culprit behind most of the contact stability issues
I can recall at least 3 or 4 times where it has caused issues now
Seems like a good place to spend time making it better, then. I came here for the immediately obvious quality of the engine, but I am staying for the improvements and quick communication.
The thing I am making, I would probably shelf it if it wasn't for XPBD.
Or worse, do it with Unity. Which seems to have a pretty good built-in 2D physics engine, far outperforming that of Godot. But that is pretty much synonymous with shelving it for me.
Sorry, I am yapping today.
I mean the performance of godot is probably better than bevy_xpbd ... I do know godot's new physics engine is very unreliable tho ๐
No... Well, Godot 2D physics cannot reliably resolve a simple circle colliding with two rectangles same iteration. It picks one.
And the result is just painful.
And it is a known error, not something I am making up.
I think I would've had to go back to the drawing board if we only had bevy_rapier and I couldn't find creative solutions (like sdf collisions) to my game's biggest performance drains ... And afaik rapier still doesn't allow you to do determinism correctly
Which means that if you tesselate a complex object, it is at best totally unpredictable what will happen.
Sure. I might be wrong about this. All of it. But this library is by far the closest I have been to manifesting my vision. Rapier let me down day 1.
Sorry, I am treating "crate-help" as "lets-just-chat-about-stuff".
If only discord allowed threads in topics, we always seem to need them here :')
I personally don't mind random convo in this help thread/topic as long as it relates to physics or xpbd in some way, which this does
I am yet to make the tesselation for import of Lyon, but I think xpbd will do it better; if it interacts with multiple bodies it will be reasonably translated.
worst case you can convert your game to sdfs
In Godot, just slap a bunch of rectangles next to each other and you will see that it doesn't treat it as an extended plane.
I made some videos exhibiting this behavior, but I won't bother you with it.
well that's just a numerical thing to some extent, I'm pretty sure parry also has issues with edges like that
Ah, that edges thing ... I think we got some fix for that to some extent in xpbd, but I do remember rapier struggles with it more ... Might also just be specific to a physics approach too ๐ค
I think in 0.1 things exploded if they touched two edges at once like that ๐
xpbd doesn't have any "internal edge fixer" or anything so I'm a bit skeptical but idk
So the usecase would be a game of Arkanoid or something like that. Breakout. Where blocks are next to each other.
while rapier does have something like that iirc (or was it parry?)
Substeps vs iterations does cause pretty different behavior in such scenarios I think
Using Godot you cannot expect the out-angle to be the in-angle reversed if you hit two blocks at the same time.
You can end up having one of the blocks sending you literally back where you came from instead of just inverting Y.
And if it is indeed an issue, how can you interact comfortably with anything complex by tesselating?
Honestly, I didn't even check the engine if it does this correctly. I was just depressed over Godot and Rapier. But... Unity does it. Perfectly, it seems.
This case should be fixable at least, even if xpbd doesn't currently handle it correctly ... It's just solving penetration constraints with multiple contacts on different objects
Even if you get weird edge normals they should even out to having a -Y normal ๐ค
Unity uses PhysX (or can use Havok as well I think) which I would expect to be one of the best physics engines probably
Or X/-X normal if it hits on the side
PhysX is definitely one of the better tested engines yea
Godot 4's physics is an absolute trainwreck, everyone has been hating on it ... And rapier has decent performance for broadphase and narrow phase for how relatively small it is, but it's very rare to see it produce convincing physics behavior
I will make a small test for it. But what I am looking for might already be good for xpbd. Just a bunch of blocks as a "floor" and expect it to not hurl you in the X-direction. Godot hurls you in the X-direction when it is at the edge.
Ideally it would null with a larger plane.
there's even a Rust binding to physx but it's weird of a weird slice of the API and so hard to use it for general purpose stuff
for instance, the api has ray casting but not shape casting
Sorry, by "null" I mean it would be the exact same result as a conflated plane.
sweep tests?
Damn, even my sdf collisions has shape casts and I don't even use them
or do you mean the Rust API specifically
physx has them, but the rust api doesn't expose them
gotcha
There's also a fair bit of overhead on these bindings usually, right?
If you bind to C I cannot reasonably see that there needs to be an overhead, but there might be. I mean, at the very least you need to massage the data most of the time.
well and you might need to duplicate all your geometry
you'd at least need to interface with the ECS as well in the case of Bevy, like with rapier
Yeah, sure, but I am already duplicating geometry from physics to rendering. But sure.
the hard part about binding physx is that it's a lot of C++. Not impossible, just not enough man hours on it yet
Yea you get that rapier overhead, and some bindings overhead, which also break a bunch of optimizations I think
C++ is just a horrible language for libraries. It is good for applications and open source stuff. But if you get binaries in C++, it is very hard to predict what is going to happen.
I am not making this up, I wrote some libraries for FinTech in C++ and just differences in stack unrolling for exceptions made it almost impossible to reason about.
It doesn't only change from compiler to compiler but also versions of the same compiler. Microsoft seems to have almost decided on what it should look like. It is worse on Linux and Solaris.
Nothing against xpbd, it's great, but I've definitely considered using the bevy_mod_physx just because physx seems to be industrial strength. But I think given the state of the API, you'd probably want to write C++ code that exposes a thin C wrapper with a simple entry point. Then call that from rust.
yeah I think the "easiest" way to get super stable and tested physics would be to use PhysX bindings, but it does have downsides and is maybe more annoying to work with
There's also the part where if you need serious physics performance, xpbd and rapier just don't perform well enough
I am happy here. As long as we are moving forward. And the nice thing about compiling Rust to WASM is that I can change it out from day-to-day.
If I ever make money from this project, I am happy to fund further development. Hold me to that when I am drinking Pina Coladas benefiting from you all's work.
cubes
and 90% of what I need for physics is actually just colliders with reasonable responses for kinematic controllers. I'm NOT actually doing a proper physics sim anywhere
I swear this performed worse before
xpbd funding? Is Jondolf getting the lifetime of physics dev after all? ๐
๐
could the 0.12 instancing be helping here?
Dudes, I am happy to fund you out of pocket if you help me make my game work. ๐ Courtesy of Amex.
I should implement collisions between cubes and any other shapes in my sdf collisions so I can compare the numbers with parry ๐
This looks great.
I might accept sponsors after I'm done with high school yeah, for now I don't want that though
At least I'm confident I'm gonna win if it's sphere on concave collider ๐
I hope it is clear that I don't want to sway you. I want the best product.
probably won't impact development though, I'd build it normally either way
Main difference with funding is if you don't need to work a full time job you can keep working on xpbd
Yeah. I just think that working for something more than 3 hours a day for a long time isn't good. And then, accepting money turns it into a job.
well I'll be in uni for the next several years either way, and I don't plan on getting a full time job in the near future
We just need to make sure there's xpbd funding before jondolf considers working as FMSC, because everyone who starts working there stops maintaining their crates ๐
I just know that if my game ever ends up popular, making sure bevy and bevy_xpbd stay maintained would be the biggest priority after being able to keep working on my game fulltime. I could probably replace or maintain every single other crate I use besides those two
A million? That is nothing these days. With my bouncing balls, I can give a billion. But don't ask for a trillion, then we have an HR-issue.
just need to watch out for Nvidia lawsuits...
Isn't the paper open, tho? Unencumbered by patents?
PBD and XPBD are technically patented, but then the authors of the papers have open source implementations with permissive licenses
hard to say how enforceable it is
Hm. Interesting. We'll be fine, is what I am thinking.
I wouldn't be surprised if some sdf collision tech is patented too, considering how few papers there are compared to the number of proprietary softwares that use it
Well, I mean, back in the days XOR was patented with making a blinking cursor.
Smoke and mirrors.
sebcrozet also said that one of the reasons Rapier didn't switch to XPBD is because he wants to be sure there aren't patent issues
Just gotta make sure you don't implement it on GPUs with AMD support and you'll probably be fine 
I am putting my eggs in this basket. And to the extent I can I will be happy to contribute. I am not a good Rust coder at this point. I do have code in mainline Microsoft products to relieve memory pressure, so I am not a total slouch.
and luckily bevy_xpbd is somewhat built with this in mind with it's modularity, so if Nvidia did give a cease-and-desist, I could probably switch to a different simulation method in a couple of weeks
just need to rename ๐
bevy_xpbd is the best basket to put your egg sdfs in
Just make sure you don't put in egg trimesh colliders because then parry will screw you over ๐
God damn it. How hard is it to just test that?
I would boycott Nvidia for the rest of my life though lmao
I would join you on that boycott ... Not that I ever get anything nvidia to begin with
they have so much cool tech and a ton of research, but they have an outrageous amount of patents
Realistically most of nvidias patents and proprietary tech are hard to enforce, amd almost always copies it and makes it opensource and clearly nvidia isn't winning cases about it otherwise they wouldn't keep doing it
It seems like if it is described in a paper with an open source implementation, it is made to be hard to enforce.
Yea that's the sad reality of these big companies, they swoop up all the good people, then patent all their research
here's one example of MIT Position Based Dynamics, and it's from the paper author who also works at NVIDIA
https://github.com/matthias-research/pages/blob/master/challenges/PBD.js
My web page containing all the demos from my youtube channel "Ten Minute Physics" www.youtube.com/c/TenMinutePhysics - matthias-research/pages
Matthias Mรผller is a legend tho, so many amazing papers and a lot of educational resources
despite being at NVIDIA
Realistically if you're a good researcher, you just end up at whatever company gives you the most to keep doing your research
And they'll then patent all of it, probably with no real plans what to do with it, other than maybe erasing unwanted new competitors
the question about the patents was also asked from Mรผller on the Ten Minute Physics Discord, but no answer from him so far
although his latest message there is from over a year ago lmao
probably sent to the NVIDIA dungeon for open sourcing PBD code
Does physx even use this tech they research?
XPBD is used in Unreal
I wonder if Epic licensed it or if they also think "it's opensource so your patents are invalid"
So every rigidbody here is configured with Restitution(0.0), sometimes the collision response seems accurate and mostly inelastic, and sometimes it seems very elastic. I guess I wouldn't really consider this explosive.
I've been seeing these games everywhere, I had been wondering when one would start using xpbd ๐
๐ i wanted to try out rust
So far I enjoy rust a lot more than I ever did cpp, etc. I'm usually devving in scala
Trying out rust with bevy and bevy_xpbd is the best choice ๐
Also wanted to try making a game with ECS, never done any of this stuff before
and SDFs ๐
I used to dislike rust, but now I've been using bevy for almost a year and I'm starting to consider rewriting Go things in Rust ๐
But yea that seems mostly fine except sometimes when it explodes when to spheres hit eachother, looks a lot like the video jondolf sent before
Yep, that's the main issue that affects the gameplay
Makes it very non punishing to stack improperly
Since eventually the whole thing kinda just explodes when it gets big enough, and things that were stuck before are no longer
I'm soon releasing the fix I found for my issue, we can see if it's the same issue
I mean on the flip side, it does feel very satisfying when everything explodes and all the pieces merge ๐
These games get very frustrating when the physics makes all spheres at the bottom sleep and they never wake up again, being locked until something directly next to it gets merged
Pretty sure the intended behavior in xpbd is that they start waking up in a chain tho ๐ค
they should currently wake up when a collision ends or a colliding body moves
but an island architecture would probably be good
the way sleeping is handled is... questionable in some ways
but it works decently so ๐คทโโ๏ธ
Worst case you could always make them have 0 friction and they'll spin for all eternity, never going to sleep ๐
I don't suppose someone could find me a research article about economics real quick?
do my homework so I have more time for making 0.3.1 ๐
(I'm kidding... unless you do find one)
Research articles about economics? But economics aren't even a field of science, they're just a big scam that uses math ๐
This sphere has been spinning on my server for over 24 hours ๐
it's not about math though, it's about how the state of the economy or things like changes in taxing affect people and their behavior
although I'm not sure if the English word "economics" is what I'm referring to
I mean "taloustiede" which is "economy science" basically
I think economics is correct yea
Ah, cool. I watched Otto on stream making this with Rapier.
It's just a meme because economists often consider theirselves scientists, but most scientists don't because they tend to ignore reliable studies in favor of ones that clearly got manipulated by rich companies
Math isn't science.
This triggers people who think science is a pinnacle. Math is better than science.
And with this I actually think I will talk to you all tomorrow. Thanks for the chat and the help.
Science isn't really a pinnacle, it's just a method to do things ... Math might fit it or not depending on how you define it ... You can't really do experiments with math tho, since it's not a real world phenomenon, and it also needs to be built up from things the can proof, rather than building upon best guesses that haven't been proven wrong yet
also that's a good stress test, we now know that the simulation works for over 24 hours ๐
should put that in the README
Oh yea, my game is excelent at testing such things
xpbd has been very stable over time after the qbvh thing got worked around
Rapier was never this stable, it would eventually crash with some meaningless error because it produces NaNs rarely for normal collision responses, then fails assertions elsewhere
It's excellent for testing everything
can't wait for soft bodies
check this out: https://bubblepins.com/blog/sdf-used-to-deform-geometry
Looks like updating a heightmap or voxel grid with SDFs ... You can just value = max(value, -sdf), maybe use smooth max ... Interesting idea tho, using sdf colliders to make things like snow or water physics more accurate
Another naive question: is this something that could be done with a compute shader?
Offloading sdf physics to the GPU is definitely possible, but it makes your physics very inflexible, especially in that you can't run it on a server unless it has a GPU
Not sure if solving XPBD constraints can also be offloaded onto the GPU tho ... But I feel like at that point nvidia might actually get annoyed ๐
you can
I might actually look into it at some point ...
Because I feel like cloth/hair physics belongs on the GPU 
it's MIT :P and yeah this is cloth
https://github.com/matthias-research/pages/blob/master/tenMinutePhysics/16-GPUCloth.py
@vestal minnow Sign up for gitlab sponsor funding? I'll easily kick in $5/month...
in about 4-5 months maybe
I'm not sure whats worse ... Having a highschooler develop a physics library for free ... Or for $5 a month 
I would be funding development of libraries too, but I already spend Infinity% more on my game's hosting than I have income ๐
Well, theoretically, it's not just me throwing in a few dollars.
AWS EC2 node with an A100 is only, like $60/hour. ๐
I just run the game on a 2core VPS at hetzner
For like 5 euros a month
It can handle a few hunderd players now I think
$5 is more than I've ever gotten from working... because I've never had a job
(I do get money from the government tho)
I also get some money for the government ... To pay health insurance ... They give me more than the health insurance costs so really the government funds my game's hosting ๐
If I ever need to upgrade we're gonna be seeing how bevy and bevy_xpbd behave on ARM 
brave of you to say that publicly 
surely there's some government official from the Netherlands in this game engine's physics engine's help thread, and they know how to find you
The government doesn't give a shit. This whole system is entirely broken, everyone complains about it, and they don't care about fixing it
In some cases you can reduce your working hours, and the government will give you so much extra money you get more per month than working more
welfare traps
Yea, but in reverse 
They should just introduce basic income
Then I don't need to worry about getting a meaningless job at some IT company and I can continue doing the important work of making SDF collisions for an obscure game engine
exactly
yeah for 2D it uses box2d
if glam with libm is cross-platform deterministic then maybe we're (close to) beating Unity on that front
except I recall reading that their ECS physics is deterministic
Hey stop giving me reasons to test these new ARM VPSes hetzner started offering ๐
Don't worry tho, it'll happen eventually
Once I release my game and can't predict how many people will show up I'm gonna throw it on a separate VPS, and I'll ofc use the ARM ones because they are more power efficient which means my game's hosting would be less bad for the planet
@merry tide For 0.3.1, I think I'll leave the collision event thing as it currently is because it's kinda tricky to fix with the current way it's handled, at least without breaking changes. I'll try to rework it at some point though and hopefully fix the issue
for now, you can use the prediction_distance: 0.0 thing
it should work fine in your case
I don't think the shapecasting code has really been touched since 0.2, but you could try inverting the ignore_origin_penetration setting (from false to true or vice versa)
what exactly are you trying to do with the shapecast?
is that what you have in main atm?
Cool, i'll test it
i did try setting: prediction_distance: 0, and that didn't seem to fix anything
in narrowphase
that also discards this fix since it relies on the prediction distance ๐
seems a lot better
i haven't seen them bounce high at all yet
is there anyway to make these bodies "squish" or emulate that
in the game when something below combines, i have it resize the collider over time to not make it explode
trying to assist that
there's not a nice way currently
I guess you could set SubstepCount to 1
but that just makes physics accuracy worse (which includes making things squishier)
ideally we'd expose the compliance (inverse of stiffness) of penetration constraints (the things that handle contacts) but that's currently not possible
or add a CollisionStiffness component or something...
yeah i guess that's more of a stop gap before more involved softbody stuff huh?
fyi the game feels a lot better now on that branch
the penetration constraint compliance is very different from actual soft bodies, it just controls contact strength/stiffness while soft bodies consist of a bunch of particles that are constrained by volume, distance and bending angles
cool!
yeah i guess that would be pretty useful
this guy has very good videos on XPBD and soft body simulations with it
they're the type of things I'd like to eventually implement in bevy_xpbd, and what I used for an old experimental demo I made months ago
(although that was just implementing the first and maybe second episode basically)
ah so the issue is that the ball is spawned overlapping the wall and not right next to it which causes it to explode
so the shape cast hit data seems to be wrong
you could maybe test with debug rendering to see where the shape is at the hit point
it's not visible with SpatialQuery but you can render it manually with PhysicsDebugRenderer. For ShapeCaster it's like this
fn debug_render_shapecasts(
query: Query<(&ShapeCaster, &ShapeHits)>,
mut debug_renderer: PhysicsDebugRenderer,
config: Res<PhysicsDebugConfig>,
) {
for (shape_caster, hits) in &query {
let ray_color = config
.shapecast_color
.unwrap_or(Color::rgba(0.0, 0.0, 0.0, 0.0));
let shape_color = config
.shapecast_shape_color
.unwrap_or(Color::rgba(0.0, 0.0, 0.0, 0.0));
let point_color = config
.shapecast_point_color
.unwrap_or(Color::rgba(0.0, 0.0, 0.0, 0.0));
let normal_color = config
.shapecast_normal_color
.unwrap_or(Color::rgba(0.0, 0.0, 0.0, 0.0));
debug_renderer.draw_shapecast(
&shape_caster.shape,
shape_caster.global_origin(),
shape_caster.global_shape_rotation(),
shape_caster.global_direction(),
shape_caster.max_time_of_impact.min(1_000_000_000_000_000.0),
hits.as_slice(),
ray_color,
shape_color,
point_color,
normal_color,
);
}
}
dumb question but the ball isn't scaled via Transform right?
idk it's hard to say
especially if the line looks correct
nothing has been changed for cast_shape I'm pretty sure
and yeah the shapecast result in my demo is correct
or it can overlap other colliders in specific positions but I don't think that can be avoided
like this
although that could be the gizmo thickness actually
I think I'll just release 0.3.1 now, it has the fixed timestep fix and contact explosion fix + a couple of other smaller fixes
the fixed timestep thing is bad enough that I want the fix released ASAP
I can always make a 0.3.2 for further patches
I did release 0.3.1 btw #crates message
I'll try tomorrow, don't have time today
yeah hmm, that's odd
Related to xpbd patent stuff I think one idea might be to rebrand bevy xpbd
idk how much that matters if it still uses xpbd
since the patent is on the simulation method
is XPBD trademarked? surely not
I don't have any strong objections against renaming it though since the focus has gradually shifted from the "xpbd" part to the native Bevy physics engine part
mainly that people know it as bevy_xpbd and there hasn't been a meaningful incentive for a rebrand
ofc if it were to be eventually accepted into the Bevy nursery (once that RFC gets merged) and upstreamed, it would definitely be rebranded
right now I don't know what it would be called if not bevy_xpbd though since it can't be bevy_physics of course and probably not bevy_mod_physics
As a non-lawyer, I have heard from lawyers more than once: don't speculate about software patents.
In the sense that you should be extra careful or not care?
There is nothing good that can come of having a record of software engineer's opinions in this area.
I am choosing my words carefully ๐
Of course, if there is a known patent on some areas, that should be avoided.
well this is the patent / one of the patents, it covers pretty much the entire core of PBD and XPBD in a somewhat ambiguous manner
the consensus has generally been that it seems unenforceable, and that the original PBD patent was somewhat questionable considering there was prior art
and especially considering that the actual authors have open source MIT code with PBD/XPBD, you would assume it's fine to implement
but my legal knowledge is very limited so I can not say whether or not they could enforce the patent and what the impact would be
The more ambiguous patents get the less enforcable they become ... It's like nintendo with their physics patent ... No one would enforce that
Like this just seems quite generic
Embodiments of the present invention provide a position-based dynamics approach for simulating objects using a set of points and constraints, applied as equations that restrict the relative motion of bodies. Forces are applied to the points to move them, and the constraints ensure that the points will not move in a way that is inconsistent with rules of the simulation.
But I guess this is a bit more specific to XPBD
The present invention improves upon existing PBD approaches by using regularized constraints that directly correspond to well-defined energy potentials, and which can advantageously be solved independent of time step and iteration count.
but still quite ambiguous in my opinion
I'm also not sure if there's any precedent for patents being used against individuals or non-profits
This is the kind of speculation that ends up in court documents.
And, NiseVoid: individuals, usually not, because the goal is usually a monetary shakedown. But non-profits, definitely.
Nvidia is, at a least, a practicing entity -- that is, they do stuff other than just own patents and sue. It's the latter that are really dangerous.
Who would theoretically be sued in this case? I am an individual currently developing it without monetary gain, but someone could use it in a monetized application
I think they could have github take the repo down or go after devs
If they do the latter they'd be imploding their company however 
You, github, users, anyone.
NVIDIA would put theirselves in a very dubious situation if they ever go after anyone for these cases however, because they do this exact pattern everywhere:
Release a paper and opensource code, but also patent the concept
isn't this a software patent, which aren't valid in the EU?
Oh are they not?
that's a USA problem
Did they even file the patent in the EU? 
One thing I don't understand, though: this patent was filed September 24, 2018. This https://dl.acm.org/doi/10.1145/2994258.2994272 is October 2016.
NVIDIA does this very often. They patent stuff they released and published later
I wonder how that works for something international like FOSS on GitHub
Github can get told to take it down, which would result in a whole wave of drama again :')
generally you can't do software patents in EU, I wouldn't lose any sleep over it.
I wouldn't count on the EU here. It's more complicated than that. See https://en.wikipedia.org/wiki/Software_patents_under_the_European_Patent_Convention
The patentability of software, computer programs and computer-implemented inventions under the European Patent Convention (EPC) is the extent to which subject matter in these fields is patentable under the Convention on the Grant of European Patents of October 5, 1973. The subject also includes the question of whether European patents granted by...
literally everything is covered by a vaguely worded patent if you look hard enough
doesn't this mean it's not patentable?
it's not patentable in the EU I think, doesn't mean GitHub won't do something stupid in response to legal enquiries, but seems doubtful
This is one of the reasons it's not recommended for engineers to speculate about whether something might be covered by a patent
I've been on the receiving end of software patent troll nonsense before, and we just replied "we are in London, UK - go away" and never heard back
(after discussion with legal, the first couple of times..)
The basic scheme is: what's patented is not a program, but rather something like " a machine which uses this process". It's a whole legal shell game.
Yea you can't patent a program, since code falls under copyright
And to begin with they opensourced that code ๐
I feel like "mathmatical methods" might be closer to what the XPBD patent describes
Anyway, you can't patent something that's already public. The whole point of patents in the first place is to encourage publication rather than trade secrets. In return, you get a protected monopoly. (This concept isn't terrible, but the 20-year period is crazy for software.)
But algorithms can be patented to some extend, just look at the world's biggest patent troll: Adobe
In the US, there is a 1-year exception for disclosure by the original inventor.
I mean nintendo tried to patent physics ....
But October 2016 is more than a year earlier than September 2018
Unless I am doing my math wrong. ๐
Maybe nvidia offered some conditions to researchers that they wouldn't patent it for X time on the one hand, but the patent department still patents everything anyway
Might explain why they never use their patents when AMD literally copies what they just made ๐ค
and this too http://blog.mmacklin.com/2016/09/15/xpbd/
I am not a lawyer and this is not legal advice. But, if you are using public information from more than a year before the patent was filed... that seems low-risk.
Opensource software with patents are generally dubious
The only thing it can protect against afaik is competing proprietary software, tho you can still get people to go to court which is really annoying and can discourage people from using it. Tho not big companies obviously
The Apache 2.0 license ideal because it contains an explicit patent grant.
I'd imagine publishing research then patenting it later is a similar case too
You can't just publish a paper and then start going after other researchers for breaking your patent
Indeed, you cannot.
Unreal's info about XPBD doesn't mention that it's NVIDIA's tech either, which nvidia would've surely put in the license terms
If epic saw a chance to not license it they would've taken it and defended it in court, and there's no info on those cases
The real question tho ... Why do patent offices always accept these bullshit patents?
It wouldn't necessarily even be that big of a deal if GitHub was forced to take down the repo for whatever reason since I could make a non-xpbd version relatively quickly, but I'm primarily concerned for people using it (or if they come after me specifically ofc)
and it would prevent some cool cloth and soft body stuff I guess
also would crates.io have to take down the crates too ๐ค
I think just the fact that XPBD has been used and covered in various places with clearly no sign of licensing proofs they never tried to enforce it. If they try to enforce it now they'll just get told they can't
I also don't really want to try to reach out to them directly in case that'd just make them aware of it and react... despite there being several XPBD projects already
Unless someone suddenly causes financial damages using it ... But I'm not even sure what you'd have to compete with to cause nvidia damages
Unreal
Competing with unreal wouldn't cause damages to nvidia, especially when unreal seems to not have licensed it either
Maybe if you set up some really obscure situation where everyone wants to get AMD cards instead of nvidia cards because of the use of XPBD
But I literally can't think of any way you could do that ๐
If anyone does think of a way to push AMD cards I would like to know tho, would be great to push back against this trend of opensource software only supporting CUDA 
Unreal uses PhysX and PhysX is by NVIDIA, and Unreal uses a lot of other NVIDIA things too afaik, so I would assume NVIDIA to benefit from Unreal indirectly at least
NVIDIA benefits from all game engines anyway
maybe we should add a cuda feature specifically to please nvidia ๐
I mean you can just run CUDA on AMD GPUs with vulkan ๐
Supposedly PhysX is also opensource
NVIDIA's presence in the physics world is very inconsistent and confusing 
They also do SDF stuff ... Which they publish no info ๐
maybe they will, first they'll just patent it
despite them existing for years/decades
I mean either way patenting math seems like it's doomed to fail