mirror of
https://github.com/UberGames/lilium-voyager.git
synced 2024-11-10 06:31:47 +00:00
Fix predicting entity origin on rotating mover
Based on G_TryPushingEntity() in code/game/g_mover.c.
This commit is contained in:
parent
812a3dbfa5
commit
33a899d6dd
1 changed files with 49 additions and 1 deletions
|
@ -664,6 +664,44 @@ static void CG_Portal( centity_t *cent ) {
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
================
|
||||
CG_CreateRotationMatrix
|
||||
================
|
||||
*/
|
||||
void CG_CreateRotationMatrix(vec3_t angles, vec3_t matrix[3]) {
|
||||
AngleVectors(angles, matrix[0], matrix[1], matrix[2]);
|
||||
VectorInverse(matrix[1]);
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
CG_TransposeMatrix
|
||||
================
|
||||
*/
|
||||
void CG_TransposeMatrix(vec3_t matrix[3], vec3_t transpose[3]) {
|
||||
int i, j;
|
||||
for (i = 0; i < 3; i++) {
|
||||
for (j = 0; j < 3; j++) {
|
||||
transpose[i][j] = matrix[j][i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
================
|
||||
CG_RotatePoint
|
||||
================
|
||||
*/
|
||||
void CG_RotatePoint(vec3_t point, vec3_t matrix[3]) {
|
||||
vec3_t tvec;
|
||||
|
||||
VectorCopy(point, tvec);
|
||||
point[0] = DotProduct(matrix[0], tvec);
|
||||
point[1] = DotProduct(matrix[1], tvec);
|
||||
point[2] = DotProduct(matrix[2], tvec);
|
||||
}
|
||||
|
||||
/*
|
||||
=========================
|
||||
CG_AdjustPositionForMover
|
||||
|
@ -675,6 +713,8 @@ void CG_AdjustPositionForMover(const vec3_t in, int moverNum, int fromTime, int
|
|||
centity_t *cent;
|
||||
vec3_t oldOrigin, origin, deltaOrigin;
|
||||
vec3_t oldAngles, angles, deltaAngles;
|
||||
vec3_t matrix[3], transpose[3];
|
||||
vec3_t org, org2, move2;
|
||||
|
||||
if ( moverNum <= 0 || moverNum >= ENTITYNUM_MAX_NORMAL ) {
|
||||
VectorCopy( in, out );
|
||||
|
@ -698,9 +738,17 @@ void CG_AdjustPositionForMover(const vec3_t in, int moverNum, int fromTime, int
|
|||
VectorSubtract( origin, oldOrigin, deltaOrigin );
|
||||
VectorSubtract( angles, oldAngles, deltaAngles );
|
||||
|
||||
// origin change when on a rotating object
|
||||
CG_CreateRotationMatrix( deltaAngles, transpose );
|
||||
CG_TransposeMatrix( transpose, matrix );
|
||||
VectorSubtract( in, oldOrigin, org );
|
||||
VectorCopy( org, org2 );
|
||||
CG_RotatePoint( org2, matrix );
|
||||
VectorSubtract( org2, org, move2 );
|
||||
VectorAdd( deltaOrigin, move2, deltaOrigin );
|
||||
|
||||
VectorAdd( in, deltaOrigin, out );
|
||||
VectorAdd( angles_in, deltaAngles, angles_out );
|
||||
// FIXME: origin change when on a rotating object
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue