Commits

German Larrain  committed 0171d9e

simulator: new class collision.RayContact; docstrings for NearCallbackArgs

  • Participants
  • Parent commits 647d29d
  • Branches dev-collision-engine

Comments (0)

Files changed (1)

File ars/model/simulator/collision.py

 
 import ode
 
+import ars.model.geometry.base as shapes
+
 class Engine:
 	pass
 
 
 	def collide(self, args, callback):
 		self._inner_object.collide(args, callback)
+	
+	#===========================================================================
+	# def add_ray(self, position, direction):
+	#	"""Adds a ray to the space, whose `_inner_object` will store it"""
+	#	shapes.Ray(self, position, direction) # no need for assignment
+	#===========================================================================
+
+class RayContact:
+	"""Contact information of a collision between a ray and a shape"""
+	
+	def __init__(self, ray=None, shape=None, position=None, normal=None, depth=None):
+		self._ray = ray
+		self._shape = shape
+		self._position = position # point at which the ray intersects the surface of the other geom
+		self._normal = normal # surface normal of the other geom at the contact point
+		self._depth = depth # distance from the start of the ray to the contact point
 
 class NearCallbackArgs:
+	"""Class to encapsulate args passed to the `near_callback` function"""
+	
 	def __init__(self, world=None, contact_group=None, ignore_connected=True):
 		self.world = world
 		self.contact_group = contact_group
 	"""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."""
+	
 	c_joint_bounce = 0.2 # default: 0.2
 	c_joint_mu = 500 # default: 500. 0-5 = very slippery, 50-500 = normal, 5000 = very sticky