Skip to content

Commit

Permalink
Remove material buffer implementation
Browse files Browse the repository at this point in the history
The old material struct is almost unused now, it's solely used to
shuffle a few values between the wavefront parser and the logic that
turns those into shader graph descriptions.
I should probably delete material.h and just integrate that code
directly into the wavefront parser.
  • Loading branch information
vkoskiv committed Nov 28, 2023
1 parent 169717f commit 610229d
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 36 deletions.
20 changes: 0 additions & 20 deletions src/datatypes/material.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,6 @@
#include "image/texture.h"
#include "../datatypes/scene.h"

struct material_buffer *material_buf_ref(struct material_buffer *buf) {
if (buf) {
buf->refs++;
return buf;
}
struct material_buffer *new = calloc(1, sizeof(*new));
new->refs = 1;
return new;
}

void material_buf_unref(struct material_buffer *buf) {
if (!buf) return;
if (--buf->refs) return;
for (size_t i = 0; i < buf->materials.count; ++i) {
destroyMaterial(&buf->materials.items[i]);
}
material_arr_free(&buf->materials);
free(buf);
}

//To showcase missing .MTL file, for example
struct material warningMaterial() {
struct material newMat = { 0 };
Expand Down
11 changes: 0 additions & 11 deletions src/datatypes/material.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,17 +85,6 @@ struct material {
typedef struct material material;
dyn_array_def(material);

/*
Several meshes may refer to the same set of materials, so this is refcounted.
*/
struct material_buffer {
struct material_arr materials;
size_t refs;
};

struct material_buffer *material_buf_ref(struct material_buffer *buf);
void material_buf_unref(struct material_buffer *buf);

struct material warningMaterial(void);

struct node_storage;
Expand Down
1 change: 0 additions & 1 deletion src/datatypes/mesh.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ void destroyMesh(struct mesh *mesh) {
vertex_buf_unref(mesh->vbuf);
poly_arr_free(&mesh->polygons);
destroy_bvh(mesh->bvh);
material_buf_unref(mesh->mbuf);
}
}

Expand Down
1 change: 0 additions & 1 deletion src/datatypes/mesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ struct vertex_buffer {
struct mesh {
struct vertex_buffer *vbuf;
struct poly_arr polygons;
struct material_buffer *mbuf;
struct bvh *bvh;
float surface_area;
char *name;
Expand Down
3 changes: 0 additions & 3 deletions src/driver/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,6 @@ int main(int argc, char *argv[]) {
cr_renderer_set_num_pref(renderer, cr_renderer_override_cam, args_int(opts, "cam_index"));
}

// FIXME: Remove global options table, store it in a local in main() and run overrides
// from there.

// Now check and apply potential CLI overrides.
if (args_is_set(opts, "thread_override")) {
size_t threads = args_int(opts, "thread_override");
Expand Down

0 comments on commit 610229d

Please sign in to comment.