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

Fixes collision problem #668

Merged
merged 1 commit into from
Apr 14, 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
7 changes: 7 additions & 0 deletions dart/constraint/ConstraintSolver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,10 @@ LCPSolver* ConstraintSolver::getLCPSolver() const
void ConstraintSolver::solve()
{
for (size_t i = 0; i < mSkeletons.size(); ++i)
{
mSkeletons[i]->clearConstraintImpulses();
mSkeletons[i]->clearCollidingBodies();
}

// Update constraints and collect active constraints
updateConstraints();
Expand Down Expand Up @@ -394,6 +397,10 @@ void ConstraintSolver::updateConstraints()
{
auto& ct = mCollisionResult.getContact(i);

// Set colliding bodies
const_cast<dynamics::ShapeFrame*>(ct.collisionObject1->getShapeFrame())->asShapeNode()->getBodyNodePtr()->setColliding(true);
const_cast<dynamics::ShapeFrame*>(ct.collisionObject2->getShapeFrame())->asShapeNode()->getBodyNodePtr()->setColliding(true);

if (isSoftContact(ct))
{
mSoftContactConstraints.push_back(
Expand Down
3 changes: 3 additions & 0 deletions dart/dynamics/MetaSkeleton.h
Original file line number Diff line number Diff line change
Expand Up @@ -537,6 +537,9 @@ class MetaSkeleton : public common::Subject
/// Get the potential energy of this MetaSkeleton
virtual double getPotentialEnergy() const = 0;

/// Clear collision flags of the BodyNodes in this MetaSkeleton
virtual void clearCollidingBodies() = 0;

/// \}

//----------------------------------------------------------------------------
Expand Down
11 changes: 11 additions & 0 deletions dart/dynamics/ReferentialSkeleton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,17 @@ double ReferentialSkeleton::getPotentialEnergy() const
return PE;
}

//==============================================================================
void ReferentialSkeleton::clearCollidingBodies()
{
for(size_t i = 0; i < this->getNumBodyNodes(); i++)
{
auto bd = this->getBodyNode(i);
if(bd)
bd->setColliding(false);
}
}

//==============================================================================
Eigen::Vector3d ReferentialSkeleton::getCOM(const Frame* _withRespectTo) const
{
Expand Down
3 changes: 3 additions & 0 deletions dart/dynamics/ReferentialSkeleton.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,9 @@ class ReferentialSkeleton : public MetaSkeleton
// Documentation inherited
double getPotentialEnergy() const override;

// Documentation inherited
void clearCollidingBodies() override;

/// \}

//----------------------------------------------------------------------------
Expand Down
11 changes: 11 additions & 0 deletions dart/dynamics/Skeleton.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3613,6 +3613,17 @@ double Skeleton::getPotentialEnergy() const
return PE;
}

//==============================================================================
void Skeleton::clearCollidingBodies()
{
for(size_t i = 0; i < this->getNumBodyNodes(); i++)
{
auto bd = this->getBodyNode(i);
if(bd)
bd->setColliding(false);
}
}

//==============================================================================
Eigen::Vector3d Skeleton::getCOM(const Frame* _withRespectTo) const
{
Expand Down
3 changes: 3 additions & 0 deletions dart/dynamics/Skeleton.h
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,9 @@ class Skeleton :
// Documentation inherited
double getPotentialEnergy() const override;

// Documentation inherited
void clearCollidingBodies() override;

/// \}

//----------------------------------------------------------------------------
Expand Down