appsinacup / godot-rapier-physics

Godot Rapier Physics – 2D and 3D physics engine for the Godot game engine. with better stability, performance, liquids, determinism, state serialization and no ghost collisions.
https://godot.rapier.rs
MIT License
392 stars 20 forks source link

ConcavePolygonShape2D noisey errors, clipping. #285

Open lgrammer opened 1 week ago

lgrammer commented 1 week ago

Describe the bug

Noisey errors from ConcavePolygonShape2D and clipping during collider regeneration that doesn't occur with default physics engine. The errors occur when colliders are generated, whether that's when loading up, or regenerating the mesh/collider. The clipping occurs only during regeneration.

image

To Reproduce

Use some segments to build a concave collider. My data is from a marching squares algorithms triangles list, but whatever should work as long as you pair points correctly.

image

Then swamp out the default engine from Rapier, that's when the yelling starts. Everything works outside of clipping. Collisions stay the same. Debug lines stay the same.

Expected behavior

No errors, no clipping or changes when swapping physics engines. I'll refrain from adding more information unless requested for now. This could honestly just be a user error or something simple as I was just swapping over to your plugin to check out the cool fluid stuff.

I've done a solid bit of stuff (tinkering) with Bevy/Rapier and iirc Rapier uses vertices and indices for polylines so maybe there's something going on there

In the default engine during the collider regeneration I can move along in a straight line. It's impenetrable and you can't get through the collider anywhere.

image

When switching back to Rapier and holding down the mouse key to regenerate the chunks as I move along, I can clip through.

image

If this isn't some sort of user/setup error on my part and you want a minimal example zipped up let me know.

Ughuuu commented 1 week ago

Forgot to make a new release, will create v0.8.8 and you can try with that. If it still happens put a reproducible project.

Ughuuu commented 1 week ago

Check with 0.8.8

lgrammer commented 1 week ago

Checked with 0.8.8 and while that did indeed solve the errors issue, it seems clipping is still there during collider regeneration. Tested with fast SIMD and regular. Will work on zipping something up tonight.

lgrammer commented 1 week ago

rapier_clipping.zip

Couldn't zip it up with your addon included as it was just a bit to large, sorry about that.

The collider regeneration occurs right after triangulation in the refresh function in the VoxelGrid class. Any chunk undergoing regeneration can be clipped through while it's occurring only when using Rapier for physics. The marching square method used is a port of this Unity implementation and follows similar naming conventions. So the 'voxels' are just points that compose the cells used for marching squares. Walking through the points in the triangles is how I get the collider polylines currently.

Ughuuu commented 1 week ago

Np, you normally zip without the addon. Ok i am able to debug it locally. Will check why it clips.