Example #1
0
bool Sc::BodySim::isConnectedTo(const RigidSim& other, bool& collisionDisabled) const
{
    const Sc::Actor* actorToMatch;
    Cm::Range<Interaction*const> interactions;

    if (getActorInteractionCount() <= other.getActorInteractionCount())
    {
        interactions = getActorInteractions();
        actorToMatch = &other;
    }
    else
    {
        interactions = other.getActorInteractions();
        actorToMatch = this;
    }

    for(; !interactions.empty(); interactions.popFront())
    {
        Interaction* const interaction = interactions.front();
        if (interaction->getType() == PX_INTERACTION_TYPE_CONSTRAINTSHADER)
        {
            ConstraintInteraction* csi = static_cast<ConstraintInteraction*>(interaction);
            if ((&csi->getActor0() == actorToMatch) || (&csi->getActor1() == actorToMatch))
            {
                collisionDisabled = !((csi->getConstraint()->getCore().getFlags() & PxConstraintFlag::eCOLLISION_ENABLED));
                return true;
            }
        }
    }

    collisionDisabled = false;
    return false;
}
void Sc::ParticleSystemSim::prepareCollisionInput(PxBaseTask* /*continuation*/)
{
	PxU32 numParticleShapes = mParticlePacketShapes.size();
	PxU32 numInteractionsTest = 0;

	//note: this buffer needs to be deallocated in LL 
	PxU32 cmStreamSize = PxsParticleContactManagerStreamWriter::getStreamSize(numParticleShapes, mInteractionCount);
	PxU8* cmStream = (PxU8*)(PX_ALLOC_TEMP(cmStreamSize, PX_DEBUG_EXP("ParticleContactManagerStream")));

	PxsParticleContactManagerStreamWriter swriter(cmStream, numParticleShapes, mInteractionCount);

	for (PxU32 s = 0; s < mParticlePacketShapes.size(); ++s)
	{
		const Sc::ParticlePacketShape& particleShape = *mParticlePacketShapes[s];
		swriter.addParticleShape(particleShape.getLowLevelParticleShape());

		//count number of interactions... could be cached
		for(Cm::Range<ParticleElementRbElementInteraction*const> interactions = particleShape.getPacketShapeInteractions(); !interactions.empty(); interactions.popFront())
		{
			PX_ASSERT(interactions.front()->getType()==PX_INTERACTION_TYPE_PARTICLE_BODY);
			const Sc::ParticleElementRbElementInteraction& cm = *interactions.front();
			
			if (!cm.isDisabled())
			{
				PX_ASSERT(cm.getElementSim1().getElementType() == PX_ELEMENT_TYPE_SHAPE);
				const Sc::ShapeSim& shapeSim = cm.getRbShape();
				bool isDynamic = shapeSim.actorIsDynamic();
				const RigidSim& rigidSim = shapeSim.getRbSim();				
				PxsRigidCore& rigidCore =  static_cast<BodyCore&>(rigidSim.getActorCore()).getCore();	
				const PxTransform* w2sOld = isDynamic ? getInteractionScene().getLowLevelContext()->getBodyTransformVault().getTransform(static_cast<const PxsBodyCore&>(rigidCore)) : NULL;
				swriter.addContactManager(&rigidCore, &shapeSim.getCore().getCore(), w2sOld, (shapeSim.getFlags() & PxShapeFlag::ePARTICLE_DRAIN) != 0, isDynamic);
				numInteractionsTest++;
			}
		}
	}
	PX_ASSERT(numInteractionsTest == mInteractionCount);

	//passes ownership to low level object
	PxvParticleCollisionUpdateInput input;
	input.contactManagerStream = cmStream;
	mLLSim->passCollisionInputV(input);
}
void Sc::ParticlePacketShape::setInteractionsDirty(CoreInteraction::DirtyFlag flag)
{
	Cm::Range<ParticleElementRbElementInteraction*const> interactions = getPacketShapeInteractions();
	for (; !interactions.empty(); interactions.popFront())
	{
		ParticleElementRbElementInteraction*const interaction = interactions.front();

		PX_ASSERT(interaction->getInteractionFlags() & PX_INTERACTION_FLAG_FILTERABLE);
		PX_ASSERT(interaction->getInteractionFlags() & PX_INTERACTION_FLAG_ELEMENT_ACTOR);
		PX_ASSERT(CoreInteraction::isCoreInteraction(interaction) != NULL);

		interaction->setDirty(flag);
	}
}
Example #4
0
void Sc::ActorSim::setActorsInteractionsDirty(CoreInteraction::DirtyFlag flag, const Actor* other, PxU8 interactionFlag)
{
	Cm::Range<Interaction*const> interactions = getActorInteractions();
	for (; !interactions.empty(); interactions.popFront())
	{
		Interaction*const interaction = interactions.front();
		if ((!other || other == &interaction->getActor0() || other == &interaction->getActor1()) &&
			(interaction->getInteractionFlags() & interactionFlag))
		{
			CoreInteraction* ci = CoreInteraction::isCoreInteraction(interaction);
			if (ci != NULL)
				ci->setDirty(flag);
		}
	}
}
Example #5
0
void Sc::BodySim::onConstraintDetach()
{
    PX_ASSERT(readInternalFlag(BF_HAS_CONSTRAINTS));

    Cm::Range<Interaction*const> interactions = getActorInteractions();
    unregisterUniqueInteraction();

    for(; !interactions.empty(); interactions.popFront())
    {
        Interaction* const interaction = interactions.front();
        if (interaction->getType() == PX_INTERACTION_TYPE_CONSTRAINTSHADER)
            return;
    }

    clearInternalFlag(BF_HAS_CONSTRAINTS);  // There are no other constraint interactions left
}
void Sc::ParticleSystemSim::visualizeInteractions(Cm::RenderOutput& out)
{
	out << PxU32(PxDebugColor::eARGB_GREEN) << Cm::RenderOutput::LINES;
	for(PxU32 i=0; i < mParticlePacketShapes.size(); i++)
	{
		ParticlePacketShape* particleShape = mParticlePacketShapes[i];

		Cm::Range<ParticleElementRbElementInteraction*const> interactions = particleShape->getPacketShapeInteractions();
		for (; !interactions.empty(); interactions.popFront())
		{
			ParticleElementRbElementInteraction*const interaction = interactions.front();

			PX_ASSERT(interaction->getType() == PX_INTERACTION_TYPE_PARTICLE_BODY);

			PxBounds3 bounds = particleShape->getBounds();
			out << bounds.getCenter() << interaction->getRbShape().getAbsPose().p;
		}
	}
}