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

[CollisionModel] New: added collision layer property #4219

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions Sofa/framework/Core/src/sofa/core/CollisionModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,9 @@ bool CollisionModel::canCollideWith(CollisionModel* model)
if (model->getContext() == this->getContext()) // models are in the Node -> is self collision activated?
return bSelfCollision.getValue();

if (model->layer.getValue() != this->layer.getValue()) // no collisions between models in different layers
return false;

const auto& myGroups = this->group.getValue();
if (myGroups.empty()) // a collision model without any group always collides
return true;
Expand Down
3 changes: 3 additions & 0 deletions Sofa/framework/Core/src/sofa/core/CollisionModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -407,6 +407,9 @@ class SOFA_CORE_API CollisionModel : public virtual objectmodel::BaseObject
/// models included in a common group (i.e. sharing a common id)
Data< std::set<int> > group;

// No collision can occur between collision models in different layers
Data<int> layer;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Data<int> layer;
Data<int> d_layer;

Copy link
Contributor

Choose a reason for hiding this comment

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

It also needs to be initialized in the constructor

Copy link
Contributor

Choose a reason for hiding this comment

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

Does it make sense to define more than one layer for a collision model?


/// Number of collision elements
Size size;

Expand Down
Loading