Raycast - Get vertices from body with multiple fixtures

Hi Box2D forum,

i have a question about a body with multiple fixtures (all fixtures are polygons). I want to split the body. For this i use a raycastcallback to figure out if the line hits the body.

The raycastcallback works fine. I make a raycast in both directions, so from startpoint to endpoint and from endpoint to startpoint.

The Problem is that the start and endpoint of the raycast not always interest the whole body. So the exitpoint (a property of my class) is always the last interection of the raycast. Because the line is the startpoint from

Code: Select all

cctouchbegan
event and the endpoint is the last location from

Code: Select all

cctouchmoved
.

To save the current states of the body a have a class with properties like sliceExit, sliceEntry etc. The property sliceExit (

Code: Select all

BOOL
) represent the final exit of the interection. I don't know how i figure out if the line exit the body, because the body has multiple figures.

You can trust me that i tried many things before posting this post. But all failed ):

My next idea would be figure out all vertices from body (not the vertices in the body, only the border of the body). But i have no idea how can i do this.

Sorry for my bad english. I hope everyone understands me. If there any questions or ambiguities about this post, ask me.

Thank you in advanced (:

Greetings Alex
Could you show a diagram of the problem case?
Here is a picture for demonstration:

Image
Here is a picture for demonstration:

Image

so here is the body with multiple fixtures. The line goes not always complete through the body like in this picture.
Ok, so that diagram is not the problem case then...

The simplest way to check one of the end points is inside a fixture is to use b2Fixture::TestPoint.

You could also cast the ray in both directions against all of the fixtures, and if you get an intersection from one direction but not the other, you'll know that one end is inside the fixture.

Original thread: https://box2d.org/forum/viewtopic.php?t=9495