Navigation
API > API/Runtime > API/Runtime/GeometryCore
Class for efficiently drawing weighted samples (when you need to draw more than a very small amount of them) note this is a more flexible version of the algorithm in Engine/WeightedRandomSampler.h, with support for cases where some IDs cannot be sampled (e.g. when sampling triangles of non-compact meshes)
| Name | TWeightedSamplingAliasTable |
| Type | class |
| Header File | /Engine/Source/Runtime/GeometryCore/Public/Sampling/MeshSurfacePointSampling.h |
| Include Path | #include "Sampling/MeshSurfacePointSampling.h" |
Syntax
template<typename RealType>
class TWeightedSamplingAliasTable
Constructors
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
| Sampling/MeshSurfacePointSampling.h | |||
TWeightedSamplingAliasTable
(
TConstArrayView< RealType > Weights |
Sampling/MeshSurfacePointSampling.h | ||
TWeightedSamplingAliasTable
(
TConstArrayView< RealType > Weights, |
Sampling/MeshSurfacePointSampling.h |
Variables
Protected
| Name | Type | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|---|
| Alias | TArray< int32 > | Table indicating the alternative index you should choose, if you don't keep the initial index. | Sampling/MeshSurfacePointSampling.h | |
| Probability | TArray< RealType > | Table of probability that you should keep a given index chosen by unweighted random sampling (can be MaxReal if should always pick the index) | Sampling/MeshSurfacePointSampling.h |
Functions
Public
| Name | Remarks | Include Path | Unreal Specifiers |
|---|---|---|---|
bool Init
(
TConstArrayView< RealType > Weights, |
Initialize sampling table | Sampling/MeshSurfacePointSampling.h | |
bool IsValid() |
Sampling/MeshSurfacePointSampling.h | ||
int32 Num() |
Sampling/MeshSurfacePointSampling.h | ||
int32 Sample
(
RealType UniformRandom1, |
UniformRandom1, UniformRandom2 must be in the [0,1) range. | Sampling/MeshSurfacePointSampling.h |