Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Suggestion: single struct for function calls #141

Open
matanui159 opened this issue Sep 25, 2017 · 1 comment
Open

Suggestion: single struct for function calls #141

matanui159 opened this issue Sep 25, 2017 · 1 comment

Comments

@matanui159
Copy link

This is just a suggestion, and it may have been suggested before.
Instead of having to pass attrb_t, vector<shape_t>, vector<material_t> and string (for the error), instead just have a single struct like so (possibly named obj_t):

struct model_t {
    attrib_t attribs;
    vector<shape_t> shapes;
    vector<material_t> materials;
    string error;
}

This will save having to define four different objects before calling the function. However, if the idea of having separate structs is to allow customization, my response would be saying that most people would probably already use all the structs anyway (maybe except for the materials). Also, if the idea is to keep backwards compatibility, you could just add a new function as an override or with a different name like LoadObjModel like so:

bool LoadObjModel(model_t* model, const char* filename, const char* mtl_basedir = NULL, bool triangulate = false);

As a side suggestion, maybe use references instead of using pointers? Again, possibly through new functions or function overrides.

@syoyo
Copy link
Collaborator

syoyo commented Sep 25, 2017

Making a sturct for attrib, mesh and material is a good idea.

I am also considering to wrap optional flags(mtl_basedir, triangulate, etc) into one struct for simplicity. Let me give some time to think about it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants