Fix rendering IQM models between model frames
For lerped frames (refEntity_t frame not equal oldframe) IQM joint matrices may have incorrect axis scale. This can cause significant model distortion. The matrix lerp is linear causing each vector to move in a straight line between frames instead of arcing like a circle. Each joint frame can have a different scale so can't just normalize the joint matrix. Store joints as quaternions and spherical lerp between them and then convert to a matrix. For my test model, setting up the skeleton is four times slower now but it still seems to be fast enough to be usable.
This commit is contained in:
parent
d13d06424e
commit
d404519cce
5 changed files with 294 additions and 164 deletions
|
@ -954,6 +954,12 @@ typedef struct srfBspSurface_s
|
|||
float *heightLodError;
|
||||
} srfBspSurface_t;
|
||||
|
||||
typedef struct {
|
||||
vec3_t translate;
|
||||
quat_t rotate;
|
||||
vec3_t scale;
|
||||
} iqmTransform_t;
|
||||
|
||||
// inter-quake-model
|
||||
typedef struct {
|
||||
int num_vertexes;
|
||||
|
@ -988,8 +994,9 @@ typedef struct {
|
|||
|
||||
char *jointNames;
|
||||
int *jointParents;
|
||||
float *jointMats;
|
||||
float *poseMats;
|
||||
float *bindJoints; // [num_joints * 12]
|
||||
float *invBindJoints; // [num_joints * 12]
|
||||
iqmTransform_t *poses; // [num_frames * num_poses]
|
||||
float *bounds;
|
||||
|
||||
int numVaoSurfaces;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue