当前位置: 首页>>代码示例>>C++>>正文


C++ FActiveSound::GetWorldID方法代码示例

本文整理汇总了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;
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:58,代码来源:SoundNodeRandom.cpp

示例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);
	}
}
开发者ID:zhaoyizheng0930,项目名称:UnrealEngine,代码行数:42,代码来源:SoundNodeRandom.cpp


注:本文中的FActiveSound::GetWorldID方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。