コード例 #1
0
ファイル: BodySetup.cpp プロジェクト: didixp/Ark-Dev-Kit
	FAddShapesHelper(UBodySetup* InBodySetup, FBodyInstance* InOwningInstance, physx::PxRigidActor* InPDestActor, EPhysicsSceneType InSceneType, FVector& InScale3D, physx::PxMaterial* InSimpleMaterial, TArray<UPhysicalMaterial*>& InComplexMaterials, FShapeData& InShapeData, const FTransform& InRelativeTM, TArray<physx::PxShape*>* InNewShapes, const bool InShapeSharing)
	: BodySetup(InBodySetup)
	, OwningInstance(InOwningInstance)
	, PDestActor(InPDestActor)
	, SceneType(InSceneType)
	, Scale3D(InScale3D)
	, SimpleMaterial(InSimpleMaterial)
	, ComplexMaterials(InComplexMaterials)
	, ShapeData(InShapeData)
	, RelativeTM(InRelativeTM)
	, NewShapes(InNewShapes)
	, bShapeSharing(InShapeSharing)
	{
		SetupNonUniformHelper(Scale3D, MinScale, MinScaleAbs, Scale3DAbs);
		{
			float MinScaleRelative;
			float MinScaleAbsRelative;
			FVector Scale3DAbsRelative;
			FVector Scale3DRelative = RelativeTM.GetScale3D();

			SetupNonUniformHelper(Scale3DRelative, MinScaleRelative, MinScaleAbsRelative, Scale3DAbsRelative);

			MinScaleAbs *= MinScaleAbsRelative;
			Scale3DAbs.X *= Scale3DAbsRelative.X;
			Scale3DAbs.Y *= Scale3DAbsRelative.Y;
			Scale3DAbs.Z *= Scale3DAbsRelative.Z;
		}
	}
コード例 #2
0
ファイル: BodySetup.cpp プロジェクト: Foreven/Unreal4-1
void UBodySetup::AddShapesToRigidActor(PxRigidActor* PDestActor, FVector& Scale3D, const FTransform& RelativeTM /* = FTransform::Identity */, TArray<physx::PxShape*>* NewShapes /* = NULL */ )
{
#if WITH_RUNTIME_PHYSICS_COOKING || WITH_EDITOR
	// in editor, there are a lot of things relying on body setup to create physics meshes
	CreatePhysicsMeshes();
#endif

	float MinScale;
	float MinScaleAbs;
	FVector Scale3DAbs;
	SetupNonUniformHelper(Scale3D, MinScale, MinScaleAbs, Scale3DAbs);

	{
		float MinScaleRelative;
		float MinScaleAbsRelative;
		FVector Scale3DAbsRelative;
		FVector Scale3DRelative = RelativeTM.GetScale3D();

		SetupNonUniformHelper(Scale3DRelative, MinScaleRelative, MinScaleAbsRelative, Scale3DAbsRelative);

		MinScaleAbs *= MinScaleAbsRelative;
		Scale3DAbs.X *= Scale3DAbsRelative.X;
		Scale3DAbs.Y *= Scale3DAbsRelative.Y;
		Scale3DAbs.Z *= Scale3DAbsRelative.Z;
	}

	// Create shapes for simple collision if we do not want to use the complex collision mesh 
	// for simple queries as well
	if (CollisionTraceFlag != ECollisionTraceFlag::CTF_UseComplexAsSimple)
	{
		AddSpheresToRigidActor(PDestActor, RelativeTM, MinScale, MinScaleAbs, NewShapes);
		AddBoxesToRigidActor(PDestActor, RelativeTM, Scale3D, Scale3DAbs, NewShapes);
		AddSphylsToRigidActor(PDestActor, RelativeTM, Scale3D, Scale3DAbs, NewShapes);
		AddConvexElemsToRigidActor(PDestActor, RelativeTM, Scale3D, Scale3DAbs, NewShapes);
	}


	// Create tri-mesh shape, when we are not using simple collision shapes for 
	// complex queries as well
	if( CollisionTraceFlag != ECollisionTraceFlag::CTF_UseSimpleAsComplex )
	{
		AddTriMeshToRigidActor(PDestActor, Scale3D, Scale3DAbs);
	}
}