<commit_before>// Copyright (C) 2017 <NAME>

#include <cmath>
#include "simulation.h"

Simulation::Simulation() {
	collision_configuration = new btDefaultCollisionConfiguration();
	assert(collision_configuration);
	dispatcher = new btCollisionDispatcher(collision_configuration);
	assert(dispatcher);
	overlapping_pair_cache = new btDbvtBroadphase();
	assert(overlapping_pair_cache);
	solver = new btSequentialImpulseConstraintSolver;
	assert(solver);
	dynamics_world = new btDiscreteDynamicsWorld(dispatcher,
			overlapping_pair_cache, solver, collision_configuration);
	assert(dynamics_world);
	dynamics_world->setGravity(btVector3(0, -10, 0));
}

Simulation::~Simulation() {


	for(std::map<std::string, btRigidBody*>::iterator it = rigid_bodies.begin(); it != rigid_bodies.end(); ++it) {
		btRigidBody* rb = it->second;
		if(rb) {
			delete rb;
			rb = 0;
		}
	}

	for(std::map<std::string, btBoxShape*>::iterator it = box_shapes.begin(); it != box_shapes.end(); ++it) {
		btBoxShape* box = it->second;
		if(box) {
			delete box;
			box = 0;
		}
	}

	for(std::map<std::string, btConvexHullShape*>::iterator it = convex_hull_shapes.begin(); it != convex_hull_shapes.end(); ++it) {
		btConvexHullShape* chs = it->second;
		if(chs) {
			delete chs;
			chs = 0;
		}
	}

	delete dynamics_world;
	delete solver;
	delete overlapping_pair_cache;
	delete dispatcher;
	delete collision_configuration;
}

void Simulation::parseXMLNode(rapidxml::xml_node<>* my_xml_node, scenegraph::Node* scenegraph_root) {
	if (!my_xml_node)
		return;
	char* c_name = my_xml_node->name();<commit_msg>reverted simulation destructor to use Bullet hello world example algorithm after clearing mapped pointer arrays to rigid bodies and collision shapes.<commit_after>// Copyright (C) 2017 <NAME>

#include <cmath>
#include "simulation.h"

Simulation::Simulation() {
	collision_configuration = new btDefaultCollisionConfiguration();
	assert(collision_configuration);
	dispatcher = new btCollisionDispatcher(collision_configuration);
	assert(dispatcher);
	overlapping_pair_cache = new btDbvtBroadphase();
	assert(overlapping_pair_cache);
	solver = new btSequentialImpulseConstraintSolver;
	assert(solver);
	dynamics_world = new btDiscreteDynamicsWorld(dispatcher,
			overlapping_pair_cache, solver, collision_configuration);
	assert(dynamics_world);
	dynamics_world->setGravity(btVector3(0, -10, 0));
}

Simulation::~Simulation() {
	rigid_bodies.clear();
	box_shapes.clear();
	convex_hull_shapes.clear();
	for (int i = dynamics_world->getNumCollisionObjects() - 1; i >= 0; i--) {
		btCollisionObject* obj = dynamics_world->getCollisionObjectArray()[i];
		btRigidBody* body = btRigidBody::upcast(obj);
		if (body && body->getMotionState()) {
			delete body->getMotionState();
		}
		dynamics_world->removeCollisionObject(obj);
		delete obj;
	}

	//delete collision shapes
	for (int j = 0; j < collision_shapes.size(); j++) {
		btCollisionShape* shape = collision_shapes[j];
		collision_shapes[j] = 0;
		delete shape;
	}

	delete dynamics_world;
	delete solver;
	delete overlapping_pair_cache;
	delete dispatcher;
	delete collision_configuration;
}

void Simulation::parseXMLNode(rapidxml::xml_node<>* my_xml_node, scenegraph::Node* scenegraph_root) {
	if (!my_xml_node)
		return;
	char* c_name = my_xml_node->name();
{'fraction_non_alphanumeric': 0.12724505327245053, 'fraction_numerical': 0.0076103500761035, 'mean_word_length': 6.269911504424779, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 10}, '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': '6624182', 'n_tokens_mistral': 1203, 'n_tokens_neox': 1115, 'n_words': 222}