@@ -507,18 +507,18 @@ cdef class DynamicAABBTreeCollisionManager:
507507 else :
508508 raise ValueError
509509
510- # def distance(self, *args):
511- # if len(args) == 2 and inspect.isroutine(args[1]):
512- # fn = DistanceFunction(args[1], args[0])
513- # self.thisptr.distance(<void*> fn, DistanceCallBack)
514- # elif len(args) == 3 and isinstance(args[0], DynamicAABBTreeCollisionManager):
515- # fn = DistanceFunction(args[2], args[1])
516- # self.thisptr.distance((<DynamicAABBTreeCollisionManager?> args[0]).thisptr, <void*> fn, DistanceCallBack)
517- # elif len(args) == 3 and inspect.isroutine(args[2]):
518- # fn = DistanceFunction(args[2], args[1])
519- # self.thisptr.distance((<CollisionObject?> args[0]).thisptr, <void*> fn, DistanceCallBack)
520- # else:
521- # raise ValueError
510+ def distance (self , *args ):
511+ if len (args) == 2 and inspect.isroutine(args[1 ]):
512+ fn = DistanceFunction(args[1 ], args[0 ])
513+ self .thisptr.distance(< void * > fn, DistanceCallBack)
514+ elif len (args) == 3 and isinstance (args[0 ], DynamicAABBTreeCollisionManager):
515+ fn = DistanceFunction(args[2 ], args[1 ])
516+ self .thisptr.distance((< DynamicAABBTreeCollisionManager?> args[0 ]).thisptr, < void * > fn, DistanceCallBack)
517+ elif len (args) == 3 and inspect.isroutine(args[2 ]):
518+ fn = DistanceFunction(args[2 ], args[1 ])
519+ self .thisptr.distance((< CollisionObject?> args[0 ]).thisptr, < void * > fn, DistanceCallBack)
520+ else :
521+ raise ValueError
522522
523523 def clear (self ):
524524 self .thisptr.clear()
@@ -637,31 +637,31 @@ def continuousCollide(CollisionObject o1, Transform tf1_end,
637637 result.time_of_contact = min (cresult.time_of_contact, result.time_of_contact)
638638 return ret
639639
640- # def distance(CollisionObject o1, CollisionObject o2,
641- # request = None, result=None):
642- #
643- # if request is None:
644- # request = DistanceRequest()
645- # if result is None:
646- # result = DistanceResult()
647- #
648- # cdef defs.DistanceResultd cresult
649- #
650- # cdef double dis = defs.distance(o1.thisptr, o2.thisptr,
651- # defs.DistanceRequestd(
652- # <bool?> request.enable_nearest_points,
653- # <defs.GJKSolverType?> request.gjk_solver_type
654- # ),
655- # cresult)
656- #
657- # result.min_distance = min(cresult.min_distance, result.min_distance)
658- # result.nearest_points = [vec3d_to_numpy(cresult.nearest_points[0]),
659- # vec3d_to_numpy(cresult.nearest_points[1])]
660- # result.o1 = c_to_python_collision_geometry(cresult.o1, o1, o2)
661- # result.o2 = c_to_python_collision_geometry(cresult.o2, o1, o2)
662- # result.b1 = cresult.b1
663- # result.b2 = cresult.b2
664- # return dis
640+ def distance (CollisionObject o1 , CollisionObject o2 ,
641+ request = None , result = None ):
642+
643+ if request is None :
644+ request = DistanceRequest()
645+ if result is None :
646+ result = DistanceResult()
647+
648+ cdef defs.DistanceResultd cresult
649+
650+ cdef double dis = defs.distance(o1.thisptr, o2.thisptr,
651+ defs.DistanceRequestd(
652+ < bool ?> request.enable_nearest_points,
653+ < defs.GJKSolverType?> request.gjk_solver_type
654+ ),
655+ cresult)
656+
657+ result.min_distance = min (cresult.min_distance, result.min_distance)
658+ result.nearest_points = [vec3d_to_numpy(cresult.nearest_points[0 ]),
659+ vec3d_to_numpy(cresult.nearest_points[1 ])]
660+ result.o1 = c_to_python_collision_geometry(cresult.o1, o1, o2)
661+ result.o2 = c_to_python_collision_geometry(cresult.o2, o1, o2)
662+ result.b1 = cresult.b1
663+ result.b2 = cresult.b2
664+ return dis
665665
666666# ##############################################################################
667667# Collision and Distance Callback Functions
@@ -687,9 +687,9 @@ def defaultDistanceCallback(CollisionObject o1, CollisionObject o2, cdata):
687687
688688 if cdata.done:
689689 return True , result.min_distance
690- #
691- # distance(o1, o2, request, result)
692- #
690+
691+ distance(o1, o2, request, result)
692+
693693 dist = result.min_distance
694694
695695 if dist <= 0 :
0 commit comments