ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libgender/entity.C
(Generate patch)

Comparing libgender/entity.C (file contents):
Revision 1.20 by root, Sun Oct 3 09:18:23 2004 UTC vs.
Revision 1.21 by root, Sun Oct 3 20:14:33 2004 UTC

6#include "oct.h" 6#include "oct.h"
7#include "view.h" 7#include "view.h"
8 8
9#include <GL/glext.h> 9#include <GL/glext.h>
10 10
11entity_base::entity_base ()
12{
13 orig.x = orig.y = orig.z = 0;
14}
15
16entity_base::~entity_base ()
17{
18 hide ();
19}
20
11void entity_base::update_bbox () 21void entity_base::update_bbox ()
12{ 22{
13 if (parent) 23 if (parent)
14 parent->update_bbox (); 24 parent->update_bbox ();
15} 25}
20 (*i)->remove (this); 30 (*i)->remove (this);
21 31
22 o.clear (); 32 o.clear ();
23} 33}
24 34
35void entity_base::display (draw_context &ctx)
36{
37 if (ctx.may_draw (this))
38 {
39 glPushMatrix ();
40 glTranslated (-orig.x, -orig.y, -orig.z);
41 draw (ctx);
42 glPopMatrix ();
43 }
44}
45
46/////////////////////////////////////////////////////////////////////////////
47
25void entity_filter::update_bbox () 48void entity_filter::update_bbox ()
26{ 49{
27 bbox = e->bbox; 50 bbox = e->bbox;
28 entity_base::update_bbox (); 51 entity_base::update_bbox ();
29} 52}
30 53
31void entity_filter::show (const sector &sec) 54void entity_filter::show ()
32{ 55{
33 world.add (sec, this); 56 world.add (orig, this);
34 57
35 e->show (sec); 58 e->show ();
36} 59}
37 60
38void entity_filter::draw (draw_context &ctx) 61void entity_filter::draw (draw_context &ctx)
39{ 62{
40 e->try_draw (ctx); 63 e->display (ctx);
41} 64}
42 65
43entity_filter::~entity_filter () 66entity_filter::~entity_filter ()
44{ 67{
45 delete e; 68 delete e;
46} 69}
47 70
48void entity::show (const sector &sec) 71/////////////////////////////////////////////////////////////////////////////
49{
50 show ();
51}
52
53void entity::show ()
54{
55 e->show (this->sec);
56}
57
58void entity::draw (draw_context &ctx)
59{
60 glPushMatrix ();
61 glTranslated (-sec.x, -sec.y, -sec.z);
62 e->try_draw (ctx);
63 glPopMatrix ();
64}
65 72
66void entity_container::update_bbox () 73void entity_container::update_bbox ()
67{ 74{
68 bbox.reset (); 75 bbox.reset ();
69 76
72 (*i)->update_bbox (); 79 (*i)->update_bbox ();
73 bbox.add ((*i)->bbox); 80 bbox.add ((*i)->bbox);
74 } 81 }
75} 82}
76 83
77void entity_container::show (const sector &sec) 84void entity_container::show ()
78{ 85{
79 world.add (sec, this); 86 world.add (orig, this);
80 87
81 for (iterator i = end (); i-- != begin (); ) 88 for (iterator i = end (); i-- != begin (); )
82 (*i)->show (sec); 89 (*i)->show ();
83} 90}
84 91
85void entity_container::draw (draw_context &ctx) 92void entity_container::draw (draw_context &ctx)
86{ 93{
87 for (iterator i = end (); i-- != begin (); ) 94 for (iterator i = end (); i-- != begin (); )
88 (*i)->try_draw (ctx); 95 (*i)->display (ctx);
89} 96}
90 97
91entity_container::~entity_container () 98entity_container::~entity_container ()
92{ 99{
93 hide (); 100 hide ();
95 for (iterator i = end (); i-- != begin (); ) 102 for (iterator i = end (); i-- != begin (); )
96 delete *i; 103 delete *i;
97 104
98 clear (); 105 clear ();
99} 106}
107
108/////////////////////////////////////////////////////////////////////////////
100 109
101template class entity_opengl1d<GL_POINTS>; 110template class entity_opengl1d<GL_POINTS>;
102template class entity_opengl1d<GL_LINES>; 111template class entity_opengl1d<GL_LINES>;
103template class entity_opengl1d<GL_LINE_STRIP>; 112template class entity_opengl1d<GL_LINE_STRIP>;
104template class entity_opengl1d<GL_LINE_LOOP>; 113template class entity_opengl1d<GL_LINE_LOOP>;
185 } 194 }
186 195
187 glCallList (list); 196 glCallList (list);
188} 197}
189 198
190template<GLenum type>
191void entity_opengl1d<type>::show (const sector &sec)
192{
193 world.add (sec, this);
194}
195 199
196template<GLenum type>
197void entity_opengl2d<type>::show (const sector &sec)
198{
199 world.add (sec, this);
200}
201 200
202

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines