<commit_before>#include "Stage.hpp"

#include <fstream>

noob::stage::~stage()
{
	delete dynamics_world;
	delete solver;
	delete collision_configuration;
	delete collision_dispatcher;
	delete broadphase;
}


void noob::stage::init()
{
	broadphase = new btDbvtBroadphase();
	collision_configuration = new btDefaultCollisionConfiguration();
	collision_dispatcher = new btCollisionDispatcher(collision_configuration);
	solver = new btSequentialImpulseConstraintSolver();
	dynamics_world = new btDiscreteDynamicsWorld(collision_dispatcher, broadphase, solver, collision_configuration);
	dynamics_world->setGravity(btVector3(0, -10, 0));

	draw_graph.reserveNode(NUM_RESERVED_NODES);
	draw_graph.reserveArc(NUM_RESERVED_ARCS);

	root_node = draw_graph.addNode();

	//for (size_t i = 0; i < 6; ++i)
	//{
		//noob::lights_holder::handle;
		//lights[i] =
	//}

	// noob::bodies_holder::handle temp = body(noob::body_type::ghost, globals->unit_sphere_shape, 0.0, noob::vec3(0.0, 0.0, 0.0), noob::versor(0.0, 0.0, 0.0, 1.0), false);

	// fmt::MemoryWriter ww;
	// ww << "[Stage] init first body. Handle = " << temp.get_inner();
	// logger::log(ww.str());

	logger::log("[Stage] Done init.");
}

void noob::stage::tear_down()
{
	draw_graph.clear();

	for (size_t i = 1; i < bodies.count(); ++i)
	{
		remove_body(bodies.make_handle(i));
	}

	bodies.empty();
	joints.empty();
	ghosts.empty();

	bodies_to_nodes.clear();
	basic_models_to_nodes.clear();

	delete dynamics_world;
	delete broadphase;
	delete solver;
	delete collision_dispatcher;
	delete collision_configuration;
	
	init();
}

void noob::stage::update(double dt)
{
	dynamics_world->stepSimulation(1.0/60.0, 10);
}


void noob::stage::draw(float window_width, float window_height) const<commit_msg>Fix the silliest little memory leak<commit_after>#include "Stage.hpp"

#include <fstream>

noob::stage::~stage()
{
	delete dynamics_world;
	delete solver;
	delete collision_configuration;
	delete collision_dispatcher;
	delete broadphase;
}


void noob::stage::init()
{
	broadphase = new btDbvtBroadphase();
	collision_configuration = new btDefaultCollisionConfiguration();
	collision_dispatcher = new btCollisionDispatcher(collision_configuration);
	solver = new btSequentialImpulseConstraintSolver();
	dynamics_world = new btDiscreteDynamicsWorld(collision_dispatcher, broadphase, solver, collision_configuration);
	dynamics_world->setGravity(btVector3(0, -10, 0));

	draw_graph.reserveNode(NUM_RESERVED_NODES);
	draw_graph.reserveArc(NUM_RESERVED_ARCS);

	root_node = draw_graph.addNode();

	//for (size_t i = 0; i < 6; ++i)
	//{
		//noob::lights_holder::handle;
		//lights[i] =
	//}

	// noob::bodies_holder::handle temp = body(noob::body_type::ghost, globals->unit_sphere_shape, 0.0, noob::vec3(0.0, 0.0, 0.0), noob::versor(0.0, 0.0, 0.0, 1.0), false);

	// fmt::MemoryWriter ww;
	// ww << "[Stage] init first body. Handle = " << temp.get_inner();
	// logger::log(ww.str());

	logger::log("[Stage] Done init.");
}

void noob::stage::tear_down()
{
	draw_graph.clear();

	for (size_t i = 0; i < bodies.count(); ++i)
	{
		remove_body(bodies.make_handle(i));
	}

	bodies.empty();
	joints.empty();
	ghosts.empty();

	bodies_to_nodes.clear();
	basic_models_to_nodes.clear();

	delete dynamics_world;
	delete broadphase;
	delete solver;
	delete collision_dispatcher;
	delete collision_configuration;
	
	init();
}

void noob::stage::update(double dt)
{
	dynamics_world->stepSimulation(1.0/60.0, 10);
}


void noob::stage::draw(float window_width, float window_height) const
{'fraction_non_alphanumeric': 0.1547212741751991, 'fraction_numerical': 0.01820250284414107, 'mean_word_length': 5.711832061068702, 'pattern_counts': {'":': 0, '<': 17, '<?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': '5074389', 'n_tokens_mistral': 1362, 'n_tokens_neox': 1277, 'n_words': 234}