← Back to team overview

yade-dev team mailing list archive

[Branch ~yade-dev/yade/trunk] Rev 2933: Fix mask-check in several places

 

------------------------------------------------------------
revno: 2933
committer: Anton Gladky <gladky.anton@xxxxxxxxx>
branch nick: yade
timestamp: Mon 2011-10-17 09:33:59 +0200
message:
  Fix mask-check in several places
modified:
  pkg/dem/Shop.cpp
  py/utils.py


--
lp:yade
https://code.launchpad.net/~yade-dev/yade/trunk

Your team Yade developers is subscribed to branch lp:yade.
To unsubscribe from this branch go to https://code.launchpad.net/~yade-dev/yade/trunk/+edit-subscription
=== modified file 'pkg/dem/Shop.cpp'
--- pkg/dem/Shop.cpp	2011-09-02 19:23:13 +0000
+++ pkg/dem/Shop.cpp	2011-10-17 07:33:59 +0000
@@ -283,7 +283,7 @@
 	FOREACH(shared_ptr<Body> b, *scene->bodies){
 		if (!b || !b->isDynamic()) continue;
 		Sphere* s=dynamic_cast<Sphere*>(b->shape.get());
-		if((!s) or ((mask>0) and (mask!=b->groupMask))) continue;
+		if((!s) or ((mask>0) and ((b->groupMask & mask)==0))) continue;
 		vol += (4/3.)*Mathr::PI*pow(s->radius,3);
 	}
 	return vol;
@@ -295,7 +295,7 @@
 	FOREACH(shared_ptr<Body> b, *scene->bodies){
 		if (!b || !b->isDynamic()) continue;
 		Sphere* s=dynamic_cast<Sphere*>(b->shape.get());
-		if((!s) or ((mask>0) and (mask!=b->groupMask))) continue;
+		if((!s) or ((mask>0) and ((b->groupMask & mask)==0))) continue;
 		mass += b->state->mass;
 	}
 	return mass;

=== modified file 'py/utils.py'
--- py/utils.py	2011-07-21 09:10:30 +0000
+++ py/utils.py	2011-10-17 07:33:59 +0000
@@ -780,8 +780,9 @@
 	"""
 	maxD = 0.0
 	minD = 0.0
+	
 	for b in O.bodies:
-		if (isinstance(b.shape,Sphere) and ((mask<0) or (b.mask==mask))):
+		if (isinstance(b.shape,Sphere) and ((mask<0) or ((b.mask&mask)<>0))):
 			if ((2*b.shape.radius)	> maxD) : maxD = 2*b.shape.radius
 			if (((2*b.shape.radius)	< minD) or (minD==0.0)): minD = 2*b.shape.radius
 
@@ -795,7 +796,7 @@
 	
 		
 	for b in O.bodies:
-		if (isinstance(b.shape,Sphere) and ((mask<0) or (b.mask==mask))):
+		if (isinstance(b.shape,Sphere) and ((mask<0) or ((b.mask&mask)<>0))):
 			d=2*b.shape.radius
 			
 			basketId = int(math.floor( (d-minD) / deltaBinD ) )