ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/src/rt/oocmorton.c
Revision: 2.1
Committed: Tue May 17 17:39:47 2016 UTC (8 years ago) by rschregle
Content type: text/plain
Branch: MAIN
Log Message:
Initial import of ooC photon map

File Contents

# User Rev Content
1 rschregle 2.1 /*
2     =========================================================================
3     Routines to generate and compare Morton Codes, i.e. indices on space
4     filling Z-curves.
5    
6     Roland Schregle (roland.schregle@{hslu.ch, gmail.com})
7     (c) Lucerne University of Applied Sciences and Arts,
8     supported by the Swiss National Science Foundation (SNSF, #147053)
9     =========================================================================
10    
11     $Id: oocmorton.c,v 1.2 2015/11/02 17:30:05 taschreg Exp taschreg $
12     */
13    
14    
15    
16     #include "oocmorton.h"
17    
18    
19    
20     OOC_MortonIdx OOC_Key2Morton (const FVECT key, const FVECT org, RREAL scale)
21     /* Compute Morton code (Z-curve index) of length 3 * OOC_MORTON_BITS bits
22     * for 3D key within bounding box defined by org and scaled to maximum index
23     * with scale */
24     {
25     unsigned i;
26     OOC_MortonIdx k [3];
27    
28     /* Normalise key and map each dim to int of OOC_MORTON_BITS */
29     for (i = 0; i < 3; i++)
30     k [i] = scale * (key [i] - org [i]);
31    
32     /* Interleave each dim with zeros and merge */
33     return OOC_BitInterleave(k [0]) | OOC_BitInterleave(k [1]) << 1 |
34     OOC_BitInterleave(k [2]) << 2;
35     }