Example #1
0
void FConstraintInstance::SetAngularSwing2Limit(EAngularConstraintMotion Swing2Motion, float InSwing2LimitAngle)
{
	AngularSwing2Motion = Swing2Motion;
	Swing2LimitAngle = InSwing2LimitAngle;

	UpdateAngularLimit();
}
Example #2
0
void FConstraintInstance::SetAngularTwistLimit(EAngularConstraintMotion TwistMotion, float InTwistLimitAngle)
{
	AngularTwistMotion = TwistMotion;
	TwistLimitAngle = InTwistLimitAngle;

	UpdateAngularLimit();
}
/** 
 *	Create physics engine constraint.
 */
void FConstraintInstance::InitConstraint(USceneComponent* Owner, FBodyInstance* Body1, FBodyInstance* Body2, float Scale)
{
	OwnerComponent = Owner;

#if WITH_PHYSX
	PhysxUserData = FPhysxUserData(this);

	// if there's already a constraint, get rid of it first
	if (ConstraintData)
	{
		TermConstraint();
	}

	PxRigidActor* PActor1 = nullptr;
	PxRigidActor* PActor2 = nullptr;
	PxScene* PScene = GetPScene_LockFree(Body1, Body2);
	SCOPED_SCENE_WRITE_LOCK(PScene);

	const bool bValidConstraintSetup = PScene && GetPActors_AssumesLocked(Body1, Body2, &PActor1, &PActor2) && CreatePxJoint_AssumesLocked(PActor1, PActor2, PScene, Scale);
	if (!bValidConstraintSetup)
	{
		return;
	}


	// update mass
	UpdateAverageMass_AssumesLocked(PActor1, PActor2);
	
	//flags and projection settings
	UpdateConstraintFlags_AssumesLocked();
	
	//limits
	UpdateAngularLimit();
	UpdateLinearLimit();

	//breakable
	UpdateBreakable();
	
	//motors
	SetLinearDriveParams(LinearDriveSpring, LinearDriveDamping, LinearDriveForceLimit);
	SetAngularDriveParams(AngularDriveSpring, AngularDriveDamping, AngularDriveForceLimit);
	UpdateDriveTarget();
	
	EnsureSleepingActorsStaySleeping_AssumesLocked(PActor1, PActor2);
#endif // WITH_PHYSX

}