Constraint.cpp 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609
  1. //
  2. // Copyright (c) 2008-2016 the Urho3D project.
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining a copy
  5. // of this software and associated documentation files (the "Software"), to deal
  6. // in the Software without restriction, including without limitation the rights
  7. // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  8. // copies of the Software, and to permit persons to whom the Software is
  9. // furnished to do so, subject to the following conditions:
  10. //
  11. // The above copyright notice and this permission notice shall be included in
  12. // all copies or substantial portions of the Software.
  13. //
  14. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  17. // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  18. // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  19. // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  20. // THE SOFTWARE.
  21. //
  22. #include "../Precompiled.h"
  23. #include "../Core/Context.h"
  24. #include "../Core/Profiler.h"
  25. #include "../Graphics/DebugRenderer.h"
  26. #include "../IO/Log.h"
  27. #include "../Physics/Constraint.h"
  28. #include "../Physics/PhysicsUtils.h"
  29. #include "../Physics/PhysicsWorld.h"
  30. #include "../Physics/RigidBody.h"
  31. #include "../Scene/Scene.h"
  32. // ATOMIC BEGIN
  33. #include <Bullet/src/BulletDynamics/ConstraintSolver/btConeTwistConstraint.h>
  34. #include <Bullet/src/BulletDynamics/ConstraintSolver/btHingeConstraint.h>
  35. #include <Bullet/src/BulletDynamics/ConstraintSolver/btPoint2PointConstraint.h>
  36. #include <Bullet/src/BulletDynamics/ConstraintSolver/btSliderConstraint.h>
  37. #include <Bullet/src/BulletDynamics/Dynamics/btDiscreteDynamicsWorld.h>
  38. // ATOMIC END
  39. namespace Atomic
  40. {
  41. static const char* typeNames[] =
  42. {
  43. "Point",
  44. "Hinge",
  45. "Slider",
  46. "ConeTwist",
  47. 0
  48. };
  49. extern const char* PHYSICS_CATEGORY;
  50. Constraint::Constraint(Context* context) :
  51. Component(context),
  52. constraint_(0),
  53. constraintType_(CONSTRAINT_POINT),
  54. position_(Vector3::ZERO),
  55. rotation_(Quaternion::IDENTITY),
  56. otherPosition_(Vector3::ZERO),
  57. otherRotation_(Quaternion::IDENTITY),
  58. highLimit_(Vector2::ZERO),
  59. lowLimit_(Vector2::ZERO),
  60. erp_(0.0f),
  61. cfm_(0.0f),
  62. otherBodyNodeID_(0),
  63. disableCollision_(false),
  64. recreateConstraint_(true),
  65. framesDirty_(false),
  66. retryCreation_(false)
  67. {
  68. }
  69. Constraint::~Constraint()
  70. {
  71. ReleaseConstraint();
  72. if (physicsWorld_)
  73. physicsWorld_->RemoveConstraint(this);
  74. }
  75. void Constraint::RegisterObject(Context* context)
  76. {
  77. context->RegisterFactory<Constraint>(PHYSICS_CATEGORY);
  78. ATOMIC_ACCESSOR_ATTRIBUTE("Is Enabled", IsEnabled, SetEnabled, bool, true, AM_DEFAULT);
  79. ATOMIC_ENUM_ATTRIBUTE("Constraint Type", constraintType_, typeNames, CONSTRAINT_POINT, AM_DEFAULT);
  80. ATOMIC_ATTRIBUTE("Position", Vector3, position_, Vector3::ZERO, AM_DEFAULT);
  81. ATOMIC_ATTRIBUTE("Rotation", Quaternion, rotation_, Quaternion::IDENTITY, AM_DEFAULT);
  82. ATOMIC_ATTRIBUTE("Other Body Position", Vector3, otherPosition_, Vector3::ZERO, AM_DEFAULT);
  83. ATOMIC_ATTRIBUTE("Other Body Rotation", Quaternion, otherRotation_, Quaternion::IDENTITY, AM_DEFAULT);
  84. ATOMIC_ATTRIBUTE("Other Body NodeID", unsigned, otherBodyNodeID_, 0, AM_DEFAULT | AM_NODEID);
  85. ATOMIC_ACCESSOR_ATTRIBUTE("High Limit", GetHighLimit, SetHighLimit, Vector2, Vector2::ZERO, AM_DEFAULT);
  86. ATOMIC_ACCESSOR_ATTRIBUTE("Low Limit", GetLowLimit, SetLowLimit, Vector2, Vector2::ZERO, AM_DEFAULT);
  87. ATOMIC_ACCESSOR_ATTRIBUTE("ERP Parameter", GetERP, SetERP, float, 0.0f, AM_DEFAULT);
  88. ATOMIC_ACCESSOR_ATTRIBUTE("CFM Parameter", GetCFM, SetCFM, float, 0.0f, AM_DEFAULT);
  89. ATOMIC_ATTRIBUTE("Disable Collision", bool, disableCollision_, false, AM_DEFAULT);
  90. }
  91. void Constraint::OnSetAttribute(const AttributeInfo& attr, const Variant& src)
  92. {
  93. Serializable::OnSetAttribute(attr, src);
  94. if (!attr.accessor_)
  95. {
  96. // Convenience for editing static constraints: if not connected to another body, adjust world position to match local
  97. // (when deserializing, the proper other body position will be read after own position, so this calculation is safely
  98. // overridden and does not accumulate constraint error
  99. if (attr.offset_ == offsetof(Constraint, position_) && constraint_ && !otherBody_)
  100. {
  101. btTransform ownBody = constraint_->getRigidBodyA().getWorldTransform();
  102. btVector3 worldPos = ownBody * ToBtVector3(position_ * cachedWorldScale_ - ownBody_->GetCenterOfMass());
  103. otherPosition_ = ToVector3(worldPos);
  104. }
  105. // Certain attribute changes require recreation of the constraint
  106. if (attr.offset_ == offsetof(Constraint, constraintType_) || attr.offset_ == offsetof(Constraint, otherBodyNodeID_) ||
  107. attr.offset_ == offsetof(Constraint, disableCollision_))
  108. recreateConstraint_ = true;
  109. else
  110. framesDirty_ = true;
  111. }
  112. }
  113. void Constraint::ApplyAttributes()
  114. {
  115. if (recreateConstraint_)
  116. {
  117. if (otherBody_)
  118. otherBody_->RemoveConstraint(this);
  119. otherBody_.Reset();
  120. Scene* scene = GetScene();
  121. if (scene && otherBodyNodeID_)
  122. {
  123. Node* otherNode = scene->GetNode(otherBodyNodeID_);
  124. if (otherNode)
  125. otherBody_ = otherNode->GetComponent<RigidBody>();
  126. }
  127. CreateConstraint();
  128. }
  129. else if (framesDirty_)
  130. {
  131. ApplyFrames();
  132. framesDirty_ = false;
  133. }
  134. }
  135. void Constraint::OnSetEnabled()
  136. {
  137. if (constraint_)
  138. constraint_->setEnabled(IsEnabledEffective());
  139. }
  140. void Constraint::GetDependencyNodes(PODVector<Node*>& dest)
  141. {
  142. if (otherBody_ && otherBody_->GetNode())
  143. dest.Push(otherBody_->GetNode());
  144. }
  145. void Constraint::DrawDebugGeometry(DebugRenderer* debug, bool depthTest)
  146. {
  147. if (debug && physicsWorld_ && constraint_)
  148. {
  149. physicsWorld_->SetDebugRenderer(debug);
  150. physicsWorld_->SetDebugDepthTest(depthTest);
  151. physicsWorld_->GetWorld()->debugDrawConstraint(constraint_);
  152. physicsWorld_->SetDebugRenderer(0);
  153. }
  154. }
  155. void Constraint::SetConstraintType(ConstraintType type)
  156. {
  157. if (type != constraintType_)
  158. {
  159. constraintType_ = type;
  160. CreateConstraint();
  161. MarkNetworkUpdate();
  162. }
  163. }
  164. void Constraint::SetOtherBody(RigidBody* body)
  165. {
  166. if (otherBody_ != body)
  167. {
  168. if (otherBody_)
  169. otherBody_->RemoveConstraint(this);
  170. otherBody_ = body;
  171. // Update the connected body attribute
  172. Node* otherNode = otherBody_ ? otherBody_->GetNode() : 0;
  173. otherBodyNodeID_ = otherNode ? otherNode->GetID() : 0;
  174. CreateConstraint();
  175. MarkNetworkUpdate();
  176. }
  177. }
  178. void Constraint::SetPosition(const Vector3& position)
  179. {
  180. if (position != position_)
  181. {
  182. position_ = position;
  183. ApplyFrames();
  184. MarkNetworkUpdate();
  185. }
  186. }
  187. void Constraint::SetRotation(const Quaternion& rotation)
  188. {
  189. if (rotation != rotation_)
  190. {
  191. rotation_ = rotation;
  192. ApplyFrames();
  193. MarkNetworkUpdate();
  194. }
  195. }
  196. void Constraint::SetAxis(const Vector3& axis)
  197. {
  198. switch (constraintType_)
  199. {
  200. case CONSTRAINT_POINT:
  201. case CONSTRAINT_HINGE:
  202. rotation_ = Quaternion(Vector3::FORWARD, axis);
  203. break;
  204. case CONSTRAINT_SLIDER:
  205. case CONSTRAINT_CONETWIST:
  206. rotation_ = Quaternion(Vector3::RIGHT, axis);
  207. break;
  208. default:
  209. break;
  210. }
  211. ApplyFrames();
  212. MarkNetworkUpdate();
  213. }
  214. void Constraint::SetOtherPosition(const Vector3& position)
  215. {
  216. if (position != otherPosition_)
  217. {
  218. otherPosition_ = position;
  219. ApplyFrames();
  220. MarkNetworkUpdate();
  221. }
  222. }
  223. void Constraint::SetOtherRotation(const Quaternion& rotation)
  224. {
  225. if (rotation != otherRotation_)
  226. {
  227. otherRotation_ = rotation;
  228. ApplyFrames();
  229. MarkNetworkUpdate();
  230. }
  231. }
  232. void Constraint::SetOtherAxis(const Vector3& axis)
  233. {
  234. switch (constraintType_)
  235. {
  236. case CONSTRAINT_POINT:
  237. case CONSTRAINT_HINGE:
  238. otherRotation_ = Quaternion(Vector3::FORWARD, axis);
  239. break;
  240. case CONSTRAINT_SLIDER:
  241. case CONSTRAINT_CONETWIST:
  242. otherRotation_ = Quaternion(Vector3::RIGHT, axis);
  243. break;
  244. default:
  245. break;
  246. }
  247. ApplyFrames();
  248. MarkNetworkUpdate();
  249. }
  250. void Constraint::SetWorldPosition(const Vector3& position)
  251. {
  252. if (constraint_)
  253. {
  254. btTransform ownBodyInverse = constraint_->getRigidBodyA().getWorldTransform().inverse();
  255. btTransform otherBodyInverse = constraint_->getRigidBodyB().getWorldTransform().inverse();
  256. btVector3 worldPos = ToBtVector3(position);
  257. position_ = (ToVector3(ownBodyInverse * worldPos) + ownBody_->GetCenterOfMass()) / cachedWorldScale_;
  258. otherPosition_ = ToVector3(otherBodyInverse * worldPos);
  259. if (otherBody_)
  260. {
  261. otherPosition_ += otherBody_->GetCenterOfMass();
  262. otherPosition_ /= otherBody_->GetNode()->GetWorldScale();
  263. }
  264. ApplyFrames();
  265. MarkNetworkUpdate();
  266. }
  267. else
  268. ATOMIC_LOGWARNING("Constraint not created, world position could not be stored");
  269. }
  270. void Constraint::SetHighLimit(const Vector2& limit)
  271. {
  272. if (limit != highLimit_)
  273. {
  274. highLimit_ = limit;
  275. ApplyLimits();
  276. MarkNetworkUpdate();
  277. }
  278. }
  279. void Constraint::SetLowLimit(const Vector2& limit)
  280. {
  281. if (limit != lowLimit_)
  282. {
  283. lowLimit_ = limit;
  284. ApplyLimits();
  285. MarkNetworkUpdate();
  286. }
  287. }
  288. void Constraint::SetERP(float erp)
  289. {
  290. erp = Max(erp, 0.0f);
  291. if (erp != erp_)
  292. {
  293. erp_ = erp;
  294. ApplyLimits();
  295. MarkNetworkUpdate();
  296. }
  297. }
  298. void Constraint::SetCFM(float cfm)
  299. {
  300. cfm = Max(cfm, 0.0f);
  301. if (cfm != cfm_)
  302. {
  303. cfm_ = cfm;
  304. ApplyLimits();
  305. MarkNetworkUpdate();
  306. }
  307. }
  308. void Constraint::SetDisableCollision(bool disable)
  309. {
  310. if (disable != disableCollision_)
  311. {
  312. disableCollision_ = disable;
  313. CreateConstraint();
  314. MarkNetworkUpdate();
  315. }
  316. }
  317. Vector3 Constraint::GetWorldPosition() const
  318. {
  319. if (constraint_)
  320. {
  321. btTransform ownBody = constraint_->getRigidBodyA().getWorldTransform();
  322. return ToVector3(ownBody * ToBtVector3(position_ * cachedWorldScale_ - ownBody_->GetCenterOfMass()));
  323. }
  324. else
  325. return Vector3::ZERO;
  326. }
  327. void Constraint::ReleaseConstraint()
  328. {
  329. if (constraint_)
  330. {
  331. if (ownBody_)
  332. ownBody_->RemoveConstraint(this);
  333. if (otherBody_)
  334. otherBody_->RemoveConstraint(this);
  335. if (physicsWorld_)
  336. physicsWorld_->GetWorld()->removeConstraint(constraint_);
  337. delete constraint_;
  338. constraint_ = 0;
  339. }
  340. }
  341. void Constraint::ApplyFrames()
  342. {
  343. if (!constraint_ || !node_ || (otherBody_ && !otherBody_->GetNode()))
  344. return;
  345. cachedWorldScale_ = node_->GetWorldScale();
  346. Vector3 ownBodyScaledPosition = position_ * cachedWorldScale_ - ownBody_->GetCenterOfMass();
  347. Vector3 otherBodyScaledPosition =
  348. otherBody_ ? otherPosition_ * otherBody_->GetNode()->GetWorldScale() - otherBody_->GetCenterOfMass() : otherPosition_;
  349. switch (constraint_->getConstraintType())
  350. {
  351. case POINT2POINT_CONSTRAINT_TYPE:
  352. {
  353. btPoint2PointConstraint* pointConstraint = static_cast<btPoint2PointConstraint*>(constraint_);
  354. pointConstraint->setPivotA(ToBtVector3(ownBodyScaledPosition));
  355. pointConstraint->setPivotB(ToBtVector3(otherBodyScaledPosition));
  356. }
  357. break;
  358. case HINGE_CONSTRAINT_TYPE:
  359. {
  360. btHingeConstraint* hingeConstraint = static_cast<btHingeConstraint*>(constraint_);
  361. btTransform ownFrame(ToBtQuaternion(rotation_), ToBtVector3(ownBodyScaledPosition));
  362. btTransform otherFrame(ToBtQuaternion(otherRotation_), ToBtVector3(otherBodyScaledPosition));
  363. hingeConstraint->setFrames(ownFrame, otherFrame);
  364. }
  365. break;
  366. case SLIDER_CONSTRAINT_TYPE:
  367. {
  368. btSliderConstraint* sliderConstraint = static_cast<btSliderConstraint*>(constraint_);
  369. btTransform ownFrame(ToBtQuaternion(rotation_), ToBtVector3(ownBodyScaledPosition));
  370. btTransform otherFrame(ToBtQuaternion(otherRotation_), ToBtVector3(otherBodyScaledPosition));
  371. sliderConstraint->setFrames(ownFrame, otherFrame);
  372. }
  373. break;
  374. case CONETWIST_CONSTRAINT_TYPE:
  375. {
  376. btConeTwistConstraint* coneTwistConstraint = static_cast<btConeTwistConstraint*>(constraint_);
  377. btTransform ownFrame(ToBtQuaternion(rotation_), ToBtVector3(ownBodyScaledPosition));
  378. btTransform otherFrame(ToBtQuaternion(otherRotation_), ToBtVector3(otherBodyScaledPosition));
  379. coneTwistConstraint->setFrames(ownFrame, otherFrame);
  380. }
  381. break;
  382. default:
  383. break;
  384. }
  385. }
  386. void Constraint::OnNodeSet(Node* node)
  387. {
  388. if (node)
  389. {
  390. node->AddListener(this);
  391. cachedWorldScale_ = node->GetWorldScale();
  392. }
  393. }
  394. void Constraint::OnSceneSet(Scene* scene)
  395. {
  396. if (scene)
  397. {
  398. if (scene == node_)
  399. ATOMIC_LOGWARNING(GetTypeName() + " should not be created to the root scene node");
  400. physicsWorld_ = scene->GetOrCreateComponent<PhysicsWorld>();
  401. physicsWorld_->AddConstraint(this);
  402. // Create constraint now if necessary (attributes modified before adding to scene)
  403. if (retryCreation_)
  404. CreateConstraint();
  405. }
  406. else
  407. {
  408. ReleaseConstraint();
  409. if (physicsWorld_)
  410. physicsWorld_->RemoveConstraint(this);
  411. // Recreate when moved to a scene again
  412. retryCreation_ = true;
  413. }
  414. }
  415. void Constraint::OnMarkedDirty(Node* node)
  416. {
  417. /// \todo This does not catch the connected body node's scale changing
  418. if (HasWorldScaleChanged(cachedWorldScale_, node->GetWorldScale()))
  419. ApplyFrames();
  420. }
  421. void Constraint::CreateConstraint()
  422. {
  423. ATOMIC_PROFILE(CreateConstraint);
  424. cachedWorldScale_ = node_->GetWorldScale();
  425. ReleaseConstraint();
  426. ownBody_ = GetComponent<RigidBody>();
  427. btRigidBody* ownBody = ownBody_ ? ownBody_->GetBody() : 0;
  428. btRigidBody* otherBody = otherBody_ ? otherBody_->GetBody() : 0;
  429. // If no physics world available now mark for retry later
  430. if (!physicsWorld_ || !ownBody)
  431. {
  432. retryCreation_ = true;
  433. return;
  434. }
  435. if (!otherBody)
  436. otherBody = &btTypedConstraint::getFixedBody();
  437. Vector3 ownBodyScaledPosition = position_ * cachedWorldScale_ - ownBody_->GetCenterOfMass();
  438. Vector3 otherBodyScaledPosition = otherBody_ ? otherPosition_ * otherBody_->GetNode()->GetWorldScale() -
  439. otherBody_->GetCenterOfMass() : otherPosition_;
  440. switch (constraintType_)
  441. {
  442. case CONSTRAINT_POINT:
  443. {
  444. constraint_ = new btPoint2PointConstraint(*ownBody, *otherBody, ToBtVector3(ownBodyScaledPosition),
  445. ToBtVector3(otherBodyScaledPosition));
  446. }
  447. break;
  448. case CONSTRAINT_HINGE:
  449. {
  450. btTransform ownFrame(ToBtQuaternion(rotation_), ToBtVector3(ownBodyScaledPosition));
  451. btTransform otherFrame(ToBtQuaternion(otherRotation_), ToBtVector3(otherBodyScaledPosition));
  452. constraint_ = new btHingeConstraint(*ownBody, *otherBody, ownFrame, otherFrame);
  453. }
  454. break;
  455. case CONSTRAINT_SLIDER:
  456. {
  457. btTransform ownFrame(ToBtQuaternion(rotation_), ToBtVector3(ownBodyScaledPosition));
  458. btTransform otherFrame(ToBtQuaternion(otherRotation_), ToBtVector3(otherBodyScaledPosition));
  459. constraint_ = new btSliderConstraint(*ownBody, *otherBody, ownFrame, otherFrame, false);
  460. }
  461. break;
  462. case CONSTRAINT_CONETWIST:
  463. {
  464. btTransform ownFrame(ToBtQuaternion(rotation_), ToBtVector3(ownBodyScaledPosition));
  465. btTransform otherFrame(ToBtQuaternion(otherRotation_), ToBtVector3(otherBodyScaledPosition));
  466. constraint_ = new btConeTwistConstraint(*ownBody, *otherBody, ownFrame, otherFrame);
  467. }
  468. break;
  469. default:
  470. break;
  471. }
  472. if (constraint_)
  473. {
  474. constraint_->setUserConstraintPtr(this);
  475. constraint_->setEnabled(IsEnabledEffective());
  476. ownBody_->AddConstraint(this);
  477. if (otherBody_)
  478. otherBody_->AddConstraint(this);
  479. ApplyLimits();
  480. physicsWorld_->GetWorld()->addConstraint(constraint_, disableCollision_);
  481. }
  482. recreateConstraint_ = false;
  483. framesDirty_ = false;
  484. retryCreation_ = false;
  485. }
  486. void Constraint::ApplyLimits()
  487. {
  488. if (!constraint_)
  489. return;
  490. switch (constraint_->getConstraintType())
  491. {
  492. case HINGE_CONSTRAINT_TYPE:
  493. {
  494. btHingeConstraint* hingeConstraint = static_cast<btHingeConstraint*>(constraint_);
  495. hingeConstraint->setLimit(lowLimit_.x_ * M_DEGTORAD, highLimit_.x_ * M_DEGTORAD);
  496. }
  497. break;
  498. case SLIDER_CONSTRAINT_TYPE:
  499. {
  500. btSliderConstraint* sliderConstraint = static_cast<btSliderConstraint*>(constraint_);
  501. sliderConstraint->setUpperLinLimit(highLimit_.x_);
  502. sliderConstraint->setUpperAngLimit(highLimit_.y_ * M_DEGTORAD);
  503. sliderConstraint->setLowerLinLimit(lowLimit_.x_);
  504. sliderConstraint->setLowerAngLimit(lowLimit_.y_ * M_DEGTORAD);
  505. }
  506. break;
  507. case CONETWIST_CONSTRAINT_TYPE:
  508. {
  509. btConeTwistConstraint* coneTwistConstraint = static_cast<btConeTwistConstraint*>(constraint_);
  510. coneTwistConstraint->setLimit(highLimit_.y_ * M_DEGTORAD, highLimit_.y_ * M_DEGTORAD, highLimit_.x_ * M_DEGTORAD);
  511. }
  512. break;
  513. default:
  514. break;
  515. }
  516. if (erp_ != 0.0f)
  517. constraint_->setParam(BT_CONSTRAINT_STOP_ERP, erp_);
  518. if (cfm_ != 0.0f)
  519. constraint_->setParam(BT_CONSTRAINT_STOP_CFM, cfm_);
  520. }
  521. }