# UWorldPartition::GetIntersectingCells for UWorldPartitionRuntimeHashSet::ForEachStreamingCellsQuery incorrectly handles bDataLayersOnly 

**URL:** <https://forums.unrealengine.com/t/uworldpartition-getintersectingcells-for-uworldpartitionruntimehashset-foreachstreamingcellsquery-incorrectly-handles-bdatalayersonly/2722500>\
**Category:** World Creation\
**Tags:** Epic-Pro-Support, unreal-engine, question\
**Created:** [April 9, 2026, 11:14pm UTC](https://forums.unrealengine.com/t/uworldpartition-getintersectingcells-for-uworldpartitionruntimehashset-foreachstreamingcellsquery-incorrectly-handles-bdatalayersonly/2722500 "2026-04-09T23:14:31Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous-edc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous-edc](https://forums.unrealengine.com/u/anonymous-edc)\
**Post date:** [April 9, 2026, 11:14pm UTC](https://forums.unrealengine.com/t/uworldpartition-getintersectingcells-for-uworldpartitionruntimehashset-foreachstreamingcellsquery-incorrectly-handles-bdatalayersonly/2722500/1 "2026-04-09T23:14:31Z")

</div>

If you try to query against cells with DataLayers, even if you set bDataLayersOnly=false it will fail because of the else if branch that should just be an if.

Inside UWorldPartitionRuntimeHashSet::ForEachStreamingCells the ShouldAddCell lambda:

```auto
	auto ShouldAddCell = [this](const UWorldPartitionRuntimeCell* Cell, const FWorldPartitionStreamingQuerySource& QuerySource)
	{
		if (IsCellRelevantFor(Cell->GetClientOnlyVisible()))
		{
			if (Cell->HasDataLayers())
			{
				if (Cell->GetDataLayers().FindByPredicate([&](const FName& DataLayerName) { return QuerySource.DataLayers.Contains(DataLayerName); }))
				{
					return true;
				}
			}
			else if (!QuerySource.bDataLayersOnly) // Issue here
			{
				return true;
			}
		}

		return false;
	}

```

[Attachment Removed]

---

<div class="post-metadata">

**Author:** ![anonymous-edc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous-edc](https://forums.unrealengine.com/u/anonymous-edc)\
**Post date:** [April 9, 2026, 11:14pm UTC](https://forums.unrealengine.com/t/uworldpartition-getintersectingcells-for-uworldpartitionruntimehashset-foreachstreamingcellsquery-incorrectly-handles-bdatalayersonly/2722500/2 "2026-04-09T23:14:34Z")

</div>

**Steps to Reproduce**  
NA

[Attachment Removed]

---

<div class="post-metadata">

**Author:** ![Svegn2](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/svegn2/32/1225280_2.png) [@Svegn2](https://forums.unrealengine.com/u/Svegn2)\
**Post date:** [April 10, 2026, 2:33pm UTC](https://forums.unrealengine.com/t/uworldpartition-getintersectingcells-for-uworldpartitionruntimehashset-foreachstreamingcellsquery-incorrectly-handles-bdatalayersonly/2722500/3 "2026-04-10T14:33:08Z")

</div>

Hello!

I would like to clarify the intent. What understand is that you would like to include all cells that have datalayers without having to specify a list in the QuerySource. This would require adding a new setting in FWorldPartitionStreamingQuerySource .

```auto
	auto ShouldAddCell = [this](const UWorldPartitionRuntimeCell* Cell, const FWorldPartitionStreamingQuerySource& QuerySource)
	{
		if (IsCellRelevantFor(Cell->GetClientOnlyVisible()))
		{
			if (Cell->HasDataLayers())
			{
				//Include any cell that has Datalayers
				if (QuerySource.bIncludeAnyDataLayer)
				{
					return true;
				}
 
				if (Cell->GetDataLayers().FindByPredicate([&](const FName& DataLayerName) { return QuerySource.DataLayers.Contains(DataLayerName); }))
				{
					return true;
				}
			}
			else if (!QuerySource.bDataLayersOnly) // Issue here
			{
				return true;
			}
		}
 
		return false;
	}

```

Is this the behavior you are looking for?

Martin

[Attachment Removed]

---

<div class="post-metadata">

**Author:** ![anonymous-edc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous-edc](https://forums.unrealengine.com/u/anonymous-edc)\
**Post date:** [April 10, 2026, 4:53pm UTC](https://forums.unrealengine.com/t/uworldpartition-getintersectingcells-for-uworldpartitionruntimehashset-foreachstreamingcellsquery-incorrectly-handles-bdatalayersonly/2722500/4 "2026-04-10T16:53:34Z")

</div>

A new setting would work as well, but the comments on the code for the data layer properties read to be that if bDataLayersOnly=false than the DataLayers would be ignored. Happy with either solution, both will work for us 🙂

```auto
	/* Optional list of data layers to specialize the query. If empty only non data layer cells will be returned by the query. */
	UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Query")
	TArray<FName> DataLayers;
 
	/* If True, Only cells that are in a data layer found in DataLayers property will be returned by the query. */
	UPROPERTY(BlueprintReadWrite, EditAnywhere, Category = "Query")
	bool bDataLayersOnly;

```

[Attachment Removed]

---

<div class="post-metadata">

**Author:** ![Svegn2](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/svegn2/32/1225280_2.png) [@Svegn2](https://forums.unrealengine.com/u/Svegn2)\
**Post date:** [April 10, 2026, 5:48pm UTC](https://forums.unrealengine.com/t/uworldpartition-getintersectingcells-for-uworldpartitionruntimehashset-foreachstreamingcellsquery-incorrectly-handles-bdatalayersonly/2722500/5 "2026-04-10T17:48:58Z")

</div>

Thanks for confirming. I need to validate with the owner of this code. The comment on DataLayers is what is making me hesitate. It does say that an empty array means that non data layers cells are targeted. I wouldn’t want to introduce bugs for licensees that count on that behavior.

[Attachment Removed]

---

<div class="post-metadata">

**Author:** ![Svegn2](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/svegn2/32/1225280_2.png) [@Svegn2](https://forums.unrealengine.com/u/Svegn2)\
**Post date:** [April 16, 2026, 1:59pm UTC](https://forums.unrealengine.com/t/uworldpartition-getintersectingcells-for-uworldpartitionruntimehashset-foreachstreamingcellsquery-incorrectly-handles-bdatalayersonly/2722500/6 "2026-04-16T13:59:14Z")

</div>

Hello!

After discussing with the engine team, it was agreed that adding a new option is safer. You can grab CL52760639.

The behavior is:

- bIncludeAnyDataLayer=true + bDataLayersOnly=true --\> returns only cells with data layers (any DL), excludes non-DL cells
- bIncludeAnyDataLayer=true + bDataLayersOnly=false --\> effectively returns ALL cells (DL cells pass via short-circuit, non-DL cells pass via the else branch)
- bIncludeAnyDataLayer=true + DataLayers populated --\> the DataLayers array is silently ignored

Regards,

Martin

[Attachment Removed]

---

<div class="post-metadata">

**Author:** ![anonymous-edc](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous-edc](https://forums.unrealengine.com/u/anonymous-edc)\
**Post date:** [April 16, 2026, 4:45pm UTC](https://forums.unrealengine.com/t/uworldpartition-getintersectingcells-for-uworldpartitionruntimehashset-foreachstreamingcellsquery-incorrectly-handles-bdatalayersonly/2722500/7 "2026-04-16T16:45:13Z")

</div>

Thank you for the help!

[Attachment Removed]
