German Larrain committed 3a77907

collision.adapters.Engine: changed type from static to class the methods
'near_callback', 'are_geoms_connected', 'is_ray', 'handle_ray_collision'.

  • Participants
  • Parent commits 8a4d062

Comments (0)

Files changed (1)


 	# Functions and methods not overriding base class functions and methods
-	@staticmethod
-	def near_callback(args, geom1, geom2):
+	@classmethod
+	def near_callback(cls, args, geom1, geom2):
 		"""Callback function for the collide() method (in ODE). This function
 		checks if the given geoms do collide and creates contact joints (c_joint)
 		if they do, except if they are connected."""
 		ray_geom = None
 		other_geom = None
-		if args.ignore_connected and Engine.are_geoms_connected(geom1,
-			geom2):
+		if args.ignore_connected and cls.are_geoms_connected(geom1, geom2):
 		# Ray's special case
-		if Engine.is_ray(geom1):
-			if Engine.is_ray(geom2):
+		if cls.is_ray(geom1):
+			if cls.is_ray(geom2):
 				print('Weird, ODE says two rays may collide. '
 				      'That case is not handled.')
 				ray_geom = geom1
 				other_geom = geom2
-		elif Engine.is_ray(geom2):
+		elif cls.is_ray(geom2):
 			ray_geom = geom2
 			other_geom = geom1
 		for c in contacts:
 			if ray_geom is not None:
-				Engine.handle_ray_collision(ray_geom, other_geom, c)
+				cls.handle_ray_collision(ray_geom, other_geom, c)
 			else:  # we create a ContactJoint only if both geoms are not rays
 				# set contact parameters
 				j = ode.ContactJoint(world, contact_group, c)
 				j.attach(geom1.getBody(), geom2.getBody())
-	@staticmethod
-	def are_geoms_connected(geom1, geom2):
+	@classmethod
+	def are_geoms_connected(cls, geom1, geom2):
 		"""Are `geom1` and `geom2` connected (through the bodies they are
 		attached to)?
 		return ode.areConnected(geom1.getBody(), geom2.getBody())
-	@staticmethod
-	def is_ray(geom):
+	@classmethod
+	def is_ray(cls, geom):
 		"""Return whether ``geom`` is a :class:`ode.GeomRay` object or not.
 		:param geom:
 		return isinstance(geom, ode.GeomRay)
-	@staticmethod
-	def handle_ray_collision(ray, other_geom, contact):
+	@classmethod
+	def handle_ray_collision(cls, ray, other_geom, contact):
 		# pos: intersection position
 		# depth: distance
 		(pos, normal, depth, geom1, geom2) = contact.getContactGeomParams()