void PhysXMeshCollider::applyGeometry()
	{
		if (!mMesh.isLoaded())
		{
			setGeometry(PxSphereGeometry(0.01f)); // Dummy
			return;
		}

		FPhysXMesh* physxMesh = static_cast<FPhysXMesh*>(mMesh->_getInternal());

		if (mMesh->getType() == PhysicsMeshType::Convex)
		{
			PxConvexMeshGeometry geometry;
			geometry.scale = PxMeshScale(toPxVector(getScale()), PxIdentity);
			geometry.convexMesh = physxMesh->_getConvex();

			setGeometry(geometry);
		}
		else // Triangle
		{
			PxTriangleMeshGeometry geometry;
			geometry.scale = PxMeshScale(toPxVector(getScale()), PxIdentity);
			geometry.triangleMesh = physxMesh->_getTriangle();

			setGeometry(geometry);
		}
	}
Esempio n. 2
0
void PhysXRigidbody::addForceAtPoint(const Vector3& force, const Vector3& position, PointForceMode mode)
{
    const PxVec3& pxForce = toPxVector(force);
    const PxVec3& pxPos = toPxVector(position);

    const PxTransform globalPose = mInternal->getGlobalPose();
    PxVec3 centerOfMass = globalPose.transform(mInternal->getCMassLocalPose().p);

    PxForceMode::Enum pxMode = toPxForceMode(mode);

    PxVec3 torque = (pxPos - centerOfMass).cross(pxForce);
    mInternal->addForce(pxForce, pxMode);
    mInternal->addTorque(torque, pxMode);
}
	CharacterCollisionFlags PhysXCharacterController::move(const Vector3& displacement)
	{
		PxControllerFilters filters;
		filters.mFilterCallback = this;
		filters.mFilterFlags = PxQueryFlag::eANY_HIT | PxQueryFlag::eSTATIC | PxQueryFlag::eDYNAMIC | PxQueryFlag::ePREFILTER;
		filters.mCCTFilterCallback = this;

		float curTime = gTime().getTime();
		float delta = curTime - mLastMoveCall;
		mLastMoveCall = curTime;

		PxControllerCollisionFlags collisionFlag = mController->move(toPxVector(displacement), mMinMoveDistance, delta, filters);

		CharacterCollisionFlags output;
		if (collisionFlag.isSet(PxControllerCollisionFlag::eCOLLISION_DOWN))
			output.set(CharacterCollisionFlag::Down);

		if (collisionFlag.isSet(PxControllerCollisionFlag::eCOLLISION_UP))
			output.set(CharacterCollisionFlag::Up);

		if (collisionFlag.isSet(PxControllerCollisionFlag::eCOLLISION_SIDES))
			output.set(CharacterCollisionFlag::Sides);

		return output;
	}
Esempio n. 4
0
void PhysXRigidbody::setInertiaTensor(const Vector3& tensor)
{
    if (((UINT32)mFlags & (UINT32)Flag::AutoTensors) != 0)
    {
        LOGWRN("Attempting to set Rigidbody inertia tensor, but it has automatic tensor calculation turned on.");
        return;
    }

    mInternal->setMassSpaceInertiaTensor(toPxVector(tensor));
}
Esempio n. 5
0
Vector3 PhysXRigidbody::getVelocityAtPoint(const Vector3& point) const
{
    const PxVec3& pxPoint = toPxVector(point);

    const PxTransform globalPose = mInternal->getGlobalPose();
    const PxVec3 centerOfMass = globalPose.transform(mInternal->getCMassLocalPose().p);
    const PxVec3 rpoint = pxPoint - centerOfMass;

    PxVec3 velocity = mInternal->getLinearVelocity();
    velocity += mInternal->getAngularVelocity().cross(rpoint);

    return fromPxVector(velocity);
}
	PxCapsuleControllerDesc toPxDesc(const CHAR_CONTROLLER_DESC& desc)
	{
		PxCapsuleControllerDesc output;
		output.climbingMode = toPxEnum(desc.climbingMode);
		output.nonWalkableMode = toPxEnum(desc.nonWalkableMode);
		output.contactOffset = desc.contactOffset;
		output.stepOffset = desc.stepOffset;
		output.slopeLimit = desc.slopeLimit.valueRadians();
		output.height = desc.height;
		output.radius = desc.radius;
		output.upDirection = toPxVector(desc.up);
		output.position = toPxExtVector(desc.position);

		return output;
	}
Esempio n. 7
0
void PhysXRigidbody::move(const Vector3& position)
{
    if (getIsKinematic())
    {
        PxTransform target;
        if (!mInternal->getKinematicTarget(target))
            target = PxTransform(PxIdentity);

        target.p = toPxVector(position);

        mInternal->setKinematicTarget(target);
    }
    else
    {
        setTransform(position, getRotation());
    }
}
Esempio n. 8
0
void PhysXRigidbody::addTorque(const Vector3& force, ForceMode mode)
{
    mInternal->addTorque(toPxVector(force), toPxForceMode(mode));
}
Esempio n. 9
0
void PhysXRigidbody::setAngularVelocity(const Vector3& velocity)
{
    mInternal->setAngularVelocity(toPxVector(velocity));
}
	void PhysXCharacterController::setUp(const Vector3& up)
	{
		mController->setUpDirection(toPxVector(up));
	}
Esempio n. 11
0
	void PhysXD6Joint::setDriveVelocity(const Vector3& linear, const Vector3& angular)
	{
		getInternal()->setDriveVelocity(toPxVector(linear), toPxVector(angular));
	}