rive-app / rive-bevy

MIT License
94 stars 4 forks source link

expose path data #14

Open simbleau opened 11 months ago

simbleau commented 11 months ago

I have the need to tessellate my vector graphics to receive a convex hull used for game physics.

I can easily do this with lottie and svg files, but rive doesn't seem to expose the underlying path data in the runtime.

Given framerate and animation length, Is there such a function of t, time, to receive the path geometry in that moment?

See: https://simbleau.github.io/rust/graphics/2023/11/20/using-vello-for-video-games.html#physics

dragostis commented 11 months ago

rive-rs comes with a Vello back-end implementation included. You could get the path data by listening in on that implementation, but this pretty much means copy-pasting the implementation.

Another way to do this would be to query the path data from the runtime, but this would require writing quite a bit more APIs to get there.

simbleau commented 11 months ago

I am suggesting the latter, e.g.

let handle = query_artboard.single();
let time = 0.25; // seconds
let path_data = bevy_rive::runtime::get_data(handle, time);
dragostis commented 11 months ago

You could achieve that by listening to Renderer::draw_path after calling Scene::advance_and_maybe_draw. This will only give you the path data that changed from last frame though.