1. German Larrain
  2. ars

Commits

German Larrain  committed 0a7f5f4

collision.adapters: modified objects constructors to use the new module instead
of calling ODE directly.

  • Participants
  • Parent commits 5ec0ab6
  • Branches dev

Comments (0)

Files changed (1)

File ars/model/collision/adapters.py

View file
  • Ignore whitespace
 import ode
 
 from . import base
+from . import ode_objects_factories
 from .base import NearCallbackArgs
 
 
 
 class Space(base.Space):
 	def __init__(self):
-		# ode.SimpleSpace() is the same as ode.Space(space_type=0)
-		self._inner_object = ode.SimpleSpace()
+		self._inner_object = ode_objects_factories.create_ode_simple_space()
 
 	def collide(self, args, callback=None):
 		if callback is None:
 	def __init__(self, space, length):
 		OdeGeom.__init__(self)
 		base.Ray.__init__(self, space, length)
-		self._inner_object = ode.GeomRay(space.inner_object, length)
+		self._inner_object = ode_objects_factories.create_ode_ray(
+			space.inner_object, length)
 		self._inner_object.outer_object = self  # the encapsulating object
 
 	def get_length(self):
 		OdeGeom.__init__(self)
 		base.Trimesh.__init__(self, space, vertices, faces, center)
 
-		tm_data = ode.TriMeshData()
-		tm_data.build(vertices, faces)
-		self._inner_object = ode.GeomTriMesh(tm_data, space.inner_object)
-		self._inner_object.setPosition(center)
+		self._inner_object = ode_objects_factories.create_ode_trimesh(
+			space.inner_object, vertices, faces)
+		# FIXME: setting pos here is not consistent with the other constructors
+		self.set_position(center)
 
 
 class OdeBasicShape(OdeGeom):
 		OdeBasicShape.__init__(self)
 		base.Box.__init__(self, space, size)
 
-		self._inner_object = ode.GeomBox(space.inner_object, lengths=size)
+		self._inner_object = ode_objects_factories.create_ode_box(
+			space.inner_object, size)
 
 
 class Sphere(OdeBasicShape, base.Sphere):
 		OdeBasicShape.__init__(self)
 		base.Sphere.__init__(self, space, radius)
 
-		self._inner_object = ode.GeomSphere(space.inner_object, radius)
+		self._inner_object = ode_objects_factories.create_ode_sphere(
+			space.inner_object, radius)
 
 
 class Capsule(OdeBasicShape, base.Capsule):
 	"""Capsule shape, aligned along the Z-axis by default"""
 
 	def __init__(self, space, length, radius):
-		# GeomCCylinder: Capped Cylinder
 		OdeBasicShape.__init__(self)
 		base.Capsule.__init__(self, space, length, radius)
 
-		self._inner_object = ode.GeomCCylinder(
-			space.inner_object, radius, length)
+		self._inner_object = ode_objects_factories.create_ode_capsule(
+			space.inner_object, length, radius)
 
 
 class Cylinder(OdeBasicShape, base.Cylinder):
 		OdeBasicShape.__init__(self)
 		base.Cylinder.__init__(self, space, length, radius)
 
-		self._inner_object = ode.GeomCylinder(
-			space.inner_object, radius, length)
+		self._inner_object = ode_objects_factories.create_ode_cylinder(
+			space.inner_object, length, radius)
 
 
 class Plane(OdeBasicShape, base.Plane):
 		OdeBasicShape.__init__(self)
 		base.Plane.__init__(self, space, normal, dist)
 
-		self._inner_object = ode.GeomPlane(
+		self._inner_object = ode_objects_factories.create_ode_plane(
 			space.inner_object, normal, dist)