<commit_before>// Fill out your copyright notice in the Description page of Project Settings.

#include "MeshGenerator.h"
#include "MeshImporter.h"

MeshImporter::MeshImporter(const char* path)
{
	ReadFile(path);
}

MeshImporter::~MeshImporter()
{
}

void MeshImporter::ReadFile(const char* filename)
{
	Assimp::Importer importer;
	
	importer.SetPropertyInteger(AI_CONFIG_PP_RVC_FLAGS,
		aiComponent_TANGENTS_AND_BITANGENTS |
		aiComponent_MATERIALS |
		aiComponent_BONEWEIGHTS |
		aiComponent_ANIMATIONS |
		aiComponent_LIGHTS |
		aiComponent_CAMERAS |
		aiComponent_TEXTURES |
		aiComponent_TEXCOORDS
	);

#define max_Quality_Preset ( \
	aiProcess_CalcTangentSpace				|  \
	aiProcess_GenSmoothNormals				|  \
	aiProcess_JoinIdenticalVertices			|  \
	aiProcess_ImproveCacheLocality			|  \
	aiProcess_LimitBoneWeights				|  \
	aiProcess_RemoveRedundantMaterials      |  \
	aiProcess_SplitLargeMeshes				|  \
	aiProcess_Triangulate					|  \
	aiProcess_GenUVCoords                   |  \
	aiProcess_SortByPType                   |  \
	aiProcess_FindDegenerates               |  \
	aiProcess_FindInvalidData               |  \
	aiProcess_FindInstances                 |  \
	aiProcess_ValidateDataStructure         |  \
	aiProcess_OptimizeMeshes                |  \
	aiProcess_OptimizeGraph					|  \
	0 )

#define molecule_Preset ( \
	aiProcess_RemoveComponent				|  \
	aiProcess_SplitLargeMeshes				|  \
	aiProcess_GenSmoothNormals				|  \
	aiProcess_Triangulate					|  \
	aiProcess_JoinIdenticalVertices			|  \
	aiProcess_OptimizeMeshes                |  \
	0 )

	// TODO revert last two presets to gather color
	const aiScene* scene = importer.ReadFile(filename, molecule_Preset);
	int face_index = 0;

	for (unsigned int m = 0; m < scene->mNumMeshes; ++m) {
		const struct aiMesh* mesh = scene->mMeshes[m];

		for (unsigned int i = 0; i < mesh->mNumVertices; ++i) {
			aiVector3D vertex = mesh->mVertices[i];
			vertices_.push_back(vertex.x);
			vertices_.push_back(vertex.y);
			vertices_.push_back(vertex.z);
		}

		for (unsigned int i = 0; i < mesh->mNumVertices; ++i) {
			aiVector3D normal = mesh->mNormals[i];
			normals_.push_back(normal.x);
			normals_.push_back(normal.y);
			normals_.push_back(normal.z);
		}

		for (unsigned int i = 0; i < mesh->mNumFaces; ++i) {
			aiFace face = mesh->mFaces[i];
			for (int j = 0; j < 3; ++j) {
				faces_.push_back(face.mIndices[j] + face_index);
			}
		}

		face_index += mesh->mNumVertices;
	}
}

vector<float>& MeshImporter::GetVertices()
{
	return vertices_;
}

vector<float>& MeshImporter::GetNormals()<commit_msg>render all meshes -> dont split meshes<commit_after>// Fill out your copyright notice in the Description page of Project Settings.

#include "MeshGenerator.h"
#include "MeshImporter.h"

MeshImporter::MeshImporter(const char* path)
{
	ReadFile(path);
}

MeshImporter::~MeshImporter()
{
}

void MeshImporter::ReadFile(const char* filename)
{
	Assimp::Importer importer;
	
	importer.SetPropertyInteger(AI_CONFIG_PP_RVC_FLAGS,
		aiComponent_TANGENTS_AND_BITANGENTS |
		aiComponent_MATERIALS |
		aiComponent_BONEWEIGHTS |
		aiComponent_ANIMATIONS |
		aiComponent_LIGHTS |
		aiComponent_CAMERAS |
		aiComponent_TEXTURES |
		aiComponent_TEXCOORDS
	);

#define max_Quality_Preset ( \
	aiProcess_CalcTangentSpace				|  \
	aiProcess_GenSmoothNormals				|  \
	aiProcess_JoinIdenticalVertices			|  \
	aiProcess_ImproveCacheLocality			|  \
	aiProcess_LimitBoneWeights				|  \
	aiProcess_RemoveRedundantMaterials      |  \
	aiProcess_SplitLargeMeshes				|  \
	aiProcess_Triangulate					|  \
	aiProcess_GenUVCoords                   |  \
	aiProcess_SortByPType                   |  \
	aiProcess_FindDegenerates               |  \
	aiProcess_FindInvalidData               |  \
	aiProcess_FindInstances                 |  \
	aiProcess_ValidateDataStructure         |  \
	aiProcess_OptimizeMeshes                |  \
	aiProcess_OptimizeGraph					|  \
	0 )

#define molecule_Preset ( \
	aiProcess_RemoveComponent				|  \
	aiProcess_GenSmoothNormals				|  \
	aiProcess_Triangulate					|  \
	aiProcess_JoinIdenticalVertices			|  \
	aiProcess_OptimizeMeshes                |  \
	0 )

	// TODO revert last two presets to gather color
	const aiScene* scene = importer.ReadFile(filename, molecule_Preset);
	int face_index = 0;

	for (unsigned int m = 0; m < scene->mNumMeshes; ++m) {
		const struct aiMesh* mesh = scene->mMeshes[m];

		for (unsigned int i = 0; i < mesh->mNumVertices; ++i) {
			aiVector3D vertex = mesh->mVertices[i];
			vertices_.push_back(vertex.x);
			vertices_.push_back(vertex.y);
			vertices_.push_back(vertex.z);

			aiColor4t<float> color = mesh->mColors[0][i];
			colors_.push_back((uint32_t)color.r * 100);
			colors_.push_back((uint32_t)color.g * 100);
			colors_.push_back((uint32_t)color.b * 100);
		}

		for (unsigned int i = 0; i < mesh->mNumVertices; ++i) {
			aiVector3D normal = mesh->mNormals[i];
			normals_.push_back(normal.x);
			normals_.push_back(normal.y);
			normals_.push_back(normal.z);
		}

		for (unsigned int i = 0; i < mesh->mNumFaces; ++i) {
			aiFace face = mesh->mFaces[i];
			for (int j = 0; j < 3; ++j) {
				faces_.push_back(face.mIndices[j] + face_index);
			}
		}

		face_index += mesh->mNumVertices;
	}
}

vector<float>& MeshImporter::GetVertices()
{
	return vertices_;
}

vector<float>& MeshImporter::GetNormals()
{'fraction_non_alphanumeric': 0.10387655250282274, 'fraction_numerical': 0.007339104252916824, 'mean_word_length': 3.2932148626817446, 'pattern_counts': {'":': 0, '<': 18, '<?xml version=': 0, '>': 28, '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': '3502576', 'n_tokens_mistral': 2156, 'n_tokens_neox': 1935, 'n_words': 312}