Common Lisp library for manipulating Doom and Quake WAD files and PAK files.
| Revision | 87dd607c039b7d6ef80fc71d1590ea91fc57e8a0 (tree) |
|---|---|
| Time | 2019-12-29 10:35:49 |
| Author | Alexa Jones-Gonzales <alexa@part...> |
| Commiter | Alexa Jones-Gonzales |
Added FIND-UNUSED-TEXTURES
| @@ -316,3 +316,18 @@ | ||
| 316 | 316 | |
| 317 | 317 | (setf (bsp-model-face-id model) (p36:read-bytes-into-int source 4)) |
| 318 | 318 | (setf (bsp-model-origin model) (p36:read-bytes-into-int source 4)))) |
| 319 | + | |
| 320 | +(defmethod find-unused-textures ((bsp bsp-file) &rest ignores) | |
| 321 | + (let ((unused (make-hash-table))) | |
| 322 | + (loop for tdef across (bsp-entry-data (getf (slot-value bsp 'entries) :miptex)) | |
| 323 | + for tdef-num from 0 | |
| 324 | + do (setf (gethash tdef-num unused) (bsp-mip-texture-name tdef))) | |
| 325 | + | |
| 326 | + (loop for tinfo across (bsp-entry-data (getf (slot-value bsp 'entries) :texture-info)) | |
| 327 | + do (when (gethash (bsp-surface-texture-id tinfo) unused) | |
| 328 | + (remhash (bsp-surface-texture-id tinfo) unused))) | |
| 329 | + | |
| 330 | + (loop for v being the hash-values in unused | |
| 331 | + when (and (not (find v ignores :test #'string=)) | |
| 332 | + (not (equal (position #\+ v :test #'char=) 0))) | |
| 333 | + collect v))) |