本文整理汇总了C++中FActiveSound::GetWorldID方法的典型用法代码示例。如果您正苦于以下问题:C++ FActiveSound::GetWorldID方法的具体用法?C++ FActiveSound::GetWorldID怎么用?C++ FActiveSound::GetWorldID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FActiveSound
的用法示例。
在下文中一共展示了FActiveSound::GetWorldID方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ChooseNodeIndex
int32 USoundNodeRandom::ChooseNodeIndex(FActiveSound& ActiveSound)
{
int32 NodeIndex = 0;
float WeightSum = 0.0f;
#if WITH_EDITOR
bool bIsPIESound = (GEditor != nullptr) && ((GEditor->bIsSimulatingInEditor || GEditor->PlayWorld != nullptr) && ActiveSound.GetWorldID() > 0);
if (bIsPIESound)
{
// Find the first available index - needed if there is only one
while (PIEHiddenNodes.Contains(NodeIndex))
{
NodeIndex++;
}
}
#endif //WITH_EDITOR
// only calculate the weights that have not been used and use that set for the random choice
for (int32 i = 0; i < Weights.Num(); ++i)
{
#if WITH_EDITOR
if (!bIsPIESound || !PIEHiddenNodes.Contains(i))
#endif //WITH_EDITOR
{
if (!bRandomizeWithoutReplacement || !HasBeenUsed[i])
{
WeightSum += Weights[i];
}
}
}
float Choice = FMath::FRand() * WeightSum;
WeightSum = 0.0f;
for (int32 i = 0; i < ChildNodes.Num() && i < Weights.Num(); ++i)
{
#if WITH_EDITOR
if (!bIsPIESound || !PIEHiddenNodes.Contains(i))
#endif //WITH_EDITOR
{
if (bRandomizeWithoutReplacement && HasBeenUsed[i])
{
continue;
}
WeightSum += Weights[i];
if (Choice < WeightSum)
{
NodeIndex = i;
HasBeenUsed[i] = true;
NumRandomUsed++;
break;
}
}
}
return NodeIndex;
}
示例2: ParseNodes
void USoundNodeRandom::ParseNodes( FAudioDevice* AudioDevice, const UPTRINT NodeWaveInstanceHash, FActiveSound& ActiveSound, const FSoundParseParameters& ParseParams, TArray<FWaveInstance*>& WaveInstances )
{
RETRIEVE_SOUNDNODE_PAYLOAD(sizeof(int32));
DECLARE_SOUNDNODE_ELEMENT(int32, NodeIndex);
// Pick a random child node and save the index.
if (*RequiresInitialization)
{
NodeIndex = ChooseNodeIndex(ActiveSound);
*RequiresInitialization = 0;
}
#if WITH_EDITOR
bool bIsPIESound = (GEditor != nullptr) && ((GEditor->bIsSimulatingInEditor || GEditor->PlayWorld != nullptr) && ActiveSound.GetWorldID() > 0);
#endif //WITH_EDITOR
// check to see if we have used up our random sounds
if (bRandomizeWithoutReplacement && (HasBeenUsed.Num() > 0) && (NumRandomUsed >= HasBeenUsed.Num()
#if WITH_EDITOR
|| (bIsPIESound && NumRandomUsed >= (HasBeenUsed.Num() - PIEHiddenNodes.Num()))
#endif //WITH_EDITOR
))
{
// reset all of the children nodes
for (int32 i = 0; i < HasBeenUsed.Num(); ++i)
{
if (HasBeenUsed.Num() > NodeIndex)
{
HasBeenUsed[i] = false;
}
}
// set the node that has JUST played to be true so we don't repeat it
HasBeenUsed[NodeIndex] = true;
NumRandomUsed = 1;
}
if (NodeIndex < ChildNodes.Num() && ChildNodes[NodeIndex])
{
ChildNodes[NodeIndex]->ParseNodes(AudioDevice, GetNodeWaveInstanceHash(NodeWaveInstanceHash, ChildNodes[NodeIndex], NodeIndex), ActiveSound, ParseParams, WaveInstances);
}
}