<commit_before>#ifndef __ENGINE_MESH_H__
#define __ENGINE_MESH_H__

#include "std/types.h"
#include "gfx/vector3d.h"

typedef struct Triangle {
  uint16_t p1, p2, p3;
} TriangleT;

typedef struct IndexArray {
  uint16_t count;
  uint16_t *index;
} IndexArrayT;

typedef struct IndexMap {
  IndexArrayT *vertex;
  uint16_t *indices;
} IndexMapT;

typedef struct Mesh {
  size_t vertexNum;
  size_t polygonNum;

  Vector3D *vertex;
  TriangleT *polygon;

  Vector3D *surfaceNormal;
  Vector3D *vertexNormal;

  IndexMapT vertexToPoly;
} MeshT;

MeshT *NewMesh(size_t vertices, size_t triangles);
MeshT *NewMeshFromFile(const char *fileName);
void DeleteMesh(MeshT *mesh);
void NormalizeMeshSize(MeshT *mesh);
void CenterMeshPosition(MeshT *mesh);

void AddSurfaceNormals(MeshT *mesh);
void AddVertexToPolygonMap(MeshT *mesh);
void AddVertexNormals(MeshT *mesh);

#define RSC_MESH_FILE(NAME, FILENAME) \
  AddRscSimple(NAME, NewMeshFromFile(FILENAME), (FreeFuncT)DeleteMesh)

#endif<commit_msg>Add some comments about expected purpose.<commit_after>#ifndef __ENGINE_MESH_H__
#define __ENGINE_MESH_H__

#include "std/types.h"
#include "gfx/vector3d.h"

typedef struct Triangle {
  uint16_t p1, p2, p3;
} TriangleT;

typedef struct IndexArray {
  uint16_t count;
  uint16_t *index;
} IndexArrayT;

typedef struct IndexMap {
  IndexArrayT *vertex;
  uint16_t *indices;
} IndexMapT;

typedef struct Mesh {
  size_t vertexNum;
  size_t polygonNum;

  Vector3D *vertex;
  TriangleT *polygon;

  /* map from vertex index to list of polygon indices */
  IndexMapT vertexToPoly;

  /* useful for lighting and backface culling */
  Vector3D *surfaceNormal;
  Vector3D *vertexNormal;
} MeshT;

MeshT *NewMesh(size_t vertices, size_t triangles);
MeshT *NewMeshFromFile(const char *fileName);
void DeleteMesh(MeshT *mesh);
void NormalizeMeshSize(MeshT *mesh);
void CenterMeshPosition(MeshT *mesh);

void AddSurfaceNormals(MeshT *mesh);
void AddVertexToPolygonMap(MeshT *mesh);
void AddVertexNormals(MeshT *mesh);

#define RSC_MESH_FILE(NAME, FILENAME) \
  AddRscSimple(NAME, NewMeshFromFile(FILENAME), (FreeFuncT)DeleteMesh)

#endif
{'fraction_non_alphanumeric': 0.0949905482041588, 'fraction_numerical': 0.014177693761814745, 'mean_word_length': 5.963815789473684, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5657886', 'n_tokens_mistral': 809, 'n_tokens_neox': 767, 'n_words': 187}