Commits

German Larrain  committed f4a6eae

simulator: new class collision.NearCallbackArgs to encapsulate args passed to the 'near_callback' functions; new arg ('ignore_connected') to determine whether connected bodies intersection should be considered collision.

  • Participants
  • Parent commits 3ad6b7e
  • Branches dev-collision-engine

Comments (0)

Files changed (2)

File ars/model/simulator/__init__.py

 				print(e)
 
 			# Detect collisions and create contact joints
-			self._space.collide((self._world, self._contact_group), coll.near_callback)
+			coll_args = coll.NearCallbackArgs(self._world, self._contact_group)
+			self._space.collide(coll_args, coll.near_callback)
 			# Simulation step
 			time_step = self.get_time_step()
 

File ars/model/simulator/collision.py

 	def get_inner_object(self):
 		return self._inner_object
 
-	def collide(self, arg, callback):
-		self._inner_object.collide(arg, callback)
+	def collide(self, args, callback):
+		self._inner_object.collide(args, callback)
+
+class NearCallbackArgs:
+	def __init__(self, world=None, contact_group=None, ignore_connected=True):
+		self.world = world
+		self.contact_group = contact_group
+		self.ignore_connected = ignore_connected
 
 def near_callback(args, geom1, geom2):
 	"""Callback function for the collide() method (in ODE). This function
 	c_joint_bounce = 0.2 # default: 0.2
 	c_joint_mu = 500 # default: 500. 0-5 = very slippery, 50-500 = normal, 5000 = very sticky
 
-	if (ode.areConnected(geom1.getBody(), geom2.getBody())):
-		return
+	if args.ignore_connected:
+		if (ode.areConnected(geom1.getBody(), geom2.getBody())):
+			return
 
+	#===========================================================================
 	# create contact joints
-	world, contact_group = args
+	#===========================================================================
+	#world, contact_group = args
+	world = args.world
+	contact_group = args.contact_group
 
 	# check if the objects collide
 	contacts = ode.collide(geom1, geom2)