Home › Forum › SOFA › Using SOFA › [SOLVED] Collision groups
Tagged: 64_bits, Linux_ubuntu, SOFA_1712
- This topic has 3 replies, 2 voices, and was last updated 6 years, 8 months ago by Noura.
-
AuthorPosts
-
10 April 2018 at 17:50 #10770NouraBlocked
Hi all,
My question is related to the collision groups.
We are planning to use them in order to reduce the collision detection complexity by avoiding unnecessary tests between objects which are not likely to collide during the simulation.According to our understanding, objects which are not likely to collide should belong to the same collision group whereas objects which we would like to test their collision must belong to different collision groups.
Here is an example:
Having 4 objects A, B, C and D. Let’s assume that A and B may collide, C and D may collide, while C and D will never collide with A or B.
We need at least 4 groups:
Group 1 : A & C
Group 2 : B & C
Group 3 : A & D
Group 4 : B & D
Is that the correct way to group them?If yes, we think that it would probably be much more easier to place the objects which are likely to collide in the same group, this will ease the process of grouping objects together.
In the previous example, only 2 groups are required instead of 4:
Group 1 : A & B
Group 2 : C & DIt’s not a big deal when having only 4 objects, but when it comes to a scene with 40 objects, it becomes much more complicated.
– Is there a reason why collision groups are designed this way in SOFA?
– Is it possible to set the groups the opposite way (place objects which collide in the same collision group)?Any hint to another way to test collision would be very helpful.
Thanks,
Noura
18 April 2018 at 16:57 #10781BineshBlockedHi @Noura
yes of course , your idea is good
i implemented and modified collision detection 1 years ago
This idea is “Reverse Grouping” in my codes
after reverse grouping i used new Data “Target” for apply collision to same target
This is very easy and you can change the canCollideWith FunctionGood Luck
Behnam Binesh
18 April 2018 at 18:03 #10784NouraBlockedHi @Binesh
A quick modification according to your hint in
CollisionModel.h
seems to change the grouping as desired “Reverse Grouping”.I didn’t verified enough if this will lead to an odd behavior but for now it’s perfect!
Thanks!
Noura
18 April 2018 at 18:05 #10785NouraBlockedI include the modified function just in case someone would like to try it.
virtual bool canCollideWith(CollisionModel* model) { if (model->getContext() == this->getContext()) // models are in the Node -> is self collision activated? return bSelfCollision.getValue(); else if( this->group.getValue().empty() || model->group.getValue().empty() ) // one model has no group -> always collide return true; else { std::set<int>::const_iterator it = group.getValue().begin(), itend = group.getValue().end(); for( ; it != itend ; ++it ) if( model->group.getValue().count(*it)>0 ) // both models are included in the same group -> do not collide return true; return false; } }
-
AuthorPosts
- You must be logged in to reply to this topic.