Skip to content

Commit

Permalink
Renderer|Hexen: More accurate movement alignment for models
Browse files Browse the repository at this point in the history
Now using the system-provided atan2() function instead of a
low-precision lookup table. Also, the pitch angle takes into account
the aspect correction factor.
  • Loading branch information
skyjake committed Jun 27, 2016
1 parent ecce45a commit 56916bf
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions doomsday/apps/client/src/r_util.cpp
Expand Up @@ -35,8 +35,7 @@ using namespace de;

float R_MovementYaw(float const mom[])
{
// Multiply by 100 to get some artificial accuracy in bamsAtan2.
return BANG2DEG(bamsAtan2(-100 * mom[MY], 100 * mom[MX]));
return radianToDegree(atan2f(-mom[MY], mom[MX]));
}

float R_MovementXYYaw(float momx, float momy)
Expand All @@ -47,7 +46,7 @@ float R_MovementXYYaw(float momx, float momy)

float R_MovementPitch(float const mom[])
{
return BANG2DEG(bamsAtan2 (100 * mom[MZ], 100 * V2f_Length(mom)));
return radianToDegree(atan2f(1.2f * mom[MZ], V2f_Length(mom)));
}

float R_MovementXYZPitch(float momx, float momy, float momz)
Expand Down
2 changes: 1 addition & 1 deletion doomsday/apps/client/src/render/r_things.cpp
Expand Up @@ -448,7 +448,7 @@ void R_ProjectSprite(mobj_t &mob)
// Set up a GL2 model for drawing.
vis->pose = VisEntityPose(vis->pose.origin,
Vector3d(visOff.x, visOff.y, visOff.z - floorClip),
viewAlign, topZ, yaw, 0, pitch, 0);
/*viewAlign*/ false, topZ, yaw, 0, pitch, 0);
vis->light = VisEntityLighting(ambientColor, vLightListIdx);

vis->data.model2.object = &mob;
Expand Down
2 changes: 1 addition & 1 deletion doomsday/apps/plugins/hexen/src/p_mobj.c
Expand Up @@ -959,7 +959,7 @@ void P_MobjThinker(void *thinkerPtr)
// Give a small amount of momentum so the movement direction
// can be determined.
V3d_Copy (fx->mom, mobj->mom);
V3d_Scale(fx->mom, .00001);
V3d_Scale(fx->mom, 0.0001 / V3d_Length(fx->mom));
}
else if(!--mobj->special1)
{
Expand Down

0 comments on commit 56916bf

Please sign in to comment.