More ioq3 fixes

This commit is contained in:
Richard Allen 2020-09-07 22:15:01 +00:00
parent bdbae11650
commit 31d500f76e
14 changed files with 239 additions and 120 deletions

View file

@ -1224,7 +1224,7 @@ define DO_REF_STR
$(echo_cmd) "REF_STR $<" $(echo_cmd) "REF_STR $<"
$(Q)rm -f $@ $(Q)rm -f $@
$(Q)echo "const char *fallbackShader_$(notdir $(basename $<)) =" >> $@ $(Q)echo "const char *fallbackShader_$(notdir $(basename $<)) =" >> $@
$(Q)cat $< | sed -e 's/^/\"/;s/$$/\\n\"/' | tr -d '\r' >> $@ $(Q)cat $< | sed -e 's/^\(.*\)$$/\"\1\"/' >> $@
$(Q)echo ";" >> $@ $(Q)echo ";" >> $@
endef endef

View file

@ -186,6 +186,7 @@ void CL_AddCgameCommand( const char *cmdName ) {
Cmd_AddCommand( cmdName, NULL ); Cmd_AddCommand( cmdName, NULL );
} }
/* /*
===================== =====================
CL_ConfigstringModified CL_ConfigstringModified

View file

@ -3088,8 +3088,10 @@ static __attribute__ ((format (printf, 2, 3))) void QDECL CL_RefPrintf( int prin
Com_Printf ("%s", msg); Com_Printf ("%s", msg);
} else if ( print_level == PRINT_WARNING ) { } else if ( print_level == PRINT_WARNING ) {
Com_Printf (S_COLOR_YELLOW "%s", msg); // yellow Com_Printf (S_COLOR_YELLOW "%s", msg); // yellow
} else if ( print_level == PRINT_ERROR ) {
Com_Printf (S_COLOR_RED "%s", msg); // red
} else if ( print_level == PRINT_DEVELOPER ) { } else if ( print_level == PRINT_DEVELOPER ) {
Com_DPrintf (S_COLOR_RED "%s", msg); // red Com_DPrintf (S_COLOR_RED "%s", msg); // red - developer only
} }
} }

View file

@ -288,19 +288,34 @@
# define CURL_SIZEOF_CURL_SOCKLEN_T 4 # define CURL_SIZEOF_CURL_SOCKLEN_T 4
#elif defined(__LCC__) #elif defined(__LCC__)
# define CURL_SIZEOF_LONG 4 # if defined(__e2k__) /* MCST eLbrus C Compiler */
# define CURL_TYPEOF_CURL_OFF_T long # define CURL_SIZEOF_LONG 8
# define CURL_FORMAT_CURL_OFF_T "ld" # define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_TU "lu" # define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_OFF_T "%ld" # define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_SIZEOF_CURL_OFF_T 4 # define CURL_FORMAT_OFF_T "%ld"
# define CURL_SUFFIX_CURL_OFF_T L # define CURL_SIZEOF_CURL_OFF_T 8
# define CURL_SUFFIX_CURL_OFF_TU UL # define CURL_SUFFIX_CURL_OFF_T L
# define CURL_TYPEOF_CURL_SOCKLEN_T int # define CURL_SUFFIX_CURL_OFF_TU UL
# define CURL_SIZEOF_CURL_SOCKLEN_T 4 # define CURL_TYPEOF_CURL_SOCKLEN_T socklen_t
# define CURL_SIZEOF_CURL_SOCKLEN_T 4
# define CURL_PULL_SYS_TYPES_H 1
# define CURL_PULL_SYS_SOCKET_H 1
# else /* Local (or Little) C Compiler */
# define CURL_SIZEOF_LONG 4
# define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld"
# define CURL_FORMAT_CURL_OFF_TU "lu"
# define CURL_FORMAT_OFF_T "%ld"
# define CURL_SIZEOF_CURL_OFF_T 4
# define CURL_SUFFIX_CURL_OFF_T L
# define CURL_SUFFIX_CURL_OFF_TU UL
# define CURL_TYPEOF_CURL_SOCKLEN_T int
# define CURL_SIZEOF_CURL_SOCKLEN_T 4
# endif
#elif defined(__SYMBIAN32__) #elif defined(__SYMBIAN32__)
# if defined(__EABI__) /* Treat all ARM compilers equally */ # if defined(__EABI__) /* Treat all ARM compilers equally */
# define CURL_SIZEOF_LONG 4 # define CURL_SIZEOF_LONG 4
# define CURL_TYPEOF_CURL_OFF_T long long # define CURL_TYPEOF_CURL_OFF_T long long
# define CURL_FORMAT_CURL_OFF_T "lld" # define CURL_FORMAT_CURL_OFF_T "lld"
@ -539,7 +554,8 @@
# define CURL_SUFFIX_CURL_OFF_T LL # define CURL_SUFFIX_CURL_OFF_T LL
# define CURL_SUFFIX_CURL_OFF_TU ULL # define CURL_SUFFIX_CURL_OFF_TU ULL
# elif defined(__LP64__) || \ # elif defined(__LP64__) || \
defined(__x86_64__) || defined(__ppc64__) || defined(__powerpc64__) || defined(__sparc64__) defined(__x86_64__) || defined(__ppc64__) || defined(__powerpc64__) || defined(__sparc64__) || \
defined(__e2k__) /* MCST Elbrus 2000 */
# define CURL_SIZEOF_LONG 8 # define CURL_SIZEOF_LONG 8
# define CURL_TYPEOF_CURL_OFF_T long # define CURL_TYPEOF_CURL_OFF_T long
# define CURL_FORMAT_CURL_OFF_T "ld" # define CURL_FORMAT_CURL_OFF_T "ld"

View file

@ -80,6 +80,7 @@ extern glconfig_t glConfig; // outside of TR since it shouldn't be cleared duri
extern qboolean textureFilterAnisotropic; extern qboolean textureFilterAnisotropic;
extern int maxAnisotropy; extern int maxAnisotropy;
extern float displayAspect; extern float displayAspect;
extern qboolean haveClampToEdge;
// //
// cvars // cvars

View file

@ -794,8 +794,8 @@ void RE_UploadCinematic (int w, int h, int cols, int rows, const byte *data, int
qglTexImage2D( GL_TEXTURE_2D, 0, GL_RGB8, cols, rows, 0, GL_RGBA, GL_UNSIGNED_BYTE, data ); qglTexImage2D( GL_TEXTURE_2D, 0, GL_RGB8, cols, rows, 0, GL_RGBA, GL_UNSIGNED_BYTE, data );
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR ); qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ); qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, haveClampToEdge ? GL_CLAMP_TO_EDGE : GL_CLAMP );
qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); qglTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, haveClampToEdge ? GL_CLAMP_TO_EDGE : GL_CLAMP );
} else { } else {
if (dirty) { if (dirty) {
// otherwise, just subimage upload it so that drivers can tell we are going to be changing // otherwise, just subimage upload it so that drivers can tell we are going to be changing

View file

@ -866,7 +866,7 @@ image_t *R_CreateImage( const char *name, byte *pic, int width, int height,
image->width = width; image->width = width;
image->height = height; image->height = height;
if (flags & IMGFLAG_CLAMPTOEDGE) if (flags & IMGFLAG_CLAMPTOEDGE)
glWrapClampMode = GL_CLAMP_TO_EDGE; glWrapClampMode = haveClampToEdge ? GL_CLAMP_TO_EDGE : GL_CLAMP;
else else
glWrapClampMode = GL_REPEAT; glWrapClampMode = GL_REPEAT;

View file

@ -27,6 +27,7 @@ glconfig_t glConfig;
qboolean textureFilterAnisotropic = qfalse; qboolean textureFilterAnisotropic = qfalse;
int maxAnisotropy = 0; int maxAnisotropy = 0;
float displayAspect = 0.0f; float displayAspect = 0.0f;
qboolean haveClampToEdge = qfalse;
glstate_t glState; glstate_t glState;
@ -1294,6 +1295,7 @@ void RE_Shutdown( qboolean destroyWindow ) {
textureFilterAnisotropic = qfalse; textureFilterAnisotropic = qfalse;
maxAnisotropy = 0; maxAnisotropy = 0;
displayAspect = 0.0f; displayAspect = 0.0f;
haveClampToEdge = qfalse;
Com_Memset( &glState, 0, sizeof( glState ) ); Com_Memset( &glState, 0, sizeof( glState ) );
} }

View file

@ -589,6 +589,12 @@ typedef struct {
drawVert_t *verts; drawVert_t *verts;
} srfTriangles_t; } srfTriangles_t;
typedef struct {
vec3_t translate;
quat_t rotate;
vec3_t scale;
} iqmTransform_t;
// inter-quake-model // inter-quake-model
typedef struct { typedef struct {
int num_vertexes; int num_vertexes;
@ -623,8 +629,9 @@ typedef struct {
char *jointNames; char *jointNames;
int *jointParents; int *jointParents;
float *jointMats; float *bindJoints; // [num_joints * 12]
float *poseMats; float *invBindJoints; // [num_joints * 12]
iqmTransform_t *poses; // [num_frames * num_poses]
float *bounds; float *bounds;
} iqmData_t; } iqmData_t;

View file

@ -2,6 +2,7 @@
=========================================================================== ===========================================================================
Copyright (C) 2011 Thilo Schulz <thilo@tjps.eu> Copyright (C) 2011 Thilo Schulz <thilo@tjps.eu>
Copyright (C) 2011 Matthias Bentrup <matthias.bentrup@googlemail.com> Copyright (C) 2011 Matthias Bentrup <matthias.bentrup@googlemail.com>
Copyright (C) 2011-2019 Zack Middleton <zturtleman@gmail.com>
This file is part of Quake III Arena source code. This file is part of Quake III Arena source code.
@ -44,7 +45,7 @@ static qboolean IQM_CheckRange( iqmHeader_t *header, int offset,
} }
// "multiply" 3x4 matrices, these are assumed to be the top 3 rows // "multiply" 3x4 matrices, these are assumed to be the top 3 rows
// of a 4x4 matrix with the last row = (0 0 0 1) // of a 4x4 matrix with the last row = (0 0 0 1)
static void Matrix34Multiply( float *a, float *b, float *out ) { static void Matrix34Multiply( const float *a, const float *b, float *out ) {
out[ 0] = a[0] * b[0] + a[1] * b[4] + a[ 2] * b[ 8]; out[ 0] = a[0] * b[0] + a[1] * b[4] + a[ 2] * b[ 8];
out[ 1] = a[0] * b[1] + a[1] * b[5] + a[ 2] * b[ 9]; out[ 1] = a[0] * b[1] + a[1] * b[5] + a[ 2] * b[ 9];
out[ 2] = a[0] * b[2] + a[1] * b[6] + a[ 2] * b[10]; out[ 2] = a[0] * b[2] + a[1] * b[6] + a[ 2] * b[10];
@ -58,23 +59,7 @@ static void Matrix34Multiply( float *a, float *b, float *out ) {
out[10] = a[8] * b[2] + a[9] * b[6] + a[10] * b[10]; out[10] = a[8] * b[2] + a[9] * b[6] + a[10] * b[10];
out[11] = a[8] * b[3] + a[9] * b[7] + a[10] * b[11] + a[11]; out[11] = a[8] * b[3] + a[9] * b[7] + a[10] * b[11] + a[11];
} }
static void InterpolateMatrix( float *a, float *b, float lerp, float *mat ) { static void JointToMatrix( const quat_t rot, const vec3_t scale, const vec3_t trans,
float unLerp = 1.0f - lerp;
mat[ 0] = a[ 0] * unLerp + b[ 0] * lerp;
mat[ 1] = a[ 1] * unLerp + b[ 1] * lerp;
mat[ 2] = a[ 2] * unLerp + b[ 2] * lerp;
mat[ 3] = a[ 3] * unLerp + b[ 3] * lerp;
mat[ 4] = a[ 4] * unLerp + b[ 4] * lerp;
mat[ 5] = a[ 5] * unLerp + b[ 5] * lerp;
mat[ 6] = a[ 6] * unLerp + b[ 6] * lerp;
mat[ 7] = a[ 7] * unLerp + b[ 7] * lerp;
mat[ 8] = a[ 8] * unLerp + b[ 8] * lerp;
mat[ 9] = a[ 9] * unLerp + b[ 9] * lerp;
mat[10] = a[10] * unLerp + b[10] * lerp;
mat[11] = a[11] * unLerp + b[11] * lerp;
}
static void JointToMatrix( vec4_t rot, vec3_t scale, vec3_t trans,
float *mat ) { float *mat ) {
float xx = 2.0f * rot[0] * rot[0]; float xx = 2.0f * rot[0] * rot[0];
float yy = 2.0f * rot[1] * rot[1]; float yy = 2.0f * rot[1] * rot[1];
@ -99,8 +84,7 @@ static void JointToMatrix( vec4_t rot, vec3_t scale, vec3_t trans,
mat[10] = scale[2] * (1.0f - (xx + yy)); mat[10] = scale[2] * (1.0f - (xx + yy));
mat[11] = trans[2]; mat[11] = trans[2];
} }
static void Matrix34Invert( float *inMat, float *outMat ) static void Matrix34Invert( const float *inMat, float *outMat ) {
{
vec3_t trans; vec3_t trans;
float invSqrLen, *v; float invSqrLen, *v;
@ -120,6 +104,62 @@ static void Matrix34Invert( float *inMat, float *outMat )
outMat[ 7] = -DotProduct(outMat + 4, trans); outMat[ 7] = -DotProduct(outMat + 4, trans);
outMat[11] = -DotProduct(outMat + 8, trans); outMat[11] = -DotProduct(outMat + 8, trans);
} }
static void QuatSlerp(const quat_t from, const quat_t _to, float fraction, quat_t out) {
float angle, cosAngle, sinAngle, backlerp, lerp;
quat_t to;
// cos() of angle
cosAngle = from[0] * _to[0] + from[1] * _to[1] + from[2] * _to[2] + from[3] * _to[3];
// negative handling is needed for taking shortest path (required for model joints)
if ( cosAngle < 0.0f ) {
cosAngle = -cosAngle;
to[0] = - _to[0];
to[1] = - _to[1];
to[2] = - _to[2];
to[3] = - _to[3];
} else {
QuatCopy( _to, to );
}
if ( cosAngle < 0.999999f ) {
// spherical lerp (slerp)
angle = acosf( cosAngle );
sinAngle = sinf( angle );
backlerp = sinf( ( 1.0f - fraction ) * angle ) / sinAngle;
lerp = sinf( fraction * angle ) / sinAngle;
} else {
// linear lerp
backlerp = 1.0f - fraction;
lerp = fraction;
}
out[0] = from[0] * backlerp + to[0] * lerp;
out[1] = from[1] * backlerp + to[1] * lerp;
out[2] = from[2] * backlerp + to[2] * lerp;
out[3] = from[3] * backlerp + to[3] * lerp;
}
static vec_t QuatNormalize2( const quat_t v, quat_t out) {
float length, ilength;
length = v[0]*v[0] + v[1]*v[1] + v[2]*v[2] + v[3]*v[3];
if (length) {
/* writing it this way allows gcc to recognize that rsqrt can be used */
ilength = 1/(float)sqrt (length);
/* sqrt(length) = length * (1 / sqrt(length)) */
length *= ilength;
out[0] = v[0]*ilength;
out[1] = v[1]*ilength;
out[2] = v[2]*ilength;
out[3] = v[3]*ilength;
} else {
out[0] = out[1] = out[2] = 0;
out[3] = -1;
}
return length;
}
/* /*
================= =================
@ -139,7 +179,7 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na
unsigned short *framedata; unsigned short *framedata;
char *str; char *str;
int i, j, k; int i, j, k;
float jointInvMats[IQM_MAX_JOINTS * 12] = {0.0f}; iqmTransform_t *transform;
float *mat, *matInv; float *mat, *matInv;
size_t size, joint_names; size_t size, joint_names;
byte *dataPtr; byte *dataPtr;
@ -559,10 +599,11 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na
if( header->num_joints ) { if( header->num_joints ) {
size += joint_names; // joint names size += joint_names; // joint names
size += header->num_joints * sizeof(int); // joint parents size += header->num_joints * sizeof(int); // joint parents
size += header->num_joints * 12 * sizeof( float ); // joint mats size += header->num_joints * 12 * sizeof(float); // bind joint matricies
size += header->num_joints * 12 * sizeof(float); // inverse bind joint matricies
} }
if( header->num_poses ) { if( header->num_poses ) {
size += header->num_poses * header->num_frames * 12 * sizeof( float ); // pose mats size += header->num_poses * header->num_frames * sizeof(iqmTransform_t); // pose transforms
} }
if( header->ofs_bounds ) { if( header->ofs_bounds ) {
size += header->num_frames * 6 * sizeof(float); // model bounds size += header->num_frames * 6 * sizeof(float); // model bounds
@ -633,12 +674,15 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na
iqmData->jointParents = (int*)dataPtr; iqmData->jointParents = (int*)dataPtr;
dataPtr += header->num_joints * sizeof(int); // joint parents dataPtr += header->num_joints * sizeof(int); // joint parents
iqmData->jointMats = (float*)dataPtr; iqmData->bindJoints = (float*)dataPtr;
dataPtr += header->num_joints * 12 * sizeof( float ); // joint mats dataPtr += header->num_joints * 12 * sizeof(float); // bind joint matricies
iqmData->invBindJoints = (float*)dataPtr;
dataPtr += header->num_joints * 12 * sizeof(float); // inverse bind joint matricies
} }
if( header->num_poses ) { if( header->num_poses ) {
iqmData->poseMats = (float*)dataPtr; iqmData->poses = (iqmTransform_t*)dataPtr;
dataPtr += header->num_poses * header->num_frames * 12 * sizeof( float ); // pose mats dataPtr += header->num_poses * header->num_frames * sizeof(iqmTransform_t); // pose transforms
} }
if( header->ofs_bounds ) { if( header->ofs_bounds ) {
iqmData->bounds = (float*)dataPtr; iqmData->bounds = (float*)dataPtr;
@ -804,22 +848,23 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na
iqmData->jointParents[i] = joint->parent; iqmData->jointParents[i] = joint->parent;
} }
// calculate joint matrices and their inverses // calculate bind joint matrices and their inverses
// joint inverses are needed only until the pose matrices are calculated mat = iqmData->bindJoints;
mat = iqmData->jointMats; matInv = iqmData->invBindJoints;
matInv = jointInvMats;
joint = (iqmJoint_t *)((byte *)header + header->ofs_joints); joint = (iqmJoint_t *)((byte *)header + header->ofs_joints);
for( i = 0; i < header->num_joints; i++, joint++ ) { for( i = 0; i < header->num_joints; i++, joint++ ) {
float baseFrame[12], invBaseFrame[12]; float baseFrame[12], invBaseFrame[12];
QuatNormalize2( joint->rotate, joint->rotate );
JointToMatrix( joint->rotate, joint->scale, joint->translate, baseFrame ); JointToMatrix( joint->rotate, joint->scale, joint->translate, baseFrame );
Matrix34Invert( baseFrame, invBaseFrame ); Matrix34Invert( baseFrame, invBaseFrame );
if ( joint->parent >= 0 ) if ( joint->parent >= 0 )
{ {
Matrix34Multiply( iqmData->jointMats + 12 * joint->parent, baseFrame, mat ); Matrix34Multiply( iqmData->bindJoints + 12 * joint->parent, baseFrame, mat );
mat += 12; mat += 12;
Matrix34Multiply( invBaseFrame, jointInvMats + 12 * joint->parent, matInv ); Matrix34Multiply( invBaseFrame, iqmData->invBindJoints + 12 * joint->parent, matInv );
matInv += 12; matInv += 12;
} }
else else
@ -834,16 +879,15 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na
if( header->num_poses ) if( header->num_poses )
{ {
// calculate pose matrices // calculate pose transforms
transform = iqmData->poses;
framedata = (unsigned short *)((byte *)header + header->ofs_frames); framedata = (unsigned short *)((byte *)header + header->ofs_frames);
mat = iqmData->poseMats;
for( i = 0; i < header->num_frames; i++ ) { for( i = 0; i < header->num_frames; i++ ) {
pose = (iqmPose_t *)((byte *)header + header->ofs_poses); pose = (iqmPose_t *)((byte *)header + header->ofs_poses);
for( j = 0; j < header->num_poses; j++, pose++ ) { for( j = 0; j < header->num_poses; j++, pose++, transform++ ) {
vec3_t translate; vec3_t translate;
vec4_t rotate; quat_t rotate;
vec3_t scale; vec3_t scale;
float mat1[12], mat2[12];
translate[0] = pose->channeloffset[0]; translate[0] = pose->channeloffset[0];
if( pose->mask & 0x001) if( pose->mask & 0x001)
@ -878,18 +922,9 @@ qboolean R_LoadIQM( model_t *mod, void *buffer, int filesize, const char *mod_na
if( pose->mask & 0x200) if( pose->mask & 0x200)
scale[2] += *framedata++ * pose->channelscale[9]; scale[2] += *framedata++ * pose->channelscale[9];
// construct transformation matrix VectorCopy( translate, transform->translate );
JointToMatrix( rotate, scale, translate, mat1 ); QuatNormalize2( rotate, transform->rotate );
VectorCopy( scale, transform->scale );
if( pose->parent >= 0 ) {
Matrix34Multiply( iqmData->jointMats + 12 * pose->parent,
mat1, mat2 );
} else {
Com_Memcpy( mat2, mat1, sizeof(mat1) );
}
Matrix34Multiply( mat2, jointInvMats + 12 * j, mat );
mat += 12;
} }
} }
} }
@ -1128,37 +1163,59 @@ void R_AddIQMSurfaces( trRefEntity_t *ent ) {
static void ComputePoseMats( iqmData_t *data, int frame, int oldframe, static void ComputePoseMats( iqmData_t *data, int frame, int oldframe,
float backlerp, float *mat ) { float backlerp, float *poseMats ) {
float *mat1, *mat2; iqmTransform_t relativeJoints[IQM_MAX_JOINTS];
int *joint = data->jointParents; iqmTransform_t *relativeJoint;
int i; const iqmTransform_t *pose;
const iqmTransform_t *oldpose;
const int *jointParent;
const float *invBindMat;
float *poseMat, lerp;
int i;
relativeJoint = relativeJoints;
// copy or lerp animation frame pose
if ( oldframe == frame ) { if ( oldframe == frame ) {
mat1 = data->poseMats + 12 * data->num_poses * frame; pose = &data->poses[frame * data->num_poses];
for( i = 0; i < data->num_poses; i++, joint++ ) { for ( i = 0; i < data->num_poses; i++, pose++, relativeJoint++ ) {
if( *joint >= 0 ) { VectorCopy( pose->translate, relativeJoint->translate );
Matrix34Multiply( mat + 12 * *joint, QuatCopy( pose->rotate, relativeJoint->rotate );
mat1 + 12*i, mat + 12*i ); VectorCopy( pose->scale, relativeJoint->scale );
} else {
Com_Memcpy( mat + 12*i, mat1 + 12*i, 12 * sizeof(float) );
}
} }
} else { } else {
mat1 = data->poseMats + 12 * data->num_poses * frame; lerp = 1.0f - backlerp;
mat2 = data->poseMats + 12 * data->num_poses * oldframe; pose = &data->poses[frame * data->num_poses];
oldpose = &data->poses[oldframe * data->num_poses];
for( i = 0; i < data->num_poses; i++, joint++ ) { for ( i = 0; i < data->num_poses; i++, oldpose++, pose++, relativeJoint++ ) {
if( *joint >= 0 ) { relativeJoint->translate[0] = oldpose->translate[0] * backlerp + pose->translate[0] * lerp;
float tmpMat[12]; relativeJoint->translate[1] = oldpose->translate[1] * backlerp + pose->translate[1] * lerp;
InterpolateMatrix( mat1 + 12*i, mat2 + 12*i, relativeJoint->translate[2] = oldpose->translate[2] * backlerp + pose->translate[2] * lerp;
backlerp, tmpMat );
Matrix34Multiply( mat + 12 * *joint, relativeJoint->scale[0] = oldpose->scale[0] * backlerp + pose->scale[0] * lerp;
tmpMat, mat + 12*i ); relativeJoint->scale[1] = oldpose->scale[1] * backlerp + pose->scale[1] * lerp;
relativeJoint->scale[2] = oldpose->scale[2] * backlerp + pose->scale[2] * lerp;
} else {
InterpolateMatrix( mat1 + 12*i, mat2 + 12*i, QuatSlerp( oldpose->rotate, pose->rotate, lerp, relativeJoint->rotate );
backlerp, mat + 12*i ); }
} }
// multiply by inverse of bind pose and parent 'pose mat' (bind pose transform matrix)
relativeJoint = relativeJoints;
jointParent = data->jointParents;
invBindMat = data->invBindJoints;
poseMat = poseMats;
for ( i = 0; i < data->num_poses; i++, relativeJoint++, jointParent++, invBindMat += 12, poseMat += 12 ) {
float mat1[12], mat2[12];
JointToMatrix( relativeJoint->rotate, relativeJoint->scale, relativeJoint->translate, mat1 );
if ( *jointParent >= 0 ) {
Matrix34Multiply( &data->bindJoints[(*jointParent)*12], mat1, mat2 );
Matrix34Multiply( mat2, invBindMat, mat1 );
Matrix34Multiply( &poseMats[(*jointParent)*12], mat1, poseMat );
} else {
Matrix34Multiply( mat1, invBindMat, poseMat );
} }
} }
} }
@ -1169,7 +1226,7 @@ static void ComputeJointMats( iqmData_t *data, int frame, int oldframe,
int i; int i;
if ( data->num_poses == 0 ) { if ( data->num_poses == 0 ) {
Com_Memcpy( mat, data->jointMats, data->num_joints * 12 * sizeof(float) ); Com_Memcpy( mat, data->bindJoints, data->num_joints * 12 * sizeof(float) );
return; return;
} }
@ -1181,7 +1238,7 @@ static void ComputeJointMats( iqmData_t *data, int frame, int oldframe,
Com_Memcpy(outmat, mat1, sizeof(outmat)); Com_Memcpy(outmat, mat1, sizeof(outmat));
Matrix34Multiply( outmat, data->jointMats + 12*i, mat1 ); Matrix34Multiply( outmat, data->bindJoints + 12*i, mat1 );
} }
} }
@ -1246,19 +1303,20 @@ void RB_IQMSurfaceAnim( surfaceType_t *surface ) {
float *nrmMat = &influenceNrmMat[9*i]; float *nrmMat = &influenceNrmMat[9*i];
int j; int j;
float blendWeights[4]; float blendWeights[4];
int numWeights;
for ( numWeights = 0; numWeights < 4; numWeights++ ) { if ( data->blendWeightsType == IQM_FLOAT ) {
if ( data->blendWeightsType == IQM_FLOAT ) blendWeights[0] = data->influenceBlendWeights.f[4*influence + 0];
blendWeights[numWeights] = data->influenceBlendWeights.f[4*influence + numWeights]; blendWeights[1] = data->influenceBlendWeights.f[4*influence + 1];
else blendWeights[2] = data->influenceBlendWeights.f[4*influence + 2];
blendWeights[numWeights] = (float)data->influenceBlendWeights.b[4*influence + numWeights] / 255.0f; blendWeights[3] = data->influenceBlendWeights.f[4*influence + 3];
} else {
if ( blendWeights[numWeights] <= 0.0f ) blendWeights[0] = (float)data->influenceBlendWeights.b[4*influence + 0] / 255.0f;
break; blendWeights[1] = (float)data->influenceBlendWeights.b[4*influence + 1] / 255.0f;
blendWeights[2] = (float)data->influenceBlendWeights.b[4*influence + 2] / 255.0f;
blendWeights[3] = (float)data->influenceBlendWeights.b[4*influence + 3] / 255.0f;
} }
if ( numWeights == 0 ) { if ( blendWeights[0] <= 0.0f ) {
// no blend joint, use identity matrix. // no blend joint, use identity matrix.
vtxMat[0] = identityMatrix[0]; vtxMat[0] = identityMatrix[0];
vtxMat[1] = identityMatrix[1]; vtxMat[1] = identityMatrix[1];
@ -1288,7 +1346,11 @@ void RB_IQMSurfaceAnim( surfaceType_t *surface ) {
vtxMat[10] = blendWeights[0] * poseMats[12 * data->influenceBlendIndexes[4*influence + 0] + 10]; vtxMat[10] = blendWeights[0] * poseMats[12 * data->influenceBlendIndexes[4*influence + 0] + 10];
vtxMat[11] = blendWeights[0] * poseMats[12 * data->influenceBlendIndexes[4*influence + 0] + 11]; vtxMat[11] = blendWeights[0] * poseMats[12 * data->influenceBlendIndexes[4*influence + 0] + 11];
for( j = 1; j < numWeights; j++ ) { for( j = 1; j < 3; j++ ) {
if ( blendWeights[j] <= 0.0f ) {
break;
}
vtxMat[0] += blendWeights[j] * poseMats[12 * data->influenceBlendIndexes[4*influence + j] + 0]; vtxMat[0] += blendWeights[j] * poseMats[12 * data->influenceBlendIndexes[4*influence + j] + 0];
vtxMat[1] += blendWeights[j] * poseMats[12 * data->influenceBlendIndexes[4*influence + j] + 1]; vtxMat[1] += blendWeights[j] * poseMats[12 * data->influenceBlendIndexes[4*influence + j] + 1];
vtxMat[2] += blendWeights[j] * poseMats[12 * data->influenceBlendIndexes[4*influence + j] + 2]; vtxMat[2] += blendWeights[j] * poseMats[12 * data->influenceBlendIndexes[4*influence + j] + 2];

View file

@ -261,7 +261,7 @@ static qboolean GLimp_GetProcAddresses( qboolean fixedFunction ) {
version = (const char *)qglGetString( GL_VERSION ); version = (const char *)qglGetString( GL_VERSION );
if ( !version ) { if ( !version ) {
Com_Error( ERR_FATAL, "GL_VERSION is NULL\n" ); Com_Error( ERR_FATAL, "GL_VERSION is NULL" );
} }
if ( Q_stricmpn( "OpenGL ES", version, 9 ) == 0 ) { if ( Q_stricmpn( "OpenGL ES", version, 9 ) == 0 ) {
@ -277,7 +277,7 @@ static qboolean GLimp_GetProcAddresses( qboolean fixedFunction ) {
} }
if ( fixedFunction ) { if ( fixedFunction ) {
if ( QGL_VERSION_ATLEAST( 1, 2 ) ) { if ( QGL_VERSION_ATLEAST( 1, 1 ) ) {
QGL_1_1_PROCS; QGL_1_1_PROCS;
QGL_1_1_FIXED_FUNCTION_PROCS; QGL_1_1_FIXED_FUNCTION_PROCS;
QGL_DESKTOP_1_1_PROCS; QGL_DESKTOP_1_1_PROCS;
@ -289,9 +289,9 @@ static qboolean GLimp_GetProcAddresses( qboolean fixedFunction ) {
QGL_ES_1_1_PROCS; QGL_ES_1_1_PROCS;
QGL_ES_1_1_FIXED_FUNCTION_PROCS; QGL_ES_1_1_FIXED_FUNCTION_PROCS;
// error so this doesn't segfault due to NULL desktop GL functions being used // error so this doesn't segfault due to NULL desktop GL functions being used
Com_Error( ERR_FATAL, "Unsupported OpenGL Version: %s\n", version ); Com_Error( ERR_FATAL, "Unsupported OpenGL Version: %s", version );
} else { } else {
Com_Error( ERR_FATAL, "Unsupported OpenGL Version (%s), OpenGL 1.2 is required\n", version ); Com_Error( ERR_FATAL, "Unsupported OpenGL Version (%s), OpenGL 1.1 is required", version );
} }
} else { } else {
if ( QGL_VERSION_ATLEAST( 2, 0 ) ) { if ( QGL_VERSION_ATLEAST( 2, 0 ) ) {
@ -307,9 +307,9 @@ static qboolean GLimp_GetProcAddresses( qboolean fixedFunction ) {
QGL_1_5_PROCS; QGL_1_5_PROCS;
QGL_2_0_PROCS; QGL_2_0_PROCS;
// error so this doesn't segfault due to NULL desktop GL functions being used // error so this doesn't segfault due to NULL desktop GL functions being used
Com_Error( ERR_FATAL, "Unsupported OpenGL Version: %s\n", version ); Com_Error( ERR_FATAL, "Unsupported OpenGL Version: %s", version );
} else { } else {
Com_Error( ERR_FATAL, "Unsupported OpenGL Version (%s), OpenGL 2.0 is required\n", version ); Com_Error( ERR_FATAL, "Unsupported OpenGL Version (%s), OpenGL 2.0 is required", version );
} }
} }
@ -779,13 +779,13 @@ static qboolean GLimp_StartDriverAndSetMode(int mode, qboolean fullscreen, qbool
fullscreen = qfalse; fullscreen = qfalse;
} }
if (!fullscreen && mode == -2) /* if (!fullscreen && mode == -2)
{ {
ri.Printf( PRINT_ALL, "Windowed not allowed with r_mode -2\n"); ri.Printf( PRINT_ALL, "Windowed not allowed with r_mode -2\n");
ri.Cvar_Set( "r_fullscreen", "1" ); ri.Cvar_Set( "r_fullscreen", "1" );
r_fullscreen->modified = qfalse; r_fullscreen->modified = qfalse;
fullscreen = qtrue; fullscreen = qtrue;
} } */
err = GLimp_SetMode(mode, fullscreen, noborder, gl3Core); err = GLimp_SetMode(mode, fullscreen, noborder, gl3Core);
@ -973,6 +973,17 @@ static void GLimp_InitExtensions( qboolean fixedFunction )
{ {
ri.Printf( PRINT_ALL, "...GL_EXT_texture_filter_anisotropic not found\n" ); ri.Printf( PRINT_ALL, "...GL_EXT_texture_filter_anisotropic not found\n" );
} }
haveClampToEdge = qfalse;
if ( QGL_VERSION_ATLEAST( 1, 2 ) || QGLES_VERSION_ATLEAST( 1, 0 ) || SDL_GL_ExtensionSupported( "GL_SGIS_texture_edge_clamp" ) )
{
ri.Printf( PRINT_ALL, "...using GL_SGIS_texture_edge_clamp\n" );
haveClampToEdge = qtrue;
}
else
{
ri.Printf( PRINT_ALL, "...GL_SGIS_texture_edge_clamp not found\n" );
}
} }
#define R_MODE_FALLBACK 3 // 640 * 480 #define R_MODE_FALLBACK 3 // 640 * 480

View file

@ -19,6 +19,15 @@ int ifdepth;
int ifsatisfied[NIF]; int ifsatisfied[NIF];
int skipping; int skipping;
time_t reproducible_time()
{
char *source_date_epoch;
time_t t;
if ((source_date_epoch = getenv("SOURCE_DATE_EPOCH")) == NULL ||
(t = (time_t)strtol(source_date_epoch, NULL, 10)) <= 0)
return time(NULL);
return t;
}
int int
main(int argc, char **argv) main(int argc, char **argv)
@ -28,7 +37,7 @@ main(int argc, char **argv)
char ebuf[BUFSIZ]; char ebuf[BUFSIZ];
setbuf(stderr, ebuf); setbuf(stderr, ebuf);
t = time(NULL); t = reproducible_time();
curtime = ctime(&t); curtime = ctime(&t);
maketokenrow(3, &tr); maketokenrow(3, &tr);
expandlex(); expandlex();

View file

@ -38,7 +38,10 @@ void UpdatePaths( const char *lccBinary )
strncpy( basepath, lccBinary, basepathsz ); strncpy( basepath, lccBinary, basepathsz );
basepath[basepathsz] = 0; basepath[basepathsz] = 0;
p = strrchr( basepath, PATH_SEP ); p = strrchr( basepath, '/' );
if( !p )
p = strrchr( basepath, '\\' );
if( p ) if( p )
{ {

View file

@ -184,6 +184,11 @@ Cvars for advanced material usage:
1 - Use parallax occlusion mapping. 1 - Use parallax occlusion mapping.
2 - Use relief mapping. (slower) 2 - Use relief mapping. (slower)
* `r_parallaxMapShadows` - Enable self-shadowing on parallax map
supported materials.
0 - No. (default)
1 - Yes.
* `r_baseSpecular` - Set the specular reflectance of materials * `r_baseSpecular` - Set the specular reflectance of materials
which don't include a specular map or which don't include a specular map or
use the specularReflectance keyword. use the specularReflectance keyword.