Best way to check if object is inside or outside of a CartographicPolygon

Hi,

Just seeing if anyone knows an efficient way to query if a location in the world is inside or outside of a CartographicPolygon.

Use case example is because the clipping is a material function and only excludes fully occluded tiles, the player pawn could run a check with the current closest Tileset and somehow either through material or via the CesiumPolygonRasterOverlay component run a check to see if the player Pawn is currently inside the polygon shape. If so we could disable the collisions for the tileset and re-enable them once outside.

Just getting thoughts on the best way to query this either via blueprint or c++ seeing as how we have already calculated where the polygon raster lies we should be able to check a world location. Maybe sample the buffer that is used by the Clipping material layer.

Thanks,

Dan

Hi @V2i,

I can think of two possibilities here. One is that you can use Blueprint functions available on the USplineComponent to test whether a point is inside or outside the closed spline. I found an example Blueprint that claims to do this, but I haven’t tried it myself:

The second possibility is to use C++ and dig down into cesium-native to get it to do the test for you. Basically, you need to:

Again I haven’t tried that, but I think it should work. If you try it, let me know how it goes.

Hi @Kevin_Ring ,

I have made a super simple test version in blueprints just to see if it’ll work gameplay wise.

Preliminary it is promising. Basically works by

  1. Get the current tileset closest to the player pawn that is visible
  2. It checks if it has a PolygonRasterComponent and if Polygons is populated
  3. Runs a loop check on each of the current Polygons to check if the player pawn is inside closed loop polygon spline
  4. If inside, break the loop and set the Tileset to not enable collisions

This is working and allows small roads to be cut into Photogrammetry and have the player be able to drive down it without colliding with the Photogrammetry that was clipped out.

I am looking at making a PR as currently you can only Enable/Disable collision on the tileset in it’s entirety. Whereas I have made a new function that allows blueprint node to set specific channel response across the tileset so you can have the tileset ignore the Pawn object but still collide with other object types.

I’ll have a try with the cesium-native way and see how efficient it is compared to doing it with the Unreal components.

Hi @V2i,

Glad to hear you got something working. We and the rest of the community would love to see a pull request with your solution!