-
Two related questions here. Pardon if that's not desired: should I be splitting them into two posts? (Seems once people spend the overhead reading I shouldn't impose it again...) I'm trying to draw what look like 2d lines on a page in a 3d Bevy world, so I can later add 3d annotations. So I tried to smash together two standard Bevy examples: Q1: My newbie interpretation of the error I get: Q2: There are gaps in my lines that seem to indicate the Picture of problems, followed by a long-ish minimal example, follow. TIA! Your caring that I get this right, and quick/correct responses in the past have been deeply appreciated.
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Why am I getting this error message?You deduced it right. The default picking backend for This is a difficult problem to solve. I can't give you a ready-made solution. You
Why are there gaps in the lines?Your event handler is as follow: On::<Pointer<Drag>>::commands_mut(|event, commands| {
commands.entity(event.target).insert(CursorOnPage {
entity: event.target,
location: event.pointer_location.clone(),
delta: event.delta.clone(),
});
}), It overwrites the #[derive(Resource)]
struct DragPoints(Vec<Vec2>);
struct AddDragPointCommand(Vec2)
impl Command for AddDragPointCommand {
fn apply(self, world: &mut World) {
let mut points = world.resource_mut::<DragPoints>();
points.push(self.0);
}
}
// ...
On::<Pointer<Drag>>::commands_mut(|event, commands| {
commands.add(AddDragPointCommand(event.pointer_location.position));
}),
// ... You could also run a system that sends an event. Then you could read all the events one |
Beta Was this translation helpful? Give feedback.
-
I followed both parts of the @nicopap advice: collected points in a resource and generated meshes for the lines. Fortunately lyon is compact and seems to do a good job. (Took days to first try making my own meshes, then trying to isolate code from Cairo and Skia. Grateful for lyon!..) Here's the current state if it helps anyone. Remember, I've barely begun so I'm sure it could be done more concisely or with better form--but just in case it helps someone else I wanted to share it:
|
Beta Was this translation helpful? Give feedback.
Why am I getting this error message?
You deduced it right.
The default picking backend for
bevy_mod_picking
uses mesh collision to detectwhat the mouse is hovering. To tell if the mouse is hovering over a mesh,
bevy_mod_picking
reads theMesh
vertices and applies a collisiondetection algorithm that is specific to meshes with a
TriangleList
topology,it can't handle other kind of topologies.
This is a difficult problem to solve. I can't give you a ready-made solution. You
can do the following:
TriangleList
topology for your lines, and store them in RAM.This would also allow you to customize your line width!