Skip to content

Commit 1178263

Browse files
committed
- add comment why we check boundp *collision-algorithm-{pqp,bullet}* before defvar *collision-algorithm*
- setmargin of bullet only works with mesh model to add margin for primitive geometry shape, set directory as geometric parameters
1 parent 51a9f9c commit 1178263

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

irteus/bullet.l

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,26 @@
3030
(export '(bt-collision-distance bt-collision-check))
3131

3232
(defun bt-make-model-from-body
33-
(b &key (csg (send b :csg)) (margin nil))
33+
(b &key (csg (send b :csg)) (margin 0))
3434
"Make bullet model from body."
3535
(let (m)
3636
(cond ((assoc :sphere csg)
3737
(setq m
3838
(btmakespheremodel
39-
(* 1e-3 (user::radius-of-sphere b)))
39+
(* 1e-3 (+ (user::radius-of-sphere b) margin)))
4040
))
4141
((assoc :cube csg)
4242
(setq m
4343
(btmakeboxmodel
44-
(* 1e-3 (user::x-of-cube b))
45-
(* 1e-3 (user::y-of-cube b))
46-
(* 1e-3 (user::z-of-cube b))
44+
(* 1e-3 (+ (user::x-of-cube b) (* margin 2)))
45+
(* 1e-3 (+ (user::y-of-cube b) (* margin 2)))
46+
(* 1e-3 (+ (user::z-of-cube b) (* margin 2)))
4747
)))
4848
((assoc :cylinder csg)
4949
(setq m
5050
(btmakecylindermodel
51-
(* 1e-3 (user::radius-of-cylinder b))
52-
(* 1e-3 (user::height-of-cylinder b))
51+
(* 1e-3 (+ (user::radius-of-cylinder b) margin))
52+
(* 1e-3 (+ (user::height-of-cylinder b) margin))
5353
)))
5454
(t
5555
(setq m
@@ -59,9 +59,8 @@
5959
(mapcar #'(lambda (v) (send b :inverse-transform-vector v)) (send b :vertices))))
6060
(length (send b :vertices))
6161
))
62+
(if (> margin 0) (btsetmargin m (* 1e-3 margin)))
6263
))
63-
(when margin
64-
(btsetmargin m margin))
6564
m)
6665
)
6766

irteus/irtcollision.l

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
(require :pqp)
2828
(require :bullet)
2929

30+
;; set *collision-algorithm* from available libraries.
31+
;; need to cehck if *collision-algorithm-pqp*/*collision-algorithm-bullet* exists, becuase it does not defined during compile time
3032
(if (and (boundp '*collision-algorithm-pqp*) (boundp '*collision-algorithm-bullet*))
3133
(defvar *collision-algorithm* (or *collision-algorithm-pqp* *collision-algorithm-bullet*)))
3234

0 commit comments

Comments
 (0)