-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathray.lisp
27 lines (18 loc) · 897 Bytes
/
ray.lisp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
(in-package #:cl-ode)
(declaim (optimize (speed 3)))
(create-pointer-subclass ray dRayID geometry dGeomID)
(defmethod close-callback ((this ray) (that geometry))
;; no need for bodies here...
(with-foreign-object (contact '(:struct Contact-struct) *default-max-contacts*)
(let* ((geom (cffi:foreign-slot-pointer contact '(:struct ode::contact-struct) 'geom)))
(let ((num-contacts (collide this
that
*default-max-contacts*
geom
(cffi:foreign-type-size '(:struct contact-struct)))))
(unless (zerop num-contacts)
(values (cffi:foreign-slot-value geom '(:struct contact-geometry-struct) 'depth)
(cffi:foreign-slot-value geom '(:struct contact-geometry-struct) 'pos)
(cffi:foreign-slot-value geom '(:struct contact-geometry-struct) 'normal)))))))
(defmethod close-callback ((this geometry) (that ray))
(close-callback that this))