ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libgender/oct.C
Revision: 1.3
Committed: Sun Oct 3 03:51:51 2004 UTC (19 years, 8 months ago) by root
Content type: text/plain
Branch: MAIN
Changes since 1.2: +25 -6 lines
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 #include <cstdlib>
2    
3     #include "oct.h"
4 root 1.2 #include "entity.h"
5    
6 root 1.3 octant world(0, 0);
7 root 1.2
8 root 1.3 octant::octant (octant *parent, int subindex)
9 root 1.2 : parent(parent)
10     {
11     for (fill = 8; fill--; )
12     sub[fill] = 0;
13    
14 root 1.3 if (parent)
15     {
16     extent = (parent->extent + 1) >> 1;
17     orig = parent->orig;
18     orig.offset (subindex, extent);
19     }
20     else
21     {
22     extent = MAXEXTENT;
23     orig.x = orig.y = orig.z = SOFFS_MIN;
24     }
25 root 1.2 }
26    
27     octant::~octant ()
28     {
29     for (fill = 8; fill--; )
30     delete sub[fill];
31     }
32    
33 root 1.3 void octant::add (const sector &sec, entity_base *e)
34 root 1.2 {
35 root 1.3 sector orig2;
36     sector extent2;
37    
38     orig2.x = sec.x + (soffs)e->bbox.a.x;
39     orig2.y = sec.y + (soffs)e->bbox.a.y;
40     orig2.z = sec.z + (soffs)e->bbox.a.z;
41    
42     extent2.x = sec.x + (soffs)e->bbox.b.x - orig2.x;
43     extent2.x = sec.y + (soffs)e->bbox.b.y - orig2.y;
44     extent2.x = sec.z + (soffs)e->bbox.b.z - orig2.z;
45    
46 root 1.2 push_back (e);
47     e->o.push_back (this);
48     }
49 root 1.1
50     void octant::remove (entity_base *e)
51     {
52     }
53    
54 root 1.2 void octant::draw (const draw_context &ctx)
55 root 1.1 {
56 root 1.2 for (iterator i = end (); i-- != begin (); )
57     (*i)->draw (ctx);
58 root 1.1 }
59 root 1.2