Home Unreal Engine

Built in method for detecting line intersections in blueprints

poopipe
grand marshal polycounter
Offline / Send Message
poopipe grand marshal polycounter
I want to determine whether a point is within a non convex ngon (2d obvs) using the project a ray from outside and count the intersections method. 

I'm lazy and don't want to put the 500(possible exaggeration) nodes required to do the sums into a graph by hand so I'm hoping there's a built in method I haven't found yet (I don't really know the libraries)

Before anyone suggests the line trace nodes I don't think  they work in this context as there is nothing to trace against

Ta

Replies

  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
    There is a function to check if a point lies within a 3d box, but there isn't one for arbitrary 2d shapes. Though this sounds super simple to do in a shader. You wouldn't even need to trace. Giving back the info to the cpu would be less easy though. What would be the use case for this?
  • poopipe
    Options
    Offline / Send Message
    poopipe grand marshal polycounter
    my specific use case is distributing objects within the area covered by an arbitrary closed spline - i need to check whether the point is inside the spline to determine whether I should place an object there or not. 

    The idea is that you trace a line from a point outside the spline to a target point that you want to query and assume that if the trace intersects an odd number of edges the target point must be inside the shape


    I've ended up implementing the answer by Gareth Rees on this page (first discarding points outside the bounding rectangle of my spline for speed's sake)

    https://stackoverflow.com/questions/563198/how-do-you-detect-where-two-line-segments-intersect

    There are some potential hiccups around parallel or colinear lines but it works fine for my purposes since I am only interested in successful intersections
  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
    I see. Since its a spline, what immediately came to my mind is that you could have built a temporary "wall mesh" from the spline - using spline mesh, so then you can actually line trace against it. 
  • poopipe
    Options
    Offline / Send Message
    poopipe grand marshal polycounter
    It might be interesting to see how performance of that idea compares to what I did.

    I've not tried this with a lot of spline points yet (100+)  and I can see it getting a bit chuggy - it's not a realistic use case but would still be nice to have something that could cope
  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
    "It might be interesting to see how performance of that idea compares to what I did." - Yeah that would be interesting to see.

    Is this for spawning instanced meshes? Because then there is a more efficient way of doing this.
  • poopipe
    Options
    Offline / Send Message
    poopipe grand marshal polycounter
    Not directly,  I plan to use it as a base for a few things - long term  hoping to achieve a procedural street network and building generation 

    What's the more efficient way though? Might well come in handy for something

    It emerges I need to trace from more than one start point for this to be reliable since there are situations where it's unable to remove points
Sign In or Register to comment.