~gimaker/peekabot/og3d-caching

« back to all changes in this revision

Viewing changes to src/renderer/entities/OccupancyGrid3D.hh

  • Committer: Staffan Gimåker
  • Date: 2010-06-08 19:53:09 UTC
  • Revision ID: staffan@gimaker.se-20100608195309-sa9qhfcersr182xa
Clean up the 3D occupancy grid code.

Show diffs side-by-side

added added

removed removed

Lines of Context:
63
63
            void set_color_mapping(bool enable, float z_min, float z_max);
64
64
 
65
65
        private:
66
 
            class Batch
67
 
            {
68
 
            public:
69
 
                Batch(
70
 
                    PrepareRenderContext &context, size_t batch_size,
71
 
                    bool use_colors);
72
 
 
73
 
                ~Batch();
74
 
 
75
 
                void add_cube(
76
 
                    double x_c, double y_c, double z_c,
77
 
                    double size,
78
 
                    double r, double g, double b);
79
 
 
80
 
            private:
81
 
                inline void add_quad(
82
 
                    Eigen::Vector3f * &vp,
83
 
                    const Eigen::Vector3f *vertices,
84
 
                    int i0, int i1, int i2, int i3)
85
 
                {
86
 
                    *(vp++) = vertices[i0];
87
 
                    *(vp++) = vertices[i1];
88
 
                    *(vp++) = vertices[i2];
89
 
 
90
 
                    *(vp++) = vertices[i2];
91
 
                    *(vp++) = vertices[i3];
92
 
                    *(vp++) = vertices[i0];
93
 
                }
94
 
 
95
 
                void flush();
96
 
 
97
 
                void allocate_buffers();
98
 
 
99
 
            private:
100
 
                PrepareRenderContext &m_context;
101
 
                const size_t m_batch_size;
102
 
                const bool m_use_colors;
103
 
                size_t m_used;
104
 
                float *m_vertices, *m_colors, *m_normals;
105
 
            };
 
66
            class TraversalContext;
106
67
 
107
68
            class Node
108
69
            {
199
160
                }
200
161
 
201
162
                void render_no_cull(
202
 
                    Batch &batch,
 
163
                    TraversalContext &tc,
203
164
                    const Eigen::Vector3f &center,
204
 
                    float node_size,
205
 
                    const int order[],
206
 
                    bool color_mapping_enabled,
207
 
                    float z_min, float z_max) throw();
 
165
                    float node_size) throw();
208
166
 
209
167
                void render(
210
 
                    Batch &batch,
211
 
                    const Camera &camera,
 
168
                    TraversalContext &tc,
212
169
                    const Eigen::Vector3f &center,
213
170
                    float node_size,
214
 
                    const Frustum &frustum,
215
 
                    const int order[],
216
 
                    int plane_mask,
217
 
                    bool color_mapping_enabled,
218
 
                    float z_min, float z_max) throw();
 
171
                    int plane_mask) throw();
219
172
 
220
173
            private:
221
174
                /**
226
179
                 */
227
180
                static void optimize(Node *node);
228
181
 
229
 
                static void height_to_color(
230
 
                    float z, const float z_min, const float z_max,
231
 
                    float &r, float &g, float &b);
232
 
 
233
182
            public:
234
183
                Node *m_parent;
235
184
 
250
199
            void calculate_bvs() throw();
251
200
 
252
201
        private:
253
 
 
254
 
 
255
202
            /**
256
203
             * \brief The root node of the quad-tree.
257
204
             * \invariant Always non-null (except in the constructor).
261
208
 
262
209
            float m_cell_size;
263
210
 
 
211
            float m_height_factor;
 
212
 
264
213
            float m_root_cell_size;
265
214
 
266
215
            Eigen::Vector3f m_root_cell_center;