1 |
– |
/* Copyright (c) 1986 Regents of the University of California */ |
2 |
– |
|
1 |
|
#ifndef lint |
2 |
< |
static char SCCSid[] = "$SunId$ LBL"; |
2 |
> |
static const char RCSid[] = "$Id$"; |
3 |
|
#endif |
6 |
– |
|
4 |
|
/* |
5 |
|
* octree.c - routines dealing with octrees and cubes. |
9 |
– |
* |
10 |
– |
* 7/28/85 |
6 |
|
*/ |
7 |
|
|
8 |
+ |
#include "copyright.h" |
9 |
+ |
|
10 |
|
#include "standard.h" |
11 |
|
|
12 |
|
#include "octree.h" |
13 |
|
|
14 |
|
OCTREE *octblock[MAXOBLK]; /* our octree */ |
15 |
< |
static OCTREE ofreelist = EMPTY; /* free octree nodes */ |
15 |
> |
static OCTREE ofreelist = EMPTY; /* freed octree nodes */ |
16 |
|
static OCTREE treetop = 0; /* next free node */ |
17 |
|
|
18 |
|
|
31 |
|
if (octbi(freet) >= MAXOBLK) |
32 |
|
return(EMPTY); |
33 |
|
if ((octblock[octbi(freet)] = (OCTREE *)malloc( |
34 |
< |
(unsigned)256*8*sizeof(OCTREE))) == NULL) |
34 |
> |
(unsigned)OCTBLKSIZ*8*sizeof(OCTREE))) == NULL) |
35 |
|
return(EMPTY); |
36 |
|
} |
37 |
|
treetop += 8; |
39 |
|
} |
40 |
|
|
41 |
|
|
42 |
+ |
void |
43 |
|
octfree(ot) /* free an octree */ |
44 |
|
register OCTREE ot; |
45 |
|
{ |
54 |
|
} |
55 |
|
|
56 |
|
|
57 |
+ |
void |
58 |
+ |
octdone() /* free EVERYTHING */ |
59 |
+ |
{ |
60 |
+ |
register int i; |
61 |
+ |
|
62 |
+ |
for (i = 0; i < MAXOBLK; i++) { |
63 |
+ |
if (octblock[i] == NULL) |
64 |
+ |
break; |
65 |
+ |
free((void *)octblock[i]); |
66 |
+ |
octblock[i] = NULL; |
67 |
+ |
} |
68 |
+ |
ofreelist = EMPTY; |
69 |
+ |
treetop = 0; |
70 |
+ |
} |
71 |
+ |
|
72 |
+ |
|
73 |
|
OCTREE |
74 |
|
combine(ot) /* recursively combine nodes */ |
75 |
|
register OCTREE ot; |
83 |
|
for (i = 1; i < 8; i++) |
84 |
|
if ((octkid(ot, i) = combine(octkid(ot, i))) != ores) |
85 |
|
ores = ot; |
86 |
< |
if (!istree(ores)) /* all were identical leaves */ |
87 |
< |
octfree(ot); |
86 |
> |
if (!istree(ores)) { /* all were identical leaves */ |
87 |
> |
octkid(ot, 0) = ofreelist; |
88 |
> |
ofreelist = ot; |
89 |
> |
} |
90 |
|
return(ores); |
91 |
|
} |
92 |
|
|
93 |
|
|
94 |
+ |
void |
95 |
|
culocate(cu, pt) /* locate point within cube */ |
96 |
|
register CUBE *cu; |
97 |
|
register FVECT pt; |
112 |
|
} |
113 |
|
|
114 |
|
|
115 |
+ |
void |
116 |
|
cucopy(cu1, cu2) /* copy cu2 into cu1 */ |
117 |
|
register CUBE *cu1, *cu2; |
118 |
|
{ |
122 |
|
} |
123 |
|
|
124 |
|
|
125 |
+ |
int |
126 |
|
incube(cu, pt) /* determine if a point is inside a cube */ |
127 |
|
register CUBE *cu; |
128 |
|
register FVECT pt; |