Example #1
0
void Serializer::check(SerializedScene& output,
                       SceneGraph const& scene_graph,
                       std::string const& render_mask,
                       bool draw_bounding_boxes,
                       bool draw_rays,
                       bool enable_frustum_culling) {

  data_ = &output;


  std::size_t geometry_count = data_->geometrynodes_.size();
  std::size_t volume_count = data_->volumenodes_.size();
  std::size_t point_light_count = data_->point_lights_.size();
  std::size_t spot_light_count = data_->spot_lights_.size();
  std::size_t sun_light_count = data_->sun_lights_.size();
  std::size_t ray_count = data_->rays_.size();
  std::size_t textured_quad_count = data_->textured_quads_.size();

  data_->geometrynodes_.clear();
  data_->volumenodes_.clear();
  data_->point_lights_.clear();
  data_->spot_lights_.clear();
  data_->sun_lights_.clear();
  data_->textured_quads_.clear();

  data_->bounding_boxes_.clear();
  data_->rays_.clear();
  draw_bounding_boxes_ = draw_bounding_boxes;
  draw_rays_ = draw_rays;

  if (draw_bounding_boxes_) {
    data_->materials_.insert("gua_bounding_box");
    data_->bounding_boxes_.reserve(geometry_count + point_light_count + spot_light_count + ray_count);
  }

  if (draw_rays_) {
    data_->materials_.insert("gua_bounding_box");
    data_->rays_.reserve(ray_count);
  }

  data_->materials_.insert("gua_textured_quad");

  // assuming the number of nodes stays quite constant through time,
  // reserving the old size might save some time

  data_->volumenodes_.reserve(volume_count);
  data_->point_lights_.reserve(point_light_count);
  data_->spot_lights_.reserve(spot_light_count);
  data_->sun_lights_.reserve(sun_light_count);
  data_->textured_quads_.reserve(textured_quad_count);

  enable_frustum_culling_ = enable_frustum_culling;

  current_render_mask_ = Mask(render_mask);
  current_frustum_ = output.frustum;
  current_center_of_interest_ = output.center_of_interest;

  scene_graph.accept(*this);
}