Commits

German Larrain committed 580ecc2

collision.base.Engine: added class abstract methods '{process, process_ray}_collision_contacts'.

Comments (0)

Files changed (1)

ars/model/collision/base.py

 		raise NotImplementedError()
 
 	@classmethod
+	def process_collision_contacts(cls, args, geom1, geom2, contacts):
+		"""Process ``contacts`` of a collision between ``geom1`` and ``geom2``.
+
+		This method should create movement constraints for the bodies
+		attached to the geoms. This is necessary for the simulation to
+		prevent bodies' volumes from penetrating each other, making them
+		really collide (i.e. exert mutually opposing forces).
+
+		.. warning::
+		   Neither ``geom1`` nor ``geom2`` can be rays. If one of them is,
+		   use method :meth:`process_ray_collision_contacts`.
+
+		:param args:
+		:type args: :class:`NearCallbackArgs`
+		:param geom1:
+		:type geom1: type of :attr:`Geom.inner_object`
+		:param geom2:
+		:type geom2: type of :attr:`Geom.inner_object`
+		:param contacts: collision data returned by :meth:`calc_collision`
+		:type contacts: list of contact data objects
+
+		"""
+		# Like :meth:`calc_collision`, this is a @abtractclassmethod too.
+		raise NotImplementedError()
+
+	@classmethod
+	def process_ray_collision_contacts(cls, ray, other_geom, contacts):
+		"""Process special case of collision between a ray and a regular geom.
+
+		.. seealso::
+		   For regular geoms collision, see :meth:`process_collision_contacts`.
+
+		Since rays have no attached body, they can't "really" collide
+		with other geoms. However, they do intersect, which is of
+		interest to non-physical aspects of the simulation. A common
+		use case is that of laser distance sensors.
+
+		.. warning::
+		   Collision between two rays is a singularity and should never happen.
+
+		:param ray:
+		:type ray: type of :attr:`Ray.inner_object`
+		:param other_geom:
+		:type other_geom: type of :attr:`Geom.inner_object`
+		:param contacts: collision data returned by :meth:`calc_collision`
+		:type contacts: list of contact data objects
+
+		"""
+		# Like :meth:`calc_collision`, this is an @abtractclassmethod too.
+		raise NotImplementedError()
+
+	@classmethod
 	def are_geoms_connected(cls, geom1, geom2):
 		"""Return whether ``geom1``'s body is connected to ``geom2``'s body.