various improvements

main
Dominik Madarász 2024-02-16 15:38:45 +01:00
parent f2b56de416
commit 4982761b48
7 changed files with 33 additions and 23 deletions

View File

@ -1304,8 +1304,9 @@ enum MODEL_FLAGS {
MODEL_NO_ANIMATIONS = 1, MODEL_NO_ANIMATIONS = 1,
MODEL_NO_MESHES = 2, MODEL_NO_MESHES = 2,
MODEL_NO_TEXTURES = 4, MODEL_NO_TEXTURES = 4,
MODEL_MATCAPS = 8, MODEL_NO_FILTERING = 8,
MODEL_RIMLIGHT = 16 MODEL_MATCAPS = 16,
MODEL_RIMLIGHT = 32,
}; };
typedef struct model_t { typedef struct model_t {
struct iqm_t *iqm; struct iqm_t *iqm;

View File

@ -17523,8 +17523,9 @@ enum MODEL_FLAGS {
MODEL_NO_ANIMATIONS = 1, MODEL_NO_ANIMATIONS = 1,
MODEL_NO_MESHES = 2, MODEL_NO_MESHES = 2,
MODEL_NO_TEXTURES = 4, MODEL_NO_TEXTURES = 4,
MODEL_MATCAPS = 8, MODEL_NO_FILTERING = 8,
MODEL_RIMLIGHT = 16 MODEL_MATCAPS = 16,
MODEL_RIMLIGHT = 32,
}; };
//@todo: make this data-driven //@todo: make this data-driven
@ -361087,7 +361088,7 @@ bool vfs_mount_(const char *path, array(struct vfs_entry) *entries) {
array_push(*entries, (struct vfs_entry){filename, fileid, filesize}); array_push(*entries, (struct vfs_entry){filename, fileid, filesize});
} }
PRINTF("Mounted VFS volume '%s' (%u entries)\n", path_bak, fn_count[dir->type](dir->archive) ); // PRINTF("Mounted VFS volume '%s' (%u entries)\n", path_bak, fn_count[dir->type](dir->archive) );
} }
return 1; return 1;
@ -370153,7 +370154,7 @@ unsigned shader_geom(const char *gs, const char *vs, const char *fs, const char
while( attribs[0] && attribs[0] == ',' ) { attribs++; break; } while( attribs[0] && attribs[0] == ',' ) { attribs++; break; }
if(!attrib[0]) continue; if(!attrib[0]) continue;
glBindAttribLocation(program, i, attrib); glBindAttribLocation(program, i, attrib);
PRINTF("Shader.attribute[%d]=%s\n", i, attrib); // PRINTF("Shader.attribute[%d]=%s\n", i, attrib);
} }
#if !is(ems) // @fixme #if !is(ems) // @fixme
@ -373204,7 +373205,7 @@ static char* strcpy_safe(char *d, const char *s) {
} }
static static
bool model_load_textures(iqm_t *q, const struct iqmheader *hdr, model_t *model) { bool model_load_textures(iqm_t *q, const struct iqmheader *hdr, model_t *model, int _flags) {
q->textures = q->textures ? q->textures : CALLOC(hdr->num_meshes * 8, sizeof(GLuint)); // up to 8 textures per mesh q->textures = q->textures ? q->textures : CALLOC(hdr->num_meshes * 8, sizeof(GLuint)); // up to 8 textures per mesh
q->colormaps = q->colormaps ? q->colormaps : CALLOC(hdr->num_meshes * 8, sizeof(vec4)); // up to 8 colormaps per mesh q->colormaps = q->colormaps ? q->colormaps : CALLOC(hdr->num_meshes * 8, sizeof(vec4)); // up to 8 colormaps per mesh
@ -373235,7 +373236,9 @@ bool model_load_textures(iqm_t *q, const struct iqmheader *hdr, model_t *model)
if( reused ) continue; if( reused ) continue;
// decode texture+material // decode texture+material
int flags = TEXTURE_MIPMAPS|TEXTURE_ANISOTROPY|TEXTURE_REPEAT|TEXTURE_LINEAR; // LINEAR, NEAREST int flags = TEXTURE_MIPMAPS|TEXTURE_REPEAT|TEXTURE_ANISOTROPY; // LINEAR, NEAREST
if (!(_flags & MODEL_NO_FILTERING))
flags |= TEXTURE_LINEAR;
int invalid = texture_checker().id; int invalid = texture_checker().id;
#if 1 #if 1
@ -373385,7 +373388,7 @@ model_t model_from_mem(const void *mem, int len, int flags) {
memcpy(q->buf + sizeof(hdr), ptr, hdr.filesize - sizeof(hdr)); memcpy(q->buf + sizeof(hdr), ptr, hdr.filesize - sizeof(hdr));
error = 0; error = 0;
if( hdr.num_meshes > 0 && !(flags & MODEL_NO_MESHES) ) error |= !model_load_meshes(q, &hdr, &m); if( hdr.num_meshes > 0 && !(flags & MODEL_NO_MESHES) ) error |= !model_load_meshes(q, &hdr, &m);
if( hdr.num_meshes > 0 && !(flags & MODEL_NO_TEXTURES) ) error |= !model_load_textures(q, &hdr, &m); if( hdr.num_meshes > 0 && !(flags & MODEL_NO_TEXTURES) ) error |= !model_load_textures(q, &hdr, &m, flags);
else { else {
// setup fallback // setup fallback
material_t mt = {0}; material_t mt = {0};

View File

@ -686,7 +686,7 @@ bool vfs_mount_(const char *path, array(struct vfs_entry) *entries) {
array_push(*entries, (struct vfs_entry){filename, fileid, filesize}); array_push(*entries, (struct vfs_entry){filename, fileid, filesize});
} }
PRINTF("Mounted VFS volume '%s' (%u entries)\n", path_bak, fn_count[dir->type](dir->archive) ); // PRINTF("Mounted VFS volume '%s' (%u entries)\n", path_bak, fn_count[dir->type](dir->archive) );
} }
return 1; return 1;

View File

@ -138,7 +138,7 @@ unsigned shader_geom(const char *gs, const char *vs, const char *fs, const char
while( attribs[0] && attribs[0] == ',' ) { attribs++; break; } while( attribs[0] && attribs[0] == ',' ) { attribs++; break; }
if(!attrib[0]) continue; if(!attrib[0]) continue;
glBindAttribLocation(program, i, attrib); glBindAttribLocation(program, i, attrib);
PRINTF("Shader.attribute[%d]=%s\n", i, attrib); // PRINTF("Shader.attribute[%d]=%s\n", i, attrib);
} }
#if !is(ems) // @fixme #if !is(ems) // @fixme
@ -3189,7 +3189,7 @@ static char* strcpy_safe(char *d, const char *s) {
} }
static static
bool model_load_textures(iqm_t *q, const struct iqmheader *hdr, model_t *model) { bool model_load_textures(iqm_t *q, const struct iqmheader *hdr, model_t *model, int _flags) {
q->textures = q->textures ? q->textures : CALLOC(hdr->num_meshes * 8, sizeof(GLuint)); // up to 8 textures per mesh q->textures = q->textures ? q->textures : CALLOC(hdr->num_meshes * 8, sizeof(GLuint)); // up to 8 textures per mesh
q->colormaps = q->colormaps ? q->colormaps : CALLOC(hdr->num_meshes * 8, sizeof(vec4)); // up to 8 colormaps per mesh q->colormaps = q->colormaps ? q->colormaps : CALLOC(hdr->num_meshes * 8, sizeof(vec4)); // up to 8 colormaps per mesh
@ -3220,7 +3220,9 @@ bool model_load_textures(iqm_t *q, const struct iqmheader *hdr, model_t *model)
if( reused ) continue; if( reused ) continue;
// decode texture+material // decode texture+material
int flags = TEXTURE_MIPMAPS|TEXTURE_ANISOTROPY|TEXTURE_REPEAT|TEXTURE_LINEAR; // LINEAR, NEAREST int flags = TEXTURE_MIPMAPS|TEXTURE_REPEAT|TEXTURE_ANISOTROPY; // LINEAR, NEAREST
if (!(_flags & MODEL_NO_FILTERING))
flags |= TEXTURE_LINEAR;
int invalid = texture_checker().id; int invalid = texture_checker().id;
#if 1 #if 1
@ -3370,7 +3372,7 @@ model_t model_from_mem(const void *mem, int len, int flags) {
memcpy(q->buf + sizeof(hdr), ptr, hdr.filesize - sizeof(hdr)); memcpy(q->buf + sizeof(hdr), ptr, hdr.filesize - sizeof(hdr));
error = 0; error = 0;
if( hdr.num_meshes > 0 && !(flags & MODEL_NO_MESHES) ) error |= !model_load_meshes(q, &hdr, &m); if( hdr.num_meshes > 0 && !(flags & MODEL_NO_MESHES) ) error |= !model_load_meshes(q, &hdr, &m);
if( hdr.num_meshes > 0 && !(flags & MODEL_NO_TEXTURES) ) error |= !model_load_textures(q, &hdr, &m); if( hdr.num_meshes > 0 && !(flags & MODEL_NO_TEXTURES) ) error |= !model_load_textures(q, &hdr, &m, flags);
else { else {
// setup fallback // setup fallback
material_t mt = {0}; material_t mt = {0};

View File

@ -502,8 +502,9 @@ enum MODEL_FLAGS {
MODEL_NO_ANIMATIONS = 1, MODEL_NO_ANIMATIONS = 1,
MODEL_NO_MESHES = 2, MODEL_NO_MESHES = 2,
MODEL_NO_TEXTURES = 4, MODEL_NO_TEXTURES = 4,
MODEL_MATCAPS = 8, MODEL_NO_FILTERING = 8,
MODEL_RIMLIGHT = 16 MODEL_MATCAPS = 16,
MODEL_RIMLIGHT = 32,
}; };
//@todo: make this data-driven //@todo: make this data-driven

View File

@ -8228,7 +8228,7 @@ bool vfs_mount_(const char *path, array(struct vfs_entry) *entries) {
array_push(*entries, (struct vfs_entry){filename, fileid, filesize}); array_push(*entries, (struct vfs_entry){filename, fileid, filesize});
} }
PRINTF("Mounted VFS volume '%s' (%u entries)\n", path_bak, fn_count[dir->type](dir->archive) ); // PRINTF("Mounted VFS volume '%s' (%u entries)\n", path_bak, fn_count[dir->type](dir->archive) );
} }
return 1; return 1;
@ -17294,7 +17294,7 @@ unsigned shader_geom(const char *gs, const char *vs, const char *fs, const char
while( attribs[0] && attribs[0] == ',' ) { attribs++; break; } while( attribs[0] && attribs[0] == ',' ) { attribs++; break; }
if(!attrib[0]) continue; if(!attrib[0]) continue;
glBindAttribLocation(program, i, attrib); glBindAttribLocation(program, i, attrib);
PRINTF("Shader.attribute[%d]=%s\n", i, attrib); // PRINTF("Shader.attribute[%d]=%s\n", i, attrib);
} }
#if !is(ems) // @fixme #if !is(ems) // @fixme
@ -20345,7 +20345,7 @@ static char* strcpy_safe(char *d, const char *s) {
} }
static static
bool model_load_textures(iqm_t *q, const struct iqmheader *hdr, model_t *model) { bool model_load_textures(iqm_t *q, const struct iqmheader *hdr, model_t *model, int _flags) {
q->textures = q->textures ? q->textures : CALLOC(hdr->num_meshes * 8, sizeof(GLuint)); // up to 8 textures per mesh q->textures = q->textures ? q->textures : CALLOC(hdr->num_meshes * 8, sizeof(GLuint)); // up to 8 textures per mesh
q->colormaps = q->colormaps ? q->colormaps : CALLOC(hdr->num_meshes * 8, sizeof(vec4)); // up to 8 colormaps per mesh q->colormaps = q->colormaps ? q->colormaps : CALLOC(hdr->num_meshes * 8, sizeof(vec4)); // up to 8 colormaps per mesh
@ -20376,7 +20376,9 @@ bool model_load_textures(iqm_t *q, const struct iqmheader *hdr, model_t *model)
if( reused ) continue; if( reused ) continue;
// decode texture+material // decode texture+material
int flags = TEXTURE_MIPMAPS|TEXTURE_ANISOTROPY|TEXTURE_REPEAT|TEXTURE_LINEAR; // LINEAR, NEAREST int flags = TEXTURE_MIPMAPS|TEXTURE_REPEAT|TEXTURE_ANISOTROPY; // LINEAR, NEAREST
if (!(_flags & MODEL_NO_FILTERING))
flags |= TEXTURE_LINEAR;
int invalid = texture_checker().id; int invalid = texture_checker().id;
#if 1 #if 1
@ -20526,7 +20528,7 @@ model_t model_from_mem(const void *mem, int len, int flags) {
memcpy(q->buf + sizeof(hdr), ptr, hdr.filesize - sizeof(hdr)); memcpy(q->buf + sizeof(hdr), ptr, hdr.filesize - sizeof(hdr));
error = 0; error = 0;
if( hdr.num_meshes > 0 && !(flags & MODEL_NO_MESHES) ) error |= !model_load_meshes(q, &hdr, &m); if( hdr.num_meshes > 0 && !(flags & MODEL_NO_MESHES) ) error |= !model_load_meshes(q, &hdr, &m);
if( hdr.num_meshes > 0 && !(flags & MODEL_NO_TEXTURES) ) error |= !model_load_textures(q, &hdr, &m); if( hdr.num_meshes > 0 && !(flags & MODEL_NO_TEXTURES) ) error |= !model_load_textures(q, &hdr, &m, flags);
else { else {
// setup fallback // setup fallback
material_t mt = {0}; material_t mt = {0};

View File

@ -3590,8 +3590,9 @@ enum MODEL_FLAGS {
MODEL_NO_ANIMATIONS = 1, MODEL_NO_ANIMATIONS = 1,
MODEL_NO_MESHES = 2, MODEL_NO_MESHES = 2,
MODEL_NO_TEXTURES = 4, MODEL_NO_TEXTURES = 4,
MODEL_MATCAPS = 8, MODEL_NO_FILTERING = 8,
MODEL_RIMLIGHT = 16 MODEL_MATCAPS = 16,
MODEL_RIMLIGHT = 32,
}; };
//@todo: make this data-driven //@todo: make this data-driven