59 |
|
painCave.isFatal = 1; |
60 |
|
simError(); |
61 |
|
} |
62 |
– |
|
62 |
|
currentSnapshot_ = info_->getSnapshotManager()->getCurrentSnapshot(); |
63 |
|
} |
64 |
|
|
81 |
|
ConstraintPair* consPair; |
82 |
|
Molecule::ConstraintPairIterator cpi; |
83 |
|
|
84 |
< |
for (mol = info_->beginMolecule(mi); mol != NULL; mol = info_->nextMolecule(mi)) { |
85 |
< |
for (consElem = mol->beginConstraintElem(cei); consElem != NULL; consElem = mol->nextConstraintElem(cei)) { |
84 |
> |
for (mol = info_->beginMolecule(mi); mol != NULL; |
85 |
> |
mol = info_->nextMolecule(mi)) { |
86 |
> |
for (consElem = mol->beginConstraintElem(cei); consElem != NULL; |
87 |
> |
consElem = mol->nextConstraintElem(cei)) { |
88 |
|
consElem->setMoved(true); |
89 |
|
consElem->setMoving(false); |
90 |
|
} |
98 |
|
|
99 |
|
//loop over every constraint pair |
100 |
|
|
101 |
< |
for (mol = info_->beginMolecule(mi); mol != NULL; mol = info_->nextMolecule(mi)) { |
102 |
< |
for (consPair = mol->beginConstraintPair(cpi); consPair != NULL; consPair = mol->nextConstraintPair(cpi)) { |
101 |
> |
for (mol = info_->beginMolecule(mi); mol != NULL; |
102 |
> |
mol = info_->nextMolecule(mi)) { |
103 |
> |
for (consPair = mol->beginConstraintPair(cpi); consPair != NULL; |
104 |
> |
consPair = mol->nextConstraintPair(cpi)) { |
105 |
|
|
106 |
|
|
107 |
|
//dispatch constraint algorithm |
111 |
|
switch(exeStatus){ |
112 |
|
case consFail: |
113 |
|
sprintf(painCave.errMsg, |
114 |
< |
"Constraint failure in Rattle::constrainA, Constraint Fail\n"); |
114 |
> |
"Constraint failure in Rattle::constrainA, " |
115 |
> |
"Constraint Fail\n"); |
116 |
|
painCave.isFatal = 1; |
117 |
|
simError(); |
118 |
|
|
119 |
|
break; |
120 |
|
case consSuccess: |
121 |
< |
//constrain the pair by moving two elements |
121 |
> |
// constrain the pair by moving two elements |
122 |
|
done = false; |
123 |
|
consPair->getConsElem1()->setMoving(true); |
124 |
|
consPair->getConsElem2()->setMoving(true); |
125 |
|
break; |
126 |
|
case consAlready: |
127 |
< |
//current pair is already constrained, do not need to move the elements |
127 |
> |
// current pair is already constrained, do not need to |
128 |
> |
// move the elements |
129 |
|
break; |
130 |
|
default: |
131 |
< |
sprintf(painCave.errMsg, "ConstraintAlgorithm::doConstrain() Error: unrecognized status"); |
131 |
> |
sprintf(painCave.errMsg, "ConstraintAlgorithm::doConstraint() " |
132 |
> |
"Error: unrecognized status"); |
133 |
|
painCave.isFatal = 1; |
134 |
|
simError(); |
135 |
|
break; |
139 |
|
}//end for(iter->first()) |
140 |
|
|
141 |
|
|
142 |
< |
for (mol = info_->beginMolecule(mi); mol != NULL; mol = info_->nextMolecule(mi)) { |
143 |
< |
for (consElem = mol->beginConstraintElem(cei); consElem != NULL; consElem = mol->nextConstraintElem(cei)) { |
142 |
> |
for (mol = info_->beginMolecule(mi); mol != NULL; |
143 |
> |
mol = info_->nextMolecule(mi)) { |
144 |
> |
for (consElem = mol->beginConstraintElem(cei); consElem != NULL; |
145 |
> |
consElem = mol->nextConstraintElem(cei)) { |
146 |
|
consElem->setMoved(consElem->getMoving()); |
147 |
|
consElem->setMoving(false); |
148 |
|
} |
153 |
|
|
154 |
|
if (!done){ |
155 |
|
sprintf(painCave.errMsg, |
156 |
< |
"Constraint failure in Rattle::constrainA, too many iterations: %d\n", |
156 |
> |
"Constraint failure in Rattle::constrainA, " |
157 |
> |
"too many iterations: %d\n", |
158 |
|
iteration); |
159 |
|
painCave.isFatal = 1; |
160 |
|
simError(); |
223 |
|
Vector3d velB = consElem2->getVel(); |
224 |
|
velB -= rmb * delta; |
225 |
|
consElem2->setVel(velB); |
226 |
< |
|
226 |
> |
|
227 |
> |
// report the constraint force back to the constraint pair: |
228 |
> |
consPair->setConstraintForce(gab); |
229 |
|
return consSuccess; |
230 |
|
} |
231 |
|
else |
267 |
|
velB -= rmb * delta; |
268 |
|
consElem2->setVel(velB); |
269 |
|
|
270 |
+ |
// report the constraint force back to the constraint pair: |
271 |
+ |
consPair->setConstraintForce(gab); |
272 |
|
return consSuccess; |
273 |
|
} |
274 |
|
else |