Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added get/setLCPSolver functions to ConstraintSolver #633

Merged
merged 2 commits into from
Mar 21, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion dart/constraint/ConstraintSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ void ConstraintSolver::setCollisionDetector(

//==============================================================================
void ConstraintSolver::setCollisionDetector(
std::unique_ptr<collision::CollisionDetector>&& _collisionDetector)
std::unique_ptr<collision::CollisionDetector> _collisionDetector)
{
assert(_collisionDetector && "Invalid collision detector.");

Expand All @@ -261,6 +261,20 @@ collision::CollisionDetector* ConstraintSolver::getCollisionDetector() const
return mCollisionDetector.get();
}

//==============================================================================
void ConstraintSolver::setLCPSolver(std::unique_ptr<LCPSolver> _lcpSolver)
{
assert(_lcpSolver && "Invalid LCP solver.");

mLCPSolver = std::move(_lcpSolver);
}

//==============================================================================
LCPSolver* ConstraintSolver::getLCPSolver() const
{
return mLCPSolver.get();
}

//==============================================================================
void ConstraintSolver::solve()
{
Expand Down
8 changes: 7 additions & 1 deletion dart/constraint/ConstraintSolver.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,17 @@ class ConstraintSolver

/// Set collision detector
void setCollisionDetector(
std::unique_ptr<collision::CollisionDetector>&& _collisionDetector);
std::unique_ptr<collision::CollisionDetector> _collisionDetector);

/// Get collision detector
collision::CollisionDetector* getCollisionDetector() const;

/// Set LCP solver
void setLCPSolver(std::unique_ptr<LCPSolver> _lcpSolver);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Passing const reference like std::shared_ptr<T> case?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That shouldn't be done for unique_ptr because we want the ownership of the solver to be passed into the ConstraintSolver. Passing by reference wouldn't allow that.

unique_ptr is really weird when it comes to function arguments.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, thanks for the clarification. Good to know!

Also, this pull request looks good to merge.


/// Get LCP solver
LCPSolver* getLCPSolver() const;

/// Solve constraint impulses and apply them to the skeletons
void solve();

Expand Down