Exemple #1
0
void Sc::ShapeSim::getFilterInfo(PxFilterObjectAttributes& filterAttr, PxFilterData& filterData) const
{
	filterAttr = 0;
	const PxShapeFlags flags = mCore.getFlags();

	if (hasTriggerFlags(flags))
		filterAttr |= PxFilterObjectFlag::eTRIGGER;

	BodySim* b = getBodySim();
	if (b)
	{
		if (!b->isArticulationLink())
		{
			if (b->isKinematic())
				filterAttr |= PxFilterObjectFlag::eKINEMATIC;

			setFilterObjectAttributeType(filterAttr, PxFilterObjectType::eRIGID_DYNAMIC);
		}
		else
			setFilterObjectAttributeType(filterAttr, PxFilterObjectType::eARTICULATION);
	}
	else
	{
		setFilterObjectAttributeType(filterAttr, PxFilterObjectType::eRIGID_STATIC);
	}

	filterData = mCore.getSimulationFilterData();
}
void Sc::ConstraintProjectionTree::rankConstraint(ConstraintSim& c, BodyRank& br, PxU32& dominanceTracking, PxU32& constraintsToProjectCount)
{
	PxU32 projectToBody, projectToOtherBody;
	BodySim* otherB;
	getConstraintStatus(c, br.startingNode->body, otherB, projectToBody, projectToOtherBody);

	if (isFixedBody(otherB))	// joint to fixed anchor
	{
		PxU32 rank;
		if (projectToOtherBody)
		{
			dominanceTracking = 0;  // makes sure that the flags below will never get raised again for the body
			br.rank &= ~(BodyRank::sAllDominantDynamic | BodyRank::sDominantDynamic);
			rank = BodyRank::sOneWayProjection;  //we should prefer picking projected constraints as the root over non-projected ones.
			constraintsToProjectCount++;
		}
		else
			rank = 0;

		if (!otherB)
			rank |= BodyRank::sAttachedToStatic;
		else
		{
			PX_ASSERT(otherB->isKinematic());
			rank |= BodyRank::sAttachedToKinematic;
		}

		// the highest ranked fixed anchor constraint should get tracked
		if ((!br.constraintToFixedAnchor) || (rank > br.rank))
			br.constraintToFixedAnchor = &c;

		br.rank |= rank;
	}
	else
	{
		if (projectToBody && projectToOtherBody)
		{
			dominanceTracking &= ~BodyRank::sAllDominantDynamic;  // makes sure that from now on this will never get raised again for the body
			br.rank &= ~BodyRank::sAllDominantDynamic;
			constraintsToProjectCount++;
		}
		else if (projectToOtherBody)
		{
			dominanceTracking &= ~(BodyRank::sAllDominantDynamic | BodyRank::sDominantDynamic);  // makes sure that from now on these will never get raised again for the body
			br.rank &= ~(BodyRank::sAllDominantDynamic | BodyRank::sDominantDynamic);
			constraintsToProjectCount++;
		}
		else if (projectToBody)
		{
			br.rank |= BodyRank::sOneWayProjection | (dominanceTracking & (BodyRank::sAllDominantDynamic | BodyRank::sDominantDynamic));
			constraintsToProjectCount++;
		}

		br.rank += BodyRank::sAttachedToDynamic;
	}
}