# In v2.6.0, Exclude Selected Tiles in CesiumPolygonRasterOverlay does not work

**URL:** <https://community.cesium.com/t/in-v2-6-0-exclude-selected-tiles-in-cesiumpolygonrasteroverlay-does-not-work/33124>\
**Category:** Cesium for Unreal\
**Created:** [June 17, 2024, 12:30pm UTC](https://community.cesium.com/t/in-v2-6-0-exclude-selected-tiles-in-cesiumpolygonrasteroverlay-does-not-work/33124 "2024-06-17T12:30:20Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![YRU2](https://avatars.discourse-cdn.com/v4/letter/y/ee59a6/32.png) [@YRU2](https://community.cesium.com/u/YRU2)\
**Post date:** [June 17, 2024, 12:30pm UTC](https://community.cesium.com/t/in-v2-6-0-exclude-selected-tiles-in-cesiumpolygonrasteroverlay-does-not-work/33124/1 "2024-06-17T12:30:20Z")

</div>

After upgrading to the latest v2.6.0, the tiles in the polygons are still loaded when wireframed, even though Exclude Selected Tiles is enabled. In my project I had imported a model created inside an erased polygon, but I can’t get inside it because the collision is still there and black shadows are falling. (I have seen similar postings in the community)

The version before I updated was 2.1.0, and in 2.1.0, when I turned on Exclude Selected Tiles, the tiles inside the polygons were no longer loaded.

v2.1.0

 ![NVIDIA_Share_Ff8zPLvzsw](https://global.discourse-cdn.com/cesium/original/3X/d/1/d1f51240f8230dadddf514b02913ae5967fbccf4.jpeg)

v2.6.0

 ![IPMsg_gK5AqXmSs5](https://global.discourse-cdn.com/cesium/original/3X/e/f/ef32d2e37fc9e948df0e1754cab3d72d996ce58e.jpeg)

I have tried this on several machines, all with the same problem. I have also tried UE5.3 and 5.2 with similar results, so I am wondering if 2.6.0 is the cause of this problem.  
Is this a bug? Thank you in advance.

---

<div class="post-metadata">

**Author:** ![janine](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/janine/32/5135_2.png) [@janine](https://community.cesium.com/u/janine)\
**Post date:** [June 18, 2024, 1:25pm UTC](https://community.cesium.com/t/in-v2-6-0-exclude-selected-tiles-in-cesiumpolygonrasteroverlay-does-not-work/33124/2 "2024-06-18T13:25:21Z")

</div>

Hi @YRU2,

Thank you for including screenshots in your post! I’m not sure why CesiumPolygonRasterOverlay would have broken between versions. 😕

Can you give us the longitude / latitude coordinates of the views in those screenshots? We’ll try to reproduce this behavior on our end, and from there we can try to diagnose the issue. Thank you!

---

<div class="post-metadata">

**Author:** ![YRU2](https://avatars.discourse-cdn.com/v4/letter/y/ee59a6/32.png) [@YRU2](https://community.cesium.com/u/YRU2)\
**Post date:** [June 18, 2024, 3:55pm UTC](https://community.cesium.com/t/in-v2-6-0-exclude-selected-tiles-in-cesiumpolygonrasteroverlay-does-not-work/33124/3 "2024-06-18T15:55:59Z")

</div>

Hey, @janine

The location shown in the screenshot is the default location when an empty 3DTileset is added.

Origin Latitude 39.736401  
Origin Longitude -105.257370  
Origin Height 2250.000000

 ![UnrealEditor_EHViGAWkWs](https://global.discourse-cdn.com/cesium/original/3X/b/f/bf884017ce0afa9d29d6ff1ddcbfde8dc6529e54.jpeg)

---

<div class="post-metadata">

**Author:** ![janine](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/janine/32/5135_2.png) [@janine](https://community.cesium.com/u/janine)\
**Post date:** [June 20, 2024, 2:42pm UTC](https://community.cesium.com/t/in-v2-6-0-exclude-selected-tiles-in-cesiumpolygonrasteroverlay-does-not-work/33124/4 "2024-06-20T14:42:35Z")

</div>

Hi @YRU2,

Thank you for sharing those coordinates. Just to document what I did:

- I opened a level with Google Photorealistic 3D Tiles, and set the **CesiumGeoreference** to your provided latitude / longitude / height.
- I added a **CesiumCartographicPolygon** and scaled it by 10 in all directions.
- I added a **CesiumPolygonRasterOverlay** to the tileset, and added the polygon underneath it. **Exclude Selected Tiles** is also enabled.

With all of these steps, I am able to see the tile exclusion behavior working.

 ![image](https://global.discourse-cdn.com/cesium/original/3X/5/a/5a6ff9679d18671749ad55864dd4c02409b86bcc.jpeg)

It may seem like it’s not working because the **CesiumPolygonRasterOverlay** only excludes tiles that are _completely_ inside the polygon. So, if part of a tile falls inside the polygon—even a little bit— then it will not be excluded. Otherwise, you’ll be missing tiles outside of the polygon border. As you zoom towards / away from the tileset, you can usually see that smaller tiles being excluded, while bigger ones are kept around.

![exclusion](https://global.discourse-cdn.com/cesium/original/3X/9/1/91fd6ce70dbe40a61f603bc45e46503885fe6d49.gif)

But still, there’s a chance that you did something differently that makes it break. If so, can you please point out what I missed?

---

<div class="post-metadata">

**Author:** ![YRU2](https://avatars.discourse-cdn.com/v4/letter/y/ee59a6/32.png) [@YRU2](https://community.cesium.com/u/YRU2)\
**Post date:** [June 21, 2024, 10:14am UTC](https://community.cesium.com/t/in-v2-6-0-exclude-selected-tiles-in-cesiumpolygonrasteroverlay-does-not-work/33124/5 "2024-06-21T10:14:35Z")

</div>

Thanks for the reply.  
The polygons were too small when I tested it so it didn’t look like it was disappearing.

When I make the polygons larger they start to disappear.

But I have another question, when I zoom into a tile, the difference between tiles that disappear and those that don’t is too big.

At the first zoomed in point in the video, the tiles seem to disappear nicely along the edges as you zoom in, but at the second zoomed in point, the tiles do not disappear after a certain distance.

Point 1  
 ![UnrealEditor_GdtGSwPvEN_1_3](https://global.discourse-cdn.com/cesium/original/3X/3/6/3630bbf7910055cf178f285bca1913ce330e189c.gif)

Point2  
 ![UnrealEditor_GdtGSwPvEN_1_6](https://global.discourse-cdn.com/cesium/original/3X/d/1/d1c4e3ed98db6b6452e81cf2d53358775314a9ab.gif)

I think this is the reason why I thought the tiles had stopped disappearing.  
Why is this stark difference?  
Also, is there any way to work around this (it doesn’t seem to be an angle issue, since I am squarely against the tile)?

---

<div class="post-metadata">

**Author:** ![janine](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/janine/32/5135_2.png) [@janine](https://community.cesium.com/u/janine)\
**Post date:** [June 25, 2024, 7:38pm UTC](https://community.cesium.com/t/in-v2-6-0-exclude-selected-tiles-in-cesiumpolygonrasteroverlay-does-not-work/33124/6 "2024-06-25T19:38:32Z")

</div>

Hi @YRU2,

Thank you for including the GIFs in your response. We looked into this and determined that there were some regressions in our plugin. We’re looking into fixes as we speak. You can track these Github issues for updates:

> <https://github.com/CesiumGS/cesium-native/issues/914>
>
> A 3D point-in-triangle test was added in #826, and at the same time a test for "…degenerate triangles" was added to the 2D point-in-triangle test:
> 
> \`\`\`cpp
> // Return false for degenerate triangles.
> if (glm::length2(ab) \< CesiumUtility::Math::Epsilon8 ||
> glm::length2(bc) \< CesiumUtility::Math::Epsilon8 ||
> glm::length2(ca) \< CesiumUtility::Math::Epsilon8) {
> return false;
> }
> \`\`\`
> 
> Unfortunately this breaks \`rectangleIsWithinPolygons\` and \`rectangleIsOutsidePolygons\` in \`CartographicPolygon\`, which in turn breaks the ability to filter out tiles that are entirely inside or entirely outside a clipping polygon.
> 
> These functions operate in longitude/latitude space with units of radians. They form two triangles from the bounding rectangles of the polygon and the tile, and test various points against these triangles. But in longitude/latitude radians, these triangles are very small. The length squared of their edges is significantly less than 1e-8, and so this test flags them as degenerate even though they most definitely are not.
> 
> By the way, this test won't even detect all the possible degenerate triangles. If I have three vertices arranged on a line but far apart from each other, that's a degenerate triangle but the test in this function won't detect it.
> 
> I once told someone that epsilons are the root of all evil. That's a little extreme, but only a little. 😁 One thing we can say that is definitely less extreme, though, is that a function like this, which is inherently unitless, \_must not\_ have an absolute epsilon. If we knew we were working with meters, then we could maybe say "we don't care about triangles smaller than a nanometer, so we can ignore those." But if we don't know the units, we can't make any assertions like that.
> 
> A relative epsilon could be ok. Testing the vertices for equality with a relative epsilon of 1e-14 or so would be unlikely to cause a false positive.
> 
> But in my opinion, a function like this just shouldn't have a degenerate triangle test at all. Without one, the worst-case scenario is that you intermittently might detect an intersection with a triangle that is degenerate, or close to it. But you'd detect that intersection pretty much where the line or point pretending to be a triangle is actually located, so no one is likely to be surprised by that. Floating point fun could mean that a point that is not quite on the line mathematically gets flagged as being inside the "triangle", but that's no different or worse than when the same floating point fun deems a point very slightly outside a valid triangle to be inside it. On the other hand, if you add a degenerate triangle test, and it's a little too eager, you end up completely missing intersections that \_actually exist\_. That's a drastically worse situation, in my view.

> <https://github.com/CesiumGS/cesium-unreal/issues/1461>
>
> https://community.cesium.com/t/shadows-from-geometry-hidden-by-cesiumcartographi…cpolygon-effecting-our-own-meshes/33039
> 
> Also noted here:
> https://community.cesium.com/t/geographic-polygon-collision-clipping-works-in-5-1-but-not-in-5-4/32661/7?u=kevin\_ring
> 
> And here:
> https://community.cesium.com/t/cartographicpolygon-clipping-not-precise/33227

We’ll be sure to update this thread when we find the appropriate fixes. 🤞 Thank you!

---

<div class="post-metadata">

**Author:** ![L\_N](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/l_n/32/16048_2.png) [@L\_N](https://community.cesium.com/u/L_N)\
**Post date:** [July 3, 2024, 11:30am UTC](https://community.cesium.com/t/in-v2-6-0-exclude-selected-tiles-in-cesiumpolygonrasteroverlay-does-not-work/33124/7 "2024-07-03T11:30:00Z")

</div>

@janine

I also have problems with clipping certain areas using “PolygonRasterOverlay” in cesium versions 2.6.0, which persist even after the update to V2.7.0.

I want to cut out certain areas from my terrain (terrain layer is overlaid with orthophots and material (tint) so that I can look into the ground. The cutout is also displayed in the Unreal Editor, but the cutout area does not appear in the packed project.

This is how it should actually look in the game, but there the area is still overlaid with the material.

![grafik](https://global.discourse-cdn.com/cesium/original/3X/6/d/6db1f4a355b633e0e2090d89042d2ccbb49643a2.jpeg)
