Fixed the bug where different source files were referencing a static variable. Turns out static vars are internally linked, which means there was a separate static variable defined for each source. I could have fixed this issue by using extern (see https://stackoverflow.com/questions/10422034/when-to-use-extern-in-c), but instead went with just assigning the shader manually im main. This is becoming very messy and needs a cleanup.

This commit is contained in:
2025-08-22 15:09:34 -05:00
parent a79b074201
commit c961ccf7cd
4 changed files with 29 additions and 27 deletions

View File

@@ -27,6 +27,9 @@ bool parse_poses(Array<Body>* bodies_out, const char* filepath) {
char delim = ',';
char line[LINE_BUF_SIZE];
// because clang refuses to cooperate with my append implementation and generate the function code...
*bodies_out
= { (Body*)malloc(sizeof(Body) * 3 * NUM_SPHERES_PER_AXE * 14), 3 * NUM_SPHERES_PER_AXE * 14 };
// read in header
fgets(line, LINE_BUF_SIZE, fp);
@@ -36,9 +39,9 @@ bool parse_poses(Array<Body>* bodies_out, const char* filepath) {
for (int camera_i = 0; !feof(fp); camera_i++) {
Array<char*> words = split_str(line, delim);
float x = atof(words[0])/100.0f;
float y = atof(words[1])/100.0f;
float z = atof(words[2])/100.0f;
float x = atof(words[0]);
float y = atof(words[1]);
float z = atof(words[2]);
float w = atof(words[3]);
float i = atof(words[4]);
float j = atof(words[5]);
@@ -46,10 +49,6 @@ bool parse_poses(Array<Body>* bodies_out, const char* filepath) {
glm::mat4 pose = glm::translate(quat_to_mat4(glm::quat(w, i, j, k)), glm::vec3(x, y, z));
// because clang refuses to cooperate with my append implementation and generate the function code...
*bodies_out
= { (Body*)malloc(sizeof(Body) * 3 * NUM_SPHERES_PER_AXE * 14), 3 * NUM_SPHERES_PER_AXE * 14 };
// Generate axis spheres
for (int i = 0; i < 3; i++) {
for (int j = 0; j < NUM_SPHERES_PER_AXE; j++) {
@@ -63,11 +62,12 @@ bool parse_poses(Array<Body>* bodies_out, const char* filepath) {
// Now move the translated pose via the camera's pose
b.pose = pose * glm::translate(b.pose, trans);
b.color = glm::vec4(i == 0 ? 1 : 0, i == 1 ? 1 : 0, i == 2 ? 1 : 0, 1);
b.scale = 0.2;
b.scale = 3;
printf("%d, ", camera_i * 3 * NUM_SPHERES_PER_AXE + i * NUM_SPHERES_PER_AXE + j);
bodies_out->data[camera_i*3*NUM_SPHERES_PER_AXE + i*NUM_SPHERES_PER_AXE + j] = b;
}
}
fgets(line, LINE_BUF_SIZE, fp);
}
return true;
}