ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libgender/entity.C
Revision: 1.1
Committed: Sat Oct 2 15:54:43 2004 UTC (21 years, 11 months ago) by root
Content type: text/plain
Branch: MAIN
Log Message:
*** empty log message ***

File Contents

# User Rev Content
1 root 1.1 #include <algorithm>
2    
3     using namespace std;
4    
5     #include "entity.h"
6    
7     void box::add (const box &o)
8     {
9     a.x = min (a.x, o.a.x);
10     a.y = min (a.y, o.a.y);
11     a.z = min (a.z, o.a.z);
12     b.x = max (b.x, o.b.x);
13     b.y = max (b.y, o.b.y);
14     b.z = max (b.z, o.b.z);
15     }
16    
17     void entity_base::update_bbox ()
18     {
19     if (parent)
20     parent->update_bbox ();
21     }
22    
23     void entity_base::hide ()
24     {
25     for (vector<octant *>::iterator i = o.end (); i-- != o.begin (); )
26     (*i)->remove (this);
27    
28     o.clear ();
29     }
30    
31     void entity_filter::update_bbox ()
32     {
33     bbox = e->bbox;
34     entity_base::update_bbox ();
35     }
36    
37     void entity_filter::show (const sector &sec)
38     {
39     e->show (sec);
40     }
41    
42     void entity_filter::draw ()
43     {
44     e->draw ();
45     }
46    
47     entity_filter::~entity_filter ()
48     {
49     delete e;
50     }
51    
52     void entity::show (const sector &sec)
53     {
54     e->show (this->sec);
55     }
56    
57     void entity::draw ()
58     {
59     //TODO setup matrix etc.
60     e->draw ();
61     }
62    
63     void entity_container::update_bbox ()
64     {
65     bbox.reset ();
66    
67     for (iterator i = end (); i-- != begin (); )
68     {
69     (*i)->update_bbox ();
70     bbox.add ((*i)->bbox);
71     }
72     }
73    
74     void entity_container::show (const sector &sec)
75     {
76     for (iterator i = end (); i-- != begin (); )
77     (*i)->show (sec);
78     }
79    
80     void entity_container::draw ()
81     {
82     for (iterator i = end (); i-- != begin (); )
83     (*i)->draw ();
84     }
85    
86     entity_container::~entity_container ()
87     {
88     hide ();
89    
90     for (iterator i = end (); i-- != begin (); )
91     delete *i;
92    
93     clear ();
94     }
95    
96