From 4982761b487f366f8366bcd71f194e0acfabf791 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dominik=20Madar=C3=A1sz?= Date: Fri, 16 Feb 2024 15:38:45 +0100 Subject: [PATCH] various improvements --- bind/v4k.lua | 5 +++-- engine/joint/v4k.h | 17 ++++++++++------- engine/split/v4k_file.c | 2 +- engine/split/v4k_render.c | 10 ++++++---- engine/split/v4k_render.h | 5 +++-- engine/v4k.c | 12 +++++++----- engine/v4k.h | 5 +++-- 7 files changed, 33 insertions(+), 23 deletions(-) diff --git a/bind/v4k.lua b/bind/v4k.lua index 4f85b8b..8760a70 100644 --- a/bind/v4k.lua +++ b/bind/v4k.lua @@ -1304,8 +1304,9 @@ enum MODEL_FLAGS { MODEL_NO_ANIMATIONS = 1, MODEL_NO_MESHES = 2, MODEL_NO_TEXTURES = 4, - MODEL_MATCAPS = 8, - MODEL_RIMLIGHT = 16 + MODEL_NO_FILTERING = 8, + MODEL_MATCAPS = 16, + MODEL_RIMLIGHT = 32, }; typedef struct model_t { struct iqm_t *iqm; diff --git a/engine/joint/v4k.h b/engine/joint/v4k.h index 8a9ede3..11784f1 100644 --- a/engine/joint/v4k.h +++ b/engine/joint/v4k.h @@ -17523,8 +17523,9 @@ enum MODEL_FLAGS { MODEL_NO_ANIMATIONS = 1, MODEL_NO_MESHES = 2, MODEL_NO_TEXTURES = 4, - MODEL_MATCAPS = 8, - MODEL_RIMLIGHT = 16 + MODEL_NO_FILTERING = 8, + MODEL_MATCAPS = 16, + MODEL_RIMLIGHT = 32, }; //@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}); } - 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; @@ -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; } if(!attrib[0]) continue; glBindAttribLocation(program, i, attrib); - PRINTF("Shader.attribute[%d]=%s\n", i, attrib); + // PRINTF("Shader.attribute[%d]=%s\n", i, attrib); } #if !is(ems) // @fixme @@ -373204,7 +373205,7 @@ static char* strcpy_safe(char *d, const char *s) { } 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->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; // 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; #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)); 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_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 { // setup fallback material_t mt = {0}; diff --git a/engine/split/v4k_file.c b/engine/split/v4k_file.c index 7f427ef..111c6dd 100644 --- a/engine/split/v4k_file.c +++ b/engine/split/v4k_file.c @@ -686,7 +686,7 @@ bool vfs_mount_(const char *path, array(struct vfs_entry) *entries) { 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; diff --git a/engine/split/v4k_render.c b/engine/split/v4k_render.c index 13910cb..8a02642 100644 --- a/engine/split/v4k_render.c +++ b/engine/split/v4k_render.c @@ -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; } if(!attrib[0]) continue; glBindAttribLocation(program, i, attrib); - PRINTF("Shader.attribute[%d]=%s\n", i, attrib); + // PRINTF("Shader.attribute[%d]=%s\n", i, attrib); } #if !is(ems) // @fixme @@ -3189,7 +3189,7 @@ static char* strcpy_safe(char *d, const char *s) { } 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->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; // 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; #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)); 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_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 { // setup fallback material_t mt = {0}; diff --git a/engine/split/v4k_render.h b/engine/split/v4k_render.h index add244c..247ed04 100644 --- a/engine/split/v4k_render.h +++ b/engine/split/v4k_render.h @@ -502,8 +502,9 @@ enum MODEL_FLAGS { MODEL_NO_ANIMATIONS = 1, MODEL_NO_MESHES = 2, MODEL_NO_TEXTURES = 4, - MODEL_MATCAPS = 8, - MODEL_RIMLIGHT = 16 + MODEL_NO_FILTERING = 8, + MODEL_MATCAPS = 16, + MODEL_RIMLIGHT = 32, }; //@todo: make this data-driven diff --git a/engine/v4k.c b/engine/v4k.c index 643072f..c8c8876 100644 --- a/engine/v4k.c +++ b/engine/v4k.c @@ -8228,7 +8228,7 @@ bool vfs_mount_(const char *path, array(struct vfs_entry) *entries) { 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; @@ -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; } if(!attrib[0]) continue; glBindAttribLocation(program, i, attrib); - PRINTF("Shader.attribute[%d]=%s\n", i, attrib); + // PRINTF("Shader.attribute[%d]=%s\n", i, attrib); } #if !is(ems) // @fixme @@ -20345,7 +20345,7 @@ static char* strcpy_safe(char *d, const char *s) { } 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->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; // 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; #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)); 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_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 { // setup fallback material_t mt = {0}; diff --git a/engine/v4k.h b/engine/v4k.h index 7321b18..c609f89 100644 --- a/engine/v4k.h +++ b/engine/v4k.h @@ -3590,8 +3590,9 @@ enum MODEL_FLAGS { MODEL_NO_ANIMATIONS = 1, MODEL_NO_MESHES = 2, MODEL_NO_TEXTURES = 4, - MODEL_MATCAPS = 8, - MODEL_RIMLIGHT = 16 + MODEL_NO_FILTERING = 8, + MODEL_MATCAPS = 16, + MODEL_RIMLIGHT = 32, }; //@todo: make this data-driven