void UEnvQueryGenerator_SimpleGrid::GenerateItems(FEnvQueryInstance& QueryInstance) const { UObject* BindOwner = QueryInstance.Owner.Get(); GridSize.BindData(BindOwner, QueryInstance.QueryID); SpaceBetween.BindData(BindOwner, QueryInstance.QueryID); float RadiusValue = GridSize.GetValue(); float DensityValue = SpaceBetween.GetValue(); const int32 ItemCount = FPlatformMath::TruncToInt((RadiusValue * 2.0f / DensityValue) + 1); const int32 ItemCountHalf = ItemCount / 2; TArray<FVector> ContextLocations; QueryInstance.PrepareContext(GenerateAround, ContextLocations); TArray<FNavLocation> GridPoints; GridPoints.Reserve(ItemCount * ItemCount * ContextLocations.Num()); for (int32 ContextIndex = 0; ContextIndex < ContextLocations.Num(); ContextIndex++) { for (int32 IndexX = 0; IndexX <= ItemCount; ++IndexX) { for (int32 IndexY = 0; IndexY <= ItemCount; ++IndexY) { const FNavLocation TestPoint = FNavLocation(ContextLocations[ContextIndex] - FVector(DensityValue * (IndexX - ItemCountHalf), DensityValue * (IndexY - ItemCountHalf), 0)); GridPoints.Add(TestPoint); } } } ProjectAndFilterNavPoints(GridPoints, QueryInstance); StoreNavPoints(GridPoints, QueryInstance); }
void UEnvQueryGenerator_OnCircle::AddItemDataForCircle(uint8* ContextRawData, UEnvQueryItemType* ContextItemType, const TArray<FNavLocation>& Locations, FEnvQueryInstance& OutQueryInstance) const { StoreNavPoints(Locations, OutQueryInstance); }
void UEnvQueryGenerator_Donut::GenerateItems(FEnvQueryInstance& QueryInstance) const { TArray<FVector> CenterPoints; QueryInstance.PrepareContext(Center, CenterPoints); if (CenterPoints.Num() <= 0) { return; } UObject* BindOwner = QueryInstance.Owner.Get(); InnerRadius.BindData(BindOwner, QueryInstance.QueryID); OuterRadius.BindData(BindOwner, QueryInstance.QueryID); NumberOfRings.BindData(BindOwner, QueryInstance.QueryID); PointsPerRing.BindData(BindOwner, QueryInstance.QueryID); ArcAngle.BindData(BindOwner, QueryInstance.QueryID); float ArcAngleValue = ArcAngle.GetValue(); float InnerRadiusValue = InnerRadius.GetValue(); float OuterRadiusValue = OuterRadius.GetValue(); int32 NumRings = NumberOfRings.GetValue(); int32 NumPoints = PointsPerRing.GetValue(); if ((InnerRadiusValue <= 0.f) || (OuterRadiusValue <= 0.f) || (InnerRadiusValue > OuterRadiusValue) || (NumRings < 1) || (NumPoints < 1)) { return; } const float ArcBisectDeg = GetArcBisectorAngle(QueryInstance); const float ArcAngleDeg = FMath::Clamp(ArcAngleValue, 0.0f, 360.0f); const float RadiusDelta = (OuterRadiusValue - InnerRadiusValue) / (NumRings - 1); const float AngleDelta = 2.0 * PI / NumPoints; float SectionAngle = FMath::DegreesToRadians(ArcBisectDeg); TArray<FNavLocation> Points; Points.Reserve(NumPoints * NumRings); for (int32 SectionIdx = 0; SectionIdx < NumPoints; SectionIdx++, SectionAngle += AngleDelta) { if (IsAngleAllowed(SectionAngle, ArcBisectDeg, ArcAngleDeg, bDefineArc)) { const float SinValue = FMath::Sin(SectionAngle); const float CosValue = FMath::Cos(SectionAngle); float RingRadius = InnerRadiusValue; for (int32 RingIdx = 0; RingIdx < NumRings; RingIdx++, RingRadius += RadiusDelta) { const FVector RingPos(RingRadius * CosValue, RingRadius * SinValue, 0.0f); for (int32 ContextIdx = 0; ContextIdx < CenterPoints.Num(); ContextIdx++) { const FNavLocation PointPos = FNavLocation(CenterPoints[ContextIdx] + RingPos); Points.Add(PointPos); } } } } ProjectAndFilterNavPoints(Points, QueryInstance); StoreNavPoints(Points, QueryInstance); }