mirror of
https://github.com/nzp-team/fteqw.git
synced 2024-11-29 07:02:12 +00:00
Work around gcc bugs.
git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@5705 fc73d0e0-1445-4013-8a0c-d673dee63da5
This commit is contained in:
parent
5501fa249d
commit
ce76201081
1 changed files with 35 additions and 34 deletions
69
iqm/iqm.cpp
69
iqm/iqm.cpp
|
@ -3767,9 +3767,14 @@ bool loadfbx(const char *filename, const filespec &spec)
|
||||||
|
|
||||||
namespace fte
|
namespace fte
|
||||||
{
|
{
|
||||||
static plugfsfuncs_t cppfsfuncs =
|
static plugfsfuncs_t cppfsfuncs;
|
||||||
|
static plugmodfuncs_t cppmodfuncs;
|
||||||
|
static plugcorefuncs_t cppplugfuncs;
|
||||||
|
static plugcvarfuncs_t cppcvarfuncs;
|
||||||
|
|
||||||
|
static void SetupFTEPluginFuncs(void)
|
||||||
{
|
{
|
||||||
.OpenVFS = [](const char *filename, const char *mode, enum fs_relative relativeto)
|
cppfsfuncs.OpenVFS = [](const char *filename, const char *mode, enum fs_relative relativeto)
|
||||||
{
|
{
|
||||||
stream *f = openfile(filename, "rb");
|
stream *f = openfile(filename, "rb");
|
||||||
if (!f)
|
if (!f)
|
||||||
|
@ -3815,28 +3820,26 @@ namespace fte
|
||||||
};
|
};
|
||||||
cppfile_t *c = new cppfile_t(f);
|
cppfile_t *c = new cppfile_t(f);
|
||||||
return static_cast<vfsfile_t*>(c);
|
return static_cast<vfsfile_t*>(c);
|
||||||
},
|
};
|
||||||
};
|
|
||||||
static plugmodfuncs_t cppmodfuncs =
|
cppmodfuncs.version = MODPLUGFUNCS_VERSION;
|
||||||
{
|
cppmodfuncs.RegisterModelFormatText = [](const char *formatname, char *magictext, qboolean (QDECL *load) (struct model_s *mod, void *buffer, size_t fsize))
|
||||||
.version = MODPLUGFUNCS_VERSION,
|
|
||||||
.RegisterModelFormatText = [](const char *formatname, char *magictext, qboolean (QDECL *load) (struct model_s *mod, void *buffer, size_t fsize))
|
|
||||||
{ //called explicitly because we're lame.
|
{ //called explicitly because we're lame.
|
||||||
return 0;
|
return 0;
|
||||||
},
|
};
|
||||||
.RegisterModelFormatMagic = [](const char *formatname, unsigned int magic, qboolean (QDECL *load) (struct model_s *mod, void *buffer, size_t fsize))
|
cppmodfuncs.RegisterModelFormatMagic = [](const char *formatname, unsigned int magic, qboolean (QDECL *load) (struct model_s *mod, void *buffer, size_t fsize))
|
||||||
{ //called explicitly because we're lame.
|
{ //called explicitly because we're lame.
|
||||||
return 0;
|
return 0;
|
||||||
},
|
};
|
||||||
.ZG_Malloc = [](zonegroup_t *ctx, size_t size)
|
cppmodfuncs.ZG_Malloc = [](zonegroup_t *ctx, size_t size)
|
||||||
{
|
{
|
||||||
/*leak the memory, because we're lazy*/
|
/*leak the memory, because we're lazy*/
|
||||||
void *ret = malloc(size);
|
void *ret = malloc(size);
|
||||||
memset(ret, 0, size);
|
memset(ret, 0, size);
|
||||||
return ret;
|
return ret;
|
||||||
},
|
};
|
||||||
|
|
||||||
.ConcatTransforms = [](const float in1[3][4], const float in2[3][4], float out[3][4])
|
cppmodfuncs.ConcatTransforms = [](const float in1[3][4], const float in2[3][4], float out[3][4])
|
||||||
{
|
{
|
||||||
out[0][0] = in1[0][0] * in2[0][0] + in1[0][1] * in2[1][0] +
|
out[0][0] = in1[0][0] * in2[0][0] + in1[0][1] * in2[1][0] +
|
||||||
in1[0][2] * in2[2][0];
|
in1[0][2] * in2[2][0];
|
||||||
|
@ -3862,9 +3865,9 @@ namespace fte
|
||||||
in1[2][2] * in2[2][2];
|
in1[2][2] * in2[2][2];
|
||||||
out[2][3] = in1[2][0] * in2[0][3] + in1[2][1] * in2[1][3] +
|
out[2][3] = in1[2][0] * in2[0][3] + in1[2][1] * in2[1][3] +
|
||||||
in1[2][2] * in2[2][3] + in1[2][3];
|
in1[2][2] * in2[2][3] + in1[2][3];
|
||||||
},
|
};
|
||||||
|
|
||||||
.GenMatrixPosQuat4Scale = [](const vec3_t pos, const vec4_t quat, const vec3_t scale, float result[12])
|
cppmodfuncs.GenMatrixPosQuat4Scale = [](const vec3_t pos, const vec4_t quat, const vec3_t scale, float result[12])
|
||||||
{
|
{
|
||||||
Matrix3x4 m = Matrix3x4(Quat(quat), Vec3(pos), Vec3(scale));
|
Matrix3x4 m = Matrix3x4(Quat(quat), Vec3(pos), Vec3(scale));
|
||||||
result[0] = m.a.x;
|
result[0] = m.a.x;
|
||||||
|
@ -3881,27 +3884,25 @@ namespace fte
|
||||||
result[9] = m.b.z;
|
result[9] = m.b.z;
|
||||||
result[10] = m.c.z;
|
result[10] = m.c.z;
|
||||||
result[11] = m.c.w;
|
result[11] = m.c.w;
|
||||||
},
|
};
|
||||||
|
|
||||||
.GetTexture = [](const char *identifier, const char *subpath, unsigned int flags, void *fallbackdata, void *fallbackpalette, int fallbackwidth, int fallbackheight, uploadfmt_t fallbackfmt)
|
cppmodfuncs.GetTexture = [](const char *identifier, const char *subpath, unsigned int flags, void *fallbackdata, void *fallbackpalette, int fallbackwidth, int fallbackheight, uploadfmt_t fallbackfmt)
|
||||||
{
|
{
|
||||||
image_t *img = (image_t*)cppmodfuncs.ZG_Malloc(NULL, sizeof(*img)+strlen(identifier)+1);
|
image_t *img = (image_t*)cppmodfuncs.ZG_Malloc(NULL, sizeof(*img)+strlen(identifier)+1);
|
||||||
img->ident = (char*)(img+1);
|
img->ident = (char*)(img+1);
|
||||||
strcpy(img->ident, identifier);
|
strcpy(img->ident, identifier);
|
||||||
img->flags = flags;
|
img->flags = flags;
|
||||||
return img;
|
return img;
|
||||||
},
|
};
|
||||||
|
|
||||||
.AccumulateTextureVectors = [](vecV_t *const vc, vec2_t *const tc, vec3_t *nv, vec3_t *sv, vec3_t *tv, const index_t *idx, int numidx, qboolean calcnorms)
|
cppmodfuncs.AccumulateTextureVectors = [](vecV_t *const vc, vec2_t *const tc, vec3_t *nv, vec3_t *sv, vec3_t *tv, const index_t *idx, int numidx, qboolean calcnorms)
|
||||||
{ //once per surface that shares the set of verts
|
{ //once per surface that shares the set of verts
|
||||||
},
|
};
|
||||||
.NormaliseTextureVectors = [](vec3_t *n, vec3_t *s, vec3_t *t, int v, qboolean calcnorms)
|
cppmodfuncs.NormaliseTextureVectors = [](vec3_t *n, vec3_t *s, vec3_t *t, int v, qboolean calcnorms)
|
||||||
{ //once per shared set of verts.
|
{ //once per shared set of verts.
|
||||||
},
|
};
|
||||||
};
|
|
||||||
static plugcorefuncs_t cppplugfuncs =
|
cppplugfuncs.GetEngineInterface = [](const char *interfacename, size_t structsize)
|
||||||
{
|
|
||||||
.GetEngineInterface = [](const char *interfacename, size_t structsize)
|
|
||||||
{
|
{
|
||||||
void *ret = nullptr;
|
void *ret = nullptr;
|
||||||
if (!strcmp(interfacename, plugfsfuncs_name))
|
if (!strcmp(interfacename, plugfsfuncs_name))
|
||||||
|
@ -3909,11 +3910,9 @@ namespace fte
|
||||||
if (!strcmp(interfacename, plugmodfuncs_name))
|
if (!strcmp(interfacename, plugmodfuncs_name))
|
||||||
ret = &cppmodfuncs;
|
ret = &cppmodfuncs;
|
||||||
return ret;
|
return ret;
|
||||||
},
|
};
|
||||||
};
|
|
||||||
static plugcvarfuncs_t cppcvarfuncs =
|
cppcvarfuncs.GetNVFDG = [](const char *name, const char *defaultval, unsigned int flags, const char *description, const char *groupname)
|
||||||
{
|
|
||||||
.GetNVFDG = [](const char *name, const char *defaultval, unsigned int flags, const char *description, const char *groupname)
|
|
||||||
{ //could maybe fill with environment settings perhaps? yuck.
|
{ //could maybe fill with environment settings perhaps? yuck.
|
||||||
auto v = new cvar_t();
|
auto v = new cvar_t();
|
||||||
v->name = strdup(name);
|
v->name = strdup(name);
|
||||||
|
@ -3921,8 +3920,8 @@ namespace fte
|
||||||
v->value = atof(v->string);
|
v->value = atof(v->string);
|
||||||
v->ival = atoi(v->string);
|
v->ival = atoi(v->string);
|
||||||
return v;
|
return v;
|
||||||
},
|
};
|
||||||
};
|
}
|
||||||
extern "C"
|
extern "C"
|
||||||
{ //our plugin-style stuff has a few external dependancies not provided via pointers...
|
{ //our plugin-style stuff has a few external dependancies not provided via pointers...
|
||||||
void ImgTool_SetupPalette(void);
|
void ImgTool_SetupPalette(void);
|
||||||
|
@ -4165,6 +4164,7 @@ namespace fte
|
||||||
auto filebuf = new char[sz];
|
auto filebuf = new char[sz];
|
||||||
if (sz == f->read(filebuf, sz))
|
if (sz == f->read(filebuf, sz))
|
||||||
{
|
{
|
||||||
|
SetupFTEPluginFuncs();
|
||||||
if (Plug_GLTF_Init())
|
if (Plug_GLTF_Init())
|
||||||
if (Mod_LoadGLBModel(&mod, filebuf, sz))
|
if (Mod_LoadGLBModel(&mod, filebuf, sz))
|
||||||
ret = loadfte(&mod, spec);
|
ret = loadfte(&mod, spec);
|
||||||
|
@ -4186,6 +4186,7 @@ namespace fte
|
||||||
auto filebuf = new char[sz];
|
auto filebuf = new char[sz];
|
||||||
if (sz == f->read(filebuf, sz))
|
if (sz == f->read(filebuf, sz))
|
||||||
{
|
{
|
||||||
|
SetupFTEPluginFuncs();
|
||||||
if (Plug_GLTF_Init())
|
if (Plug_GLTF_Init())
|
||||||
if (Mod_LoadGLTFModel(&mod, filebuf, sz))
|
if (Mod_LoadGLTFModel(&mod, filebuf, sz))
|
||||||
ret = loadfte(&mod, spec);
|
ret = loadfte(&mod, spec);
|
||||||
|
|
Loading…
Reference in a new issue