<commit_before>#ifndef SPHEREGENERATOR_H
#define SPHEREGENERATOR_H

#include <QVector2D>
#include <QVector3D>
#include <qmath.h>

template <unsigned int slices> class Circle {
public:
    static const unsigned int vertexCount = slices;
    static const unsigned int lineCount = slices * 2;

    QVector3D verts[vertexCount];
    unsigned int lines[lineCount];

    Circle();
};

template <unsigned int slices> Circle<slices>::Circle(){
    float step = float(2.0 * M_PI) / slices;

    unsigned int currentLine = 0;

    for(unsigned int current = 0; current < slices; current++){
        verts[current] = QVector3D(cos(current * step), sin(current * step), 0.0f);

        if(current == (slices - 1)){
            lines[currentLine++] = current;
            lines[currentLine++] = 0;
        }else{
            lines[currentLine++] = current;
            lines[currentLine++] = current + 1;
        }
    }
}

template <unsigned int slices, unsigned int stacks> class Sphere {
public:
    static const unsigned int vertexCount = (slices + 1) * (stacks + 1);
    static const unsigned int triangleCount = slices * stacks * 6;
    static const unsigned int lineCount = slices * stacks * 4;

    QVector3D verts[vertexCount];
    QVector2D uv[vertexCount];
    unsigned int triangles[triangleCount];
    unsigned int lines[lineCount];

    Sphere();
};

template <unsigned int slices, unsigned int stacks> Sphere<slices, stacks>::Sphere(){
    float vstep = float(M_PI) / stacks;
    float hstep = float(2.0 * M_PI) / slices;

    unsigned int currentTriangle = 0;
    unsigned int currentLine = 0;

    for(int v = 0; v <= stacks; v++){
        float z = cos(v * vstep);
        float r = sin(v * vstep);

        for(int h = 0; h <= slices; h++){
            unsigned int w = slices + 1;
            unsigned int current = v * w + h;

            verts[current] = QVector3D(cos(h * hstep) * r, sin(h * hstep) * r, z);

            uv[current] = QVector2D(float(h) / float(slices), 1.0f - float(v) / float(stacks));

            if(h != slices && v != stacks){
                triangles[currentTriangle++] = current;
                triangles[currentTriangle++] = current + w;
                triangles[currentTriangle++] = current + 1;

                triangles[currentTriangle++] = current + w + 1;
                triangles[currentTriangle++] = current + 1;
                triangles[currentTriangle++] = current + w;
<commit_msg>Made circle and sphere generators store verts & uv directly as floats.<commit_after>#ifndef SPHEREGENERATOR_H
#define SPHEREGENERATOR_H

#include <qmath.h>

template <unsigned int slices> class Circle {
public:
    static const unsigned int vertexCount = slices;
    static const unsigned int lineCount = slices * 2;

    float verts[vertexCount][3];
    unsigned int lines[lineCount];

    Circle();
};

template <unsigned int slices> Circle<slices>::Circle(){
    float step = float(2.0 * M_PI) / slices;

    unsigned int currentLine = 0;

    for(unsigned int current = 0; current < slices; current++){
        verts[current][0] = cos(current * step);
        verts[current][1] = sin(current * step);
        verts[current][2] = 0.0f;

        if(current == (slices - 1)){
            lines[currentLine++] = current;
            lines[currentLine++] = 0;
        }else{
            lines[currentLine++] = current;
            lines[currentLine++] = current + 1;
        }
    }
}

template <unsigned int slices, unsigned int stacks> class Sphere {
public:
    static const unsigned int vertexCount = (slices + 1) * (stacks + 1);
    static const unsigned int triangleCount = slices * stacks * 6;
    static const unsigned int lineCount = slices * stacks * 4;

    float verts[vertexCount][3];
    float uv[vertexCount][2];
    unsigned int triangles[triangleCount];
    unsigned int lines[lineCount];

    Sphere();
};

template <unsigned int slices, unsigned int stacks> Sphere<slices, stacks>::Sphere(){
    float vstep = float(M_PI) / stacks;
    float hstep = float(2.0 * M_PI) / slices;

    unsigned int currentTriangle = 0;
    unsigned int currentLine = 0;

    for(int v = 0; v <= stacks; v++){
        float z = cos(v * vstep);
        float r = sin(v * vstep);

        for(int h = 0; h <= slices; h++){
            unsigned int w = slices + 1;
            unsigned int current = v * w + h;

            verts[current][0] = cos(h * hstep) * r;
            verts[current][1] = sin(h * hstep) * r;
            verts[current][2] = z;

            uv[current][0] = float(h) / float(slices);
            uv[current][1] = 1.0f - float(v) / float(stacks);

            if(h != slices && v != stacks){
                triangles[currentTriangle++] = current;
                triangles[currentTriangle++] = current + w;
                triangles[currentTriangle++] = current + 1;

                triangles[currentTriangle++] = current + w + 1;
                triangles[currentTriangle++] = current + 1;
                triangles[currentTriangle++] = current + w;

{'fraction_non_alphanumeric': 0.12692384569258444, 'fraction_numerical': 0.01419148510893464, 'mean_word_length': 2.526427061310782, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 19, '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': '6927365', 'n_tokens_mistral': 1611, 'n_tokens_neox': 1467, 'n_words': 441}