本文整理汇总了C++中UNavigationSystem::UpdateNavOctree方法的典型用法代码示例。如果您正苦于以下问题:C++ UNavigationSystem::UpdateNavOctree方法的具体用法?C++ UNavigationSystem::UpdateNavOctree怎么用?C++ UNavigationSystem::UpdateNavOctree使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UNavigationSystem
的用法示例。
在下文中一共展示了UNavigationSystem::UpdateNavOctree方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: RasterizeSegmentPoints
void RasterizeSegmentPoints(ULandscapeInfo* LandscapeInfo, TArray<FLandscapeSplineInterpPoint> Points, const FTransform& SplineToWorld, bool bRaiseTerrain, bool bLowerTerrain, ULandscapeLayerInfoObject* LayerInfo)
{
ALandscapeProxy* LandscapeProxy = LandscapeInfo->GetLandscapeProxy();
const FTransform SplineToLandscape = SplineToWorld.GetRelativeTransform(LandscapeProxy->LandscapeActorToWorld());
FLandscapeEditDataInterface LandscapeEdit(LandscapeInfo);
TSet<ULandscapeComponent*> ModifiedComponents;
// I'd dearly love to use FIntRect in this code, but Landscape works with "Inclusive Max" and FIntRect is "Exclusive Max"
int32 LandscapeMinX, LandscapeMinY, LandscapeMaxX, LandscapeMaxY;
if (!LandscapeInfo->GetLandscapeExtent(LandscapeMinX, LandscapeMinY, LandscapeMaxX, LandscapeMaxY))
{
return;
}
FBox SegmentBounds = FBox(0);
for (const FLandscapeSplineInterpPoint& Point : Points)
{
SegmentBounds += Point.FalloffLeft;
SegmentBounds += Point.FalloffRight;
}
SegmentBounds = SegmentBounds.TransformBy(SplineToLandscape.ToMatrixWithScale());
int32 MinX = FMath::CeilToInt(SegmentBounds.Min.X);
int32 MinY = FMath::CeilToInt(SegmentBounds.Min.Y);
int32 MaxX = FMath::FloorToInt(SegmentBounds.Max.X);
int32 MaxY = FMath::FloorToInt(SegmentBounds.Max.Y);
MinX = FMath::Max(MinX, LandscapeMinX);
MinY = FMath::Max(MinY, LandscapeMinY);
MaxX = FMath::Min(MaxX, LandscapeMaxX);
MaxY = FMath::Min(MaxY, LandscapeMaxY);
if (MinX > MaxX || MinY > MaxY)
{
// The segment's bounds don't intersect the landscape, so skip it entirely
return;
}
for (int32 j = 0; j < Points.Num(); j++)
{
Points[j].Center = SplineToLandscape.TransformPosition(Points[j].Center);
Points[j].Left = SplineToLandscape.TransformPosition(Points[j].Left);
Points[j].Right = SplineToLandscape.TransformPosition(Points[j].Right);
Points[j].FalloffLeft = SplineToLandscape.TransformPosition(Points[j].FalloffLeft);
Points[j].FalloffRight = SplineToLandscape.TransformPosition(Points[j].FalloffRight);
// local-heights to texture value heights
Points[j].Left.Z = Points[j].Left.Z * LANDSCAPE_INV_ZSCALE + LandscapeDataAccess::MidValue;
Points[j].Right.Z = Points[j].Right.Z * LANDSCAPE_INV_ZSCALE + LandscapeDataAccess::MidValue;
Points[j].FalloffLeft.Z = Points[j].FalloffLeft.Z * LANDSCAPE_INV_ZSCALE + LandscapeDataAccess::MidValue;
Points[j].FalloffRight.Z = Points[j].FalloffRight.Z * LANDSCAPE_INV_ZSCALE + LandscapeDataAccess::MidValue;
}
// Heights raster
if (bRaiseTerrain || bLowerTerrain)
{
RasterizeSegmentHeight(MinX, MinY, MaxX, MaxY, LandscapeEdit, Points, bRaiseTerrain, bLowerTerrain, ModifiedComponents);
if (MinX > MaxX || MinY > MaxY)
{
// The segment's bounds don't intersect any data, so we skip it entirely
// it wouldn't intersect any weightmap data either so we don't even bother trying
}
}
// Blend layer raster
if (LayerInfo != NULL)
{
RasterizeSegmentAlpha(MinX, MinY, MaxX, MaxY, LandscapeEdit, Points, LayerInfo, ModifiedComponents);
}
LandscapeEdit.Flush();
for (ULandscapeComponent* Component : ModifiedComponents)
{
// Recreate collision for modified components and update the navmesh
ULandscapeHeightfieldCollisionComponent* CollisionComponent = Component->CollisionComponent.Get();
if (CollisionComponent)
{
CollisionComponent->RecreateCollision();
UNavigationSystem* NavSys = UNavigationSystem::GetCurrent(Component);
if (NavSys)
{
NavSys->UpdateNavOctree(CollisionComponent);
}
}
}
}
示例2: ApplySplinesInternal
//.........这里部分代码省略.........
// Heights raster
if (ControlPoint->bRaiseTerrain || ControlPoint->bLowerTerrain)
{
const FVector Center3D = SplineToLandscape.TransformPosition(ControlPoint->Location);
RasterizeControlPointHeights(MinX, MinY, MaxX, MaxY, LandscapeEdit, Center3D, Points, ControlPoint->bRaiseTerrain, ControlPoint->bLowerTerrain, ModifiedComponents);
}
// Blend layer raster
ULandscapeLayerInfoObject* LayerInfo = GetLayerInfoByName(ControlPoint->LayerName);
if (ControlPoint->LayerName != NAME_None && LayerInfo != NULL)
{
const FVector Center3D = SplineToLandscape.TransformPosition(ControlPoint->Location);
RasterizeControlPointAlpha(MinX, MinY, MaxX, MaxY, LandscapeEdit, Center3D, Points, LayerInfo, ModifiedComponents);
}
}
for (const ULandscapeSplineSegment* Segment : Landscape->SplineComponent->Segments)
{
if (bOnlySelected && !Segment->IsSplineSelected())
{
continue;
}
FBox SegmentBounds = Segment->GetBounds();
SegmentBounds = SegmentBounds.TransformBy(SplineToLandscape.ToMatrixWithScale());
int32 MinX = FMath::CeilToInt(SegmentBounds.Min.X);
int32 MinY = FMath::CeilToInt(SegmentBounds.Min.Y);
int32 MaxX = FMath::FloorToInt(SegmentBounds.Max.X);
int32 MaxY = FMath::FloorToInt(SegmentBounds.Max.Y);
MinX = FMath::Max(MinX, LandscapeMinX);
MinY = FMath::Max(MinY, LandscapeMinY);
MaxX = FMath::Min(MaxX, LandscapeMaxX);
MaxY = FMath::Min(MaxY, LandscapeMaxY);
if (MinX > MaxX || MinY > MaxY)
{
// The segment's bounds don't intersect the landscape, so skip it entirely
continue;
}
TArray<FLandscapeSplineInterpPoint> Points = Segment->GetPoints();
for (int32 j = 0; j < Points.Num(); j++)
{
Points[j].Center = SplineToLandscape.TransformPosition(Points[j].Center);
Points[j].Left = SplineToLandscape.TransformPosition(Points[j].Left);
Points[j].Right = SplineToLandscape.TransformPosition(Points[j].Right);
Points[j].FalloffLeft = SplineToLandscape.TransformPosition(Points[j].FalloffLeft);
Points[j].FalloffRight = SplineToLandscape.TransformPosition(Points[j].FalloffRight);
// local-heights to texture value heights
Points[j].Left.Z = Points[j].Left.Z * LANDSCAPE_INV_ZSCALE + LandscapeDataAccess::MidValue;
Points[j].Right.Z = Points[j].Right.Z * LANDSCAPE_INV_ZSCALE + LandscapeDataAccess::MidValue;
Points[j].FalloffLeft.Z = Points[j].FalloffLeft.Z * LANDSCAPE_INV_ZSCALE + LandscapeDataAccess::MidValue;
Points[j].FalloffRight.Z = Points[j].FalloffRight.Z * LANDSCAPE_INV_ZSCALE + LandscapeDataAccess::MidValue;
}
// Heights raster
if (Segment->bRaiseTerrain || Segment->bLowerTerrain)
{
RasterizeSegmentHeight(MinX, MinY, MaxX, MaxY, LandscapeEdit, Points, Segment->bRaiseTerrain, Segment->bLowerTerrain, ModifiedComponents);
if (MinX > MaxX || MinY > MaxY)
{
// The segment's bounds don't intersect any data, so we skip it entirely
// it wouldn't intersect any weightmap data either so we don't even bother trying
}
}
// Blend layer raster
ULandscapeLayerInfoObject* LayerInfo = GetLayerInfoByName(Segment->LayerName);
if (Segment->LayerName != NAME_None && LayerInfo != NULL)
{
RasterizeSegmentAlpha(MinX, MinY, MaxX, MaxY, LandscapeEdit, Points, LayerInfo, ModifiedComponents);
}
}
LandscapeEdit.Flush();
for (ULandscapeComponent* Component : ModifiedComponents)
{
// Recreate collision for modified components and update the navmesh
ULandscapeHeightfieldCollisionComponent* CollisionComponent = Component->CollisionComponent.Get();
if (CollisionComponent)
{
CollisionComponent->RecreateCollision();
UNavigationSystem* NavSys = UNavigationSystem::GetCurrent(Component);
if (NavSys)
{
NavSys->UpdateNavOctree(CollisionComponent);
}
}
}
return true;
}