-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtoolkit.lisp
38 lines (31 loc) · 1.64 KB
/
toolkit.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
27
28
29
30
31
32
33
34
35
36
37
38
(in-package #:org.shirakumo.fraf.manifolds)
(defparameter *dbg-start-time* (get-internal-real-time))
(defun dbg (&rest stuff)
(format *debug-io* "~&MANIFOLDS ~6,2f> ~{~a~^ ~}~%"
(float (/ (- (get-internal-real-time) *dbg-start-time*) internal-time-units-per-second)) stuff))
(defmacro with-specialization ((var typevar &rest expanded-types) &body body)
`(etypecase ,var
,@(loop for type in expanded-types
collect `(,type
,(eval `(let ((,typevar ',type)) ,@body))))))
(defmacro with-vertex-specialization ((var &optional (component-type-var 'vertex-component-type)) &body body)
`(with-specialization (,var type (vertex-array single-float) (vertex-array double-float))
`(let ((,',component-type-var ',(second type)))
(declare (ignorable ,',component-type-var))
,@',body)))
(defmacro with-face-specialization ((var &optional (component-type-var 'face-component-type)) &body body)
`(with-specialization (,var type (face-array (unsigned-byte 16)) (face-array (unsigned-byte 32)))
`(let ((,',component-type-var ',(second type)))
(declare (ignorable ,',component-type-var))
,@',body)))
(declaim (inline simplify unsimplify))
(defun simplify (array)
(declare (type array array))
(make-array (length array) :element-type (array-element-type array)
:initial-contents array))
(defun unsimplify (array)
(declare (type array array))
(make-array (length array) :element-type (array-element-type array)
:initial-contents array
:adjustable T
:fill-pointer T))