本文整理汇总了C++中Link::constraintSolve方法的典型用法代码示例。如果您正苦于以下问题:C++ Link::constraintSolve方法的具体用法?C++ Link::constraintSolve怎么用?C++ Link::constraintSolve使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Link
的用法示例。
在下文中一共展示了Link::constraintSolve方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: solveConstraints
/* Constraints */
void Particle::solveConstraints()
{
/* Link Constraints */
// Links make sure particles connected to this one is at a set distance away
for (int i = 0; i < links.size(); i++)
{
Link * currentLink = (Link *) links.at(i);
currentLink->constraintSolve();
}
/* Boundary Constraints */
// These if statements keep the particles within the screen
if (position.y < 1)
position.y = 2 * (1) - position.y;
if (position.y > ofGetHeight()-1)
position.y = 2 * (ofGetHeight() - 1) - position.y;
if (position.x > ofGetWidth()-1)
position.x = 2 * (ofGetWidth() - 1) - position.x;
if (position.x < 1)
position.x = 2 * (1) - position.x;
/* Other Constraints */
// make sure the particle stays in its place if it's pinned
if (pinned)
position = pinLocation;
}