<commit_before>#include "State.h"
#include "Globals.h"
#include "Render.h"
#include <atomic>
#include <memory>
#include <sstream>
#include <thread>

using namespace glm;

State::State(std::string name, SDL_Window *window, ivec2 window_size)
    : state_name(name), window(window), renderer(window, window_size)
{
  SDL_SetRelativeMouseMode(SDL_bool(true));
  reset_mouse_delta();
}

void State::prepare_renderer(double t)
{
  // frustrum cull using primitive bounding volumes
  // determine which lights affect which objects

  /*Light diameter guideline for deferred rendering (not yet used)
  Distance 	Constant 	Linear 	Quadratic
7 	1.0 	0.7 	1.8
13 	1.0 	0.35 	0.44
20 	1.0 	0.22 	0.20
32 	1.0 	0.14 	0.07
50 	1.0 	0.09 	0.032
65 	1.0 	0.07 	0.017
100 	1.0 	0.045 	0.0075
160 	1.0 	0.027 	0.0028
200 	1.0 	0.022 	0.0019
325 	1.0 	0.014 	0.0007
600 	1.0 	0.007 	0.0002
3250 	1.0 	0.0014 	0.000007

  */

  // camera must be set before entities, or they get a 1 frame lag
  renderer.set_camera(cam.pos, cam.dir);

  // Traverse graph nodes and submit to renderer for packing:
  auto render_entities = scene.visit_nodes_st_start();
  renderer.set_render_entities(&render_entities);
  renderer.set_lights(scene.lights);
  renderer.clear_color = clear_color;
}

void State::reset_mouse_delta()
{
  ivec2 mouse_delta;
  SDL_GetRelativeMouseState(&mouse_delta.x, &mouse_delta.y);
}

void State::render(float64 t)
{
  prepare_renderer(t);
  renderer.render(t);
}

void State::performance_output()
{<commit_msg>add TODO<commit_after>#include "State.h"
#include "Globals.h"
#include "Render.h"
#include <atomic>
#include <memory>
#include <sstream>
#include <thread>

using namespace glm;

State::State(std::string name, SDL_Window *window, ivec2 window_size)
    : state_name(name), window(window), renderer(window, window_size)
{
  SDL_SetRelativeMouseMode(SDL_bool(true));
  reset_mouse_delta();
}

void State::prepare_renderer(double t)
{
  // frustrum cull using primitive bounding volumes
  // determine which lights affect which objects

  /*Light diameter guideline for deferred rendering (not yet used)
  Distance 	Constant 	Linear 	Quadratic
7 	1.0 	0.7 	1.8
13 	1.0 	0.35 	0.44
20 	1.0 	0.22 	0.20
32 	1.0 	0.14 	0.07
50 	1.0 	0.09 	0.032
65 	1.0 	0.07 	0.017
100 	1.0 	0.045 	0.0075
160 	1.0 	0.027 	0.0028
200 	1.0 	0.022 	0.0019
325 	1.0 	0.014 	0.0007
600 	1.0 	0.007 	0.0002
3250 	1.0 	0.0014 	0.000007

  */

  // camera must be set before entities, or they get a 1 frame lag
  renderer.set_camera(cam.pos, cam.dir);

  // Traverse graph nodes and submit to renderer for packing:

  // TODO: add simple bounding colliders assignable to each node_ptr
  //       add a node_ptr to render_entity to point back to the owner
  //       octree for triangle data to optimize collision
  auto render_entities = scene.visit_nodes_st_start();
  renderer.set_render_entities(&render_entities);
  renderer.set_lights(scene.lights);
  renderer.clear_color = clear_color;
}

void State::reset_mouse_delta()
{
  ivec2 mouse_delta;
  SDL_GetRelativeMouseState(&mouse_delta.x, &mouse_delta.y);
}

void State::render(float64 t)
{
  prepare_renderer(t);
  renderer.render(t);
}

void State::performance_output()
{
{'fraction_non_alphanumeric': 0.11014040561622465, 'fraction_numerical': 0.09485179407176288, 'mean_word_length': 3.68029197080292, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5464361', 'n_tokens_mistral': 1421, 'n_tokens_neox': 1277, 'n_words': 326}