G1R AngelScript
Scripting reference for the Gothic 1 Remake
Loading...
Searching...
No Matches
FIndoorDetectionSampler Struct Reference

Detects whether a location is "indoor" or "outdoor" by performing AmbientOcclusion-style sampling by shooting Traces in random directions of a hemisphere. More...

Public Member Functions

Functions
FIndoorDetectionSampler & opAssign (FIndoorDetectionSampler Other)

Public Attributes

IndoorDetectionSampler
float32 ScoreWeight_Indoor_EnclosedByWalls
 If sideways traces hit, apply this score on the result. Higher values mean "more likely indoors".
int NumSamples
 How many samples (traces) to do.
ECollisionChannel CollisionChannel
 Collision channel to use for the traces.
float32 TraceRadius
 How far the traces should go.
float32 ConeFullAngleDegrees
 180° will be a perfect hemisphere. Lower angles result in a more upwards facing cone.
FVector DirectionAxisScale
 Allows to restrict the ray direction onto a specific axis for testing.
float32 SweepTraceSphereRadius
 Radius of the sweep traces cast into the sky. Switches to LineTraces if 0.
float32 ScoreWeight_Indoor_HasRoof
 If upwards traces hit, apply this score on the result. Higher values mean "more likely indoors".
float32 ScoreWeight_Outdoor_NoWalls
 If sideways traces do NOT hit, apply this score on the result. Higher values mean "more likely outdoors".
float32 ScoreWeight_Outdoor_VisibleSky
 If upwards traces do NOT hit, apply this score on the result. Higher values mean "more likely outdoors".
bool bDebugDrawTraces
float32 DebugDrawTracesLifetime
TArray< AActor > IgnoredActors
 Actors to ignore during the trace.

Detailed Description

Detects whether a location is "indoor" or "outdoor" by performing AmbientOcclusion-style sampling by shooting Traces in random directions of a hemisphere.

Each trace contributes to the final score that

  • if negative means "outside"
  • if positive means "inside"

You can weight each trace by whether it was going up towards the sky/ceiling or sideways against a wall.

For example, you may want to boost "outdoorness" whenever the sky is visible, so you could just increase the score for traces that go upwards and did not hit anything.

The sampling is done asynchronously, the results should come in 1-2 ticks later.

@note There is a component that wraps this (UIndoorDetectionComponent). For individual queries, just using the struct will probably be simpler though.

Example:

FIndoorDetectionSampler IndoorDetection;

IndoorDetection.NumSamples = 5000;
IndoorDetection.SweepTraceSphereRadius = 10.0f;

IndoorDetection.ScoreWeight_Indoor_EnclosedByWalls = 1.0f
IndoorDetection.ScoreWeight_Indoor_HasRoof = 2.0f
IndoorDetection.ScoreWeight_Outdoor_NoWalls = 32.0f
IndoorDetection.ScoreWeight_Outdoor_VisibleSky = 32.0f

IndoorDetection.QueryParams.AddIgnoredActor(SomeActor);
IndoorDetection.QueryParams.AddIgnoredActor(SomeOtherActor);

IndoorDetection.RequestAsyncSampling(
    this,
    SomeLocation,
    FIndoorDetectionResultDelegate::CreateUObject(this, &ThisClass::HandleIndoorDetectionResultsAvailable)
);

Member Function Documentation

◆ opAssign()

Member Data Documentation

◆ bDebugDrawTraces

bool bDebugDrawTraces

◆ CollisionChannel

ECollisionChannel CollisionChannel

Collision channel to use for the traces.

◆ ConeFullAngleDegrees

float32 ConeFullAngleDegrees

180° will be a perfect hemisphere. Lower angles result in a more upwards facing cone.

◆ DebugDrawTracesLifetime

float32 DebugDrawTracesLifetime

◆ DirectionAxisScale

FVector DirectionAxisScale

Allows to restrict the ray direction onto a specific axis for testing.

◆ IgnoredActors

TArray<AActor> IgnoredActors

Actors to ignore during the trace.

◆ NumSamples

int NumSamples

How many samples (traces) to do.

◆ ScoreWeight_Indoor_EnclosedByWalls

float32 ScoreWeight_Indoor_EnclosedByWalls

If sideways traces hit, apply this score on the result. Higher values mean "more likely indoors".

◆ ScoreWeight_Indoor_HasRoof

float32 ScoreWeight_Indoor_HasRoof

If upwards traces hit, apply this score on the result. Higher values mean "more likely indoors".

◆ ScoreWeight_Outdoor_NoWalls

float32 ScoreWeight_Outdoor_NoWalls

If sideways traces do NOT hit, apply this score on the result. Higher values mean "more likely outdoors".

◆ ScoreWeight_Outdoor_VisibleSky

float32 ScoreWeight_Outdoor_VisibleSky

If upwards traces do NOT hit, apply this score on the result. Higher values mean "more likely outdoors".

◆ SweepTraceSphereRadius

float32 SweepTraceSphereRadius

Radius of the sweep traces cast into the sky. Switches to LineTraces if 0.

◆ TraceRadius

float32 TraceRadius

How far the traces should go.