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


C++ PxScene::getActiveTransforms方法代码示例

本文整理汇总了C++中PxScene::getActiveTransforms方法的典型用法代码示例。如果您正苦于以下问题:C++ PxScene::getActiveTransforms方法的具体用法?C++ PxScene::getActiveTransforms怎么用?C++ PxScene::getActiveTransforms使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PxScene的用法示例。


在下文中一共展示了PxScene::getActiveTransforms方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: UpdateActiveTransforms

void FPhysScene::UpdateActiveTransforms(uint32 SceneType)
{
	if (SceneType == PST_Cloth)	//cloth doesn't bother with updating components to bodies so we don't need to store any transforms
	{
		return;
	}
	PxScene* PScene = GetPhysXScene(SceneType);
	check(PScene);
	SCOPED_SCENE_READ_LOCK(PScene);

	PxU32 NumTransforms = 0;
	const PxActiveTransform* PActiveTransforms = PScene->getActiveTransforms(NumTransforms);
	ActiveBodyInstances[SceneType].Empty(NumTransforms);
	ActiveDestructibleActors[SceneType].Empty(NumTransforms);

	for (PxU32 TransformIdx = 0; TransformIdx < NumTransforms; ++TransformIdx)
	{
		const PxActiveTransform& PActiveTransform = PActiveTransforms[TransformIdx];
		PxRigidActor* RigidActor = PActiveTransform.actor->isRigidActor();
		ensure(!RigidActor->userData || !FPhysxUserData::IsGarbage(RigidActor->userData));

		if (FBodyInstance* BodyInstance = FPhysxUserData::Get<FBodyInstance>(RigidActor->userData))
		{
			if (BodyInstance->InstanceBodyIndex == INDEX_NONE && BodyInstance->OwnerComponent.IsValid() && BodyInstance->IsInstanceSimulatingPhysics())
			{
				ActiveBodyInstances[SceneType].Add(BodyInstance);
			}
		}
		else if (const FDestructibleChunkInfo* DestructibleChunkInfo = FPhysxUserData::Get<FDestructibleChunkInfo>(RigidActor->userData))
		{
			ActiveDestructibleActors[SceneType].Add(RigidActor);
		}
		
	}
}
开发者ID:didixp,项目名称:Ark-Dev-Kit,代码行数:35,代码来源:PhysScene.cpp

示例2: SyncComponentsToBodies

void FPhysScene::SyncComponentsToBodies(uint32 SceneType)
{
#if WITH_PHYSX
	PxScene* PScene = GetPhysXScene(SceneType);
	check(PScene);
	SCENE_LOCK_READ(PScene);

	PxU32 NumTransforms = 0;
	const PxActiveTransform* PActiveTransforms = PScene->getActiveTransforms(NumTransforms);

	SCENE_UNLOCK_READ(PScene);


	for(PxU32 TransformIdx=0; TransformIdx<NumTransforms; TransformIdx++)
	{
		const PxActiveTransform& PActiveTransform = PActiveTransforms[TransformIdx];
		FBodyInstance* BodyInst = FPhysxUserData::Get<FBodyInstance>(PActiveTransform.userData);
		if(	BodyInst != NULL && 
			BodyInst->InstanceBodyIndex == INDEX_NONE && 
			BodyInst->OwnerComponent != NULL &&
			BodyInst->IsInstanceSimulatingPhysics() )
		{
			check(BodyInst->OwnerComponent->IsRegistered()); // shouldn't have a physics body for a non-registered component!

			AActor* Owner = BodyInst->OwnerComponent->GetOwner();

			// See if the transform is actually different, and if so, move the component to match physics
			const FTransform NewTransform = BodyInst->GetUnrealWorldTransform();	
			if(!NewTransform.EqualsNoScale(BodyInst->OwnerComponent->ComponentToWorld))
			{
				const FVector MoveBy = NewTransform.GetLocation() - BodyInst->OwnerComponent->ComponentToWorld.GetLocation();
				const FRotator NewRotation = NewTransform.Rotator();

				//UE_LOG(LogTemp, Log, TEXT("MOVING: %s"), *BodyInst->OwnerComponent->GetPathName());

				//@warning: do not reference BodyInstance again after calling MoveComponent() - events from the move could have made it unusable (destroying the actor, SetPhysics(), etc)
				BodyInst->OwnerComponent->MoveComponent(MoveBy, NewRotation, false, NULL, MOVECOMP_SkipPhysicsMove);
			}

			// Check if we didn't fall out of the world
			if(Owner != NULL && !Owner->IsPendingKill())
			{
				Owner->CheckStillInWorld();
			}
		}
	}
#endif
}
开发者ID:Tigrouzen,项目名称:UnrealEngine-4,代码行数:48,代码来源:PhysScene.cpp


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