本文整理汇总了C++中Interaction::getType方法的典型用法代码示例。如果您正苦于以下问题:C++ Interaction::getType方法的具体用法?C++ Interaction::getType怎么用?C++ Interaction::getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Interaction
的用法示例。
在下文中一共展示了Interaction::getType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
PxU32 Sc::ConstraintProjectionTree::projectionTreeBuildStep(ConstraintGroupNode& node, ConstraintSim* cToParent, ConstraintGroupNode** nodeQueue)
{
PX_ASSERT(node.readFlag(ConstraintGroupNode::eDISCOVERED));
PxU32 nodeQueueFillCount = 0;
//go through all constraints attached to the body.
BodySim* body = node.body;
PxU32 size = body->getActorInteractionCount();
Sc::Interaction** interactions = body->getActorInteractions();
while(size--)
{
Interaction* interaction = *interactions++;
if (interaction->getType() == InteractionType::eCONSTRAINTSHADER)
{
ConstraintSim* c = static_cast<ConstraintInteraction*>(interaction)->getConstraint();
if (c != cToParent) //don't go back along the edge we came from (not really necessary I guess since the ConstraintGroupNode::eDISCOVERED marker should solve this)
{
PxU32 projectToBody, projectToOtherBody;
BodySim* neighbor;
getConstraintStatus(*c, body, neighbor, projectToBody, projectToOtherBody);
if(!isFixedBody(neighbor) && (!projectToOtherBody || projectToBody)) //just ignore the eventual constraint with environment over here. Body might be attached to multiple fixed anchors.
//Also make sure to ignore one-way projection that goes the opposite way.
{
ConstraintGroupNode* neighborNode = neighbor->getConstraintGroup();
PX_ASSERT(neighborNode);
if (!neighborNode->readFlag(ConstraintGroupNode::eDISCOVERED))
{
*nodeQueue = neighborNode;
neighborNode->initProjectionData(&node, c);
neighborNode->raiseFlag(ConstraintGroupNode::eDISCOVERED); //flag body nodes that we process so we can detect loops
nodeQueueFillCount++;
nodeQueue++;
}
}
}
}
}
return nodeQueueFillCount;
}
示例2: be
/*
the goal here is to take the constraint group whose root is passed, and create one or more projection trees.
At the moment, the group has to be acyclic and have at most 1 constraint with the ground to be accepted
without being broken up into multiple trees.
We 'flood fill' the constraint graph several times, starting at bodies where projection trees can be rooted.
Projection tree roots are always dynamic bodies which either need to get projected to a fixed anchor directly
or have projecting constraints between dynamics some way along the tree branches. Static and kinematic actors
are never roots and will not be explicitly part of any tree (but a tree root can project to at most one such fixed node).
The algo looks like this:
for all bodies
mark body as undiscovered
rank this body
The rank of a body depends on the constraints it's connected to. It defines the projection priority which
should be (highest first):
- dynamic attached to static/world with projection
- dynamic attached to kinematic with projection
- all dominant dynamic (has projecting constraints and all of them are one-way towards this dynamic)
---- all the ones above are guaranteed tree roots
- dominant dynamic (same as above but there is at least one projecting two-way constraint as well)
- partially dominant dynamic (has at least one projecting one-way constraints towards this dynamic and at least one projecting one-way constraints towards an other body)
- dynamic attached to static/world without projection
- dynamic attached to kinematic without projection
- dynamic with or without two-way projecting constraints to other dynamics (among these, the one with the highest connectivity count wins)
for the first three priority types sorted according to rank:
create a projection tree root and grow the tree one connectivity layer at a time
do the same for dominant dynamic bodies that have not been visited/discovered yet
for all remaining bodies sorted according to rank:
if the body still hasn't been visited/discovered start a projection tree there and build the whole tree in one go
before moving to the next potential root.
*/
void Sc::ConstraintProjectionTree::buildProjectionTrees(ConstraintGroupNode& root)
{
PX_ASSERT(&root == root.parent);
PX_ASSERT(!root.hasProjectionTreeRoot());
Ps::InlineArray<BodyRank, 64> bodyRankArray PX_DEBUG_EXP("bodyRankArray");
BodyRank br;
PxU32 constraintsToProjectCount = 0;
ConstraintGroupNode* node0 = &root;
while (node0) //for all nodes in group
{
PX_ASSERT(node0->body);
if (!node0->body->isKinematic())
{
node0->clearFlag(ConstraintGroupNode::eDISCOVERED);
//rank
br.startingNode = node0;
br.rank = 0;
br.constraintToFixedAnchor = 0;
PxU32 dominanceTracking = BodyRank::sAllDominantDynamic | BodyRank::sDominantDynamic;
//go through all constraints connected to body
PxU32 size = node0->body->getActorInteractionCount();
Sc::Interaction** interactions = node0->body->getActorInteractions();
while(size--)
{
Interaction* interaction = *interactions++;
if (interaction->getType() == InteractionType::eCONSTRAINTSHADER)
{
ConstraintSim* c = static_cast<ConstraintInteraction*>(interaction)->getConstraint();
rankConstraint(*c, br, dominanceTracking, constraintsToProjectCount);
}
}
PX_ASSERT(br.rank); //if it has no constraints then why is it in the constraint group?
if (br.rank >= BodyRank::sPrimaryTreeRootMinRank)
node0->raiseFlag(ConstraintGroupNode::eDISCOVERED); // we create a tree for each node attached to a fixed anchor, or a node which is an all dominating dynamic
// -> make sure they do not include each other
bodyRankArray.pushBack(br);
}
else
node0->raiseFlag(ConstraintGroupNode::eDISCOVERED); // a kinematic does not get projected, it might only get projected to and it is never part of a tree.
node0 = node0->next;
}
root.setProjectionCountHint(constraintsToProjectCount);
if (bodyRankArray.size()) // all of the bodies might have been switched to kinematic in which case there will be no ranked body
{
//sort bodyRankArray
Ps::sort(&bodyRankArray.front(), bodyRankArray.size(), Ps::Greater<BodyRank>());
ConstraintGroupNode** nodeQueue = reinterpret_cast<ConstraintGroupNode**>(PX_ALLOC_TEMP(sizeof(ConstraintGroupNode*)*bodyRankArray.size(), "ProjectionNodeQueue"));
if (nodeQueue)
{
//build the projectionTree
//.........这里部分代码省略.........