← Back to team overview

yade-dev team mailing list archive

[svn] r1701 - trunk/pkg/common/Engine/StandAloneEngine

 

Author: sega
Date: 2009-02-28 22:39:45 +0100 (Sat, 28 Feb 2009)
New Revision: 1701

Modified:
   trunk/pkg/common/Engine/StandAloneEngine/SpatialQuickSortCollider.cpp
   trunk/pkg/common/Engine/StandAloneEngine/SpatialQuickSortCollider.hpp
Log:
Update contact logic for SpatialQuickSortCollider (hope, it's correct)


Modified: trunk/pkg/common/Engine/StandAloneEngine/SpatialQuickSortCollider.cpp
===================================================================
--- trunk/pkg/common/Engine/StandAloneEngine/SpatialQuickSortCollider.cpp	2009-02-28 19:06:57 UTC (rev 1700)
+++ trunk/pkg/common/Engine/StandAloneEngine/SpatialQuickSortCollider.cpp	2009-02-28 21:39:45 UTC (rev 1701)
@@ -14,6 +14,7 @@
 
 SpatialQuickSortCollider::SpatialQuickSortCollider() : BroadInteractor()
 {
+	haveDistantTransient=false;
 }
 
 SpatialQuickSortCollider::~SpatialQuickSortCollider()
@@ -21,11 +22,6 @@
 
 }
 
-void SpatialQuickSortCollider::registerAttributes()
-{
-    BroadInteractor::registerAttributes();
-}
-
 void SpatialQuickSortCollider::action(MetaBody* ncb)
 {
      shared_ptr<BodyContainer> bodies = ncb->bodies;
@@ -61,13 +57,11 @@
 	}
 
 	shared_ptr< InteractionContainer > transientInteractions = ncb->transientInteractions;
-
 	InteractionContainer::iterator ii    = transientInteractions->begin();
 	InteractionContainer::iterator iiEnd = transientInteractions->end();
 	for( ; ii!=iiEnd ; ++ii)
-	   (*ii)->cycle = false;
+		(*ii)->cycle=false;
 
-
 	sort(rank.begin(), rank.end(), xBoundComparator()); // sotring along X
 
 	int id,id2; size_t j;
@@ -80,32 +74,45 @@
 	    j=i;
 	    while(++j<nbElements)
 	    {
-		if ( rank[j]->min[0] < max[0])
-		{
-		    if (   rank[j]->min[1] < max[1]
+			if ( rank[j]->min[0] > max[0]) break;
+			if ( rank[j]->min[1] < max[1]
 			&& rank[j]->max[1] > min[1]
 			&& rank[j]->min[2] < max[2]
 			&& rank[j]->max[2] > min[2])
-		    {
-			id2=rank[j]->id;
-			if ( (interaction = transientInteractions->find(body_id_t(id),body_id_t(id2))) == 0)
 			{
-			    interaction = shared_ptr<Interaction>(new Interaction(id,id2) );
-			    interaction->cycle=true;
-			    transientInteractions->insert(interaction);
+				id2=rank[j]->id;
+				if ( (interaction = transientInteractions->find(body_id_t(id),body_id_t(id2))) == 0)
+				{
+					interaction = shared_ptr<Interaction>(new Interaction(id,id2) );
+					transientInteractions->insert(interaction);
+				}
+				interaction->cycle=true; 
+				// if interaction !isReal it falls back to the potential state
+				if (!haveDistantTransient && !interaction->isReal) interaction->isNew=true;
 			}
-			else
-			    interaction->cycle = true;
-		    }
-		}
-		else break;
 	    }
 	}
 
 	ii    = transientInteractions->begin();
 	iiEnd = transientInteractions->end();
 	for( ; ii!=iiEnd ; ++ii)
-	   if ( !(interaction = *ii)->cycle && !interaction->isReal ) transientInteractions->erase( interaction->getId1(), interaction->getId2());
+	{
+		interaction = *ii;
+		if( 
+			// if haveDistantTransient remove interactions deleted by the constitutive law
+				(haveDistantTransient && !interaction->isNew && !interaction->isReal)
+			// if !haveDistantTransient remove interactions without AABB overlapping
+				|| (!haveDistantTransient && !interaction->cycle) 
+		) { 
+			transientInteractions->erase( interaction->getId1(), interaction->getId2() ); 
+			continue; 
+		}
+		// Once the interaction has been fully created, it is not "new" anymore
+		if(interaction->isReal) interaction->isNew=false;
+		// For non-distant interactions reset isReal (it would be calculated later);
+		// for distant interactions isReal is set/unset by constitutive law
+		if(!haveDistantTransient) interaction->isReal=false;
+	}
 
 }
 

Modified: trunk/pkg/common/Engine/StandAloneEngine/SpatialQuickSortCollider.hpp
===================================================================
--- trunk/pkg/common/Engine/StandAloneEngine/SpatialQuickSortCollider.hpp	2009-02-28 19:06:57 UTC (rev 1700)
+++ trunk/pkg/common/Engine/StandAloneEngine/SpatialQuickSortCollider.hpp	2009-02-28 21:39:45 UTC (rev 1701)
@@ -31,8 +31,6 @@
 
 	vector<shared_ptr<AABBBound> > rank;
 
-	void registerAttributes();
-
     public:
 
 	SpatialQuickSortCollider();
@@ -41,6 +39,15 @@
 	virtual void action(MetaBody*);
 
 
+	//! Don't break transient interaction once bodies don't overlap anymore; material law will be responsible for breaking it.
+	bool haveDistantTransient;
+
+	void registerAttributes() {
+		BroadInteractor::registerAttributes();
+		REGISTER_ATTRIBUTE(haveDistantTransient);
+	}
+
+	DECLARE_LOGGER;
 	REGISTER_CLASS_NAME(SpatialQuickSortCollider);
 	REGISTER_BASE_CLASS_NAME(BroadInteractor);