Skip to content

Commit

Permalink
Renderer: Avoid near-clipping player weapon models
Browse files Browse the repository at this point in the history
IssueID #2373
  • Loading branch information
skyjake committed Dec 21, 2019
1 parent 179f69a commit 99f9925
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
5 changes: 3 additions & 2 deletions doomsday/apps/client/include/render/rend_main.h
Expand Up @@ -183,9 +183,10 @@ de::Vector3d Rend_EyeOrigin();
* Returns the projection matrix that is used for rendering the current frame's
* 3D portions.
*
* @param fixedFov If non-zero, overrides the user's FOV with a fixed value.
* @param fixedFov If non-zero, overrides the user's FOV with a fixed value.
* @param clipRangeScale Multiplier to apply to clip plane distances.
*/
de::Matrix4f Rend_GetProjectionMatrix(float fixedFov = 0.f);
de::Matrix4f Rend_GetProjectionMatrix(float fixedFov = 0.0f, float clipRangeScale = 1.0f);

#define Rend_PointDist2D(c) (abs((vOrigin.z-(c)[VY])*viewsidex - (vOrigin.x-(c)[VX])*viewsidey))

Expand Down
3 changes: 2 additions & 1 deletion doomsday/apps/client/src/render/modelrenderer.cpp
Expand Up @@ -190,7 +190,8 @@ DENG2_PIMPL(ModelRenderer)
const Matrix4f localToWorld = Matrix4f::translate(origin) *
Matrix4f::scale(aspectCorrect); // Inverse aspect correction.

const Matrix4f viewProj = Rend_GetProjectionMatrix(useFixedFov ? weaponFixedFOV : 0.0f) *
const Matrix4f viewProj = Rend_GetProjectionMatrix(useFixedFov ? weaponFixedFOV : 0.0f,
0.1f /* near plane distance: IssueID #2373 */) *
ClientApp::renderSystem().uViewMatrix().toMatrix4f();

const Matrix4f localToScreen = viewProj * localToWorld;
Expand Down
11 changes: 6 additions & 5 deletions doomsday/apps/client/src/render/rend_main.cpp
Expand Up @@ -559,18 +559,19 @@ void Rend_ModelViewMatrix(bool inWorldSpace)
Rend_GetModelViewMatrix(DoomsdayApp::players().indexOf(viewPlayer), inWorldSpace).values());
}

Matrix4f Rend_GetProjectionMatrix(float fixedFov)
Matrix4f Rend_GetProjectionMatrix(float fixedFov, float clipRangeScale)
{
if (fixedView)
{
return fixedView->projectionMatrix;
}

const dfloat fov = (fixedFov > 0 ? fixedFov : Rend_FieldOfView());
const dfloat fov = (fixedFov > 0 ? fixedFov : Rend_FieldOfView());
const Vector2f size = R_Console3DViewRect(displayPlayer).size();
yfov = vrCfg().verticalFieldOfView(fov, size);
const Rangef clip = GL_DepthClipRange();
return vrCfg().projectionMatrix(fov, size, clip.start, clip.end) *
yfov = vrCfg().verticalFieldOfView(fov, size);
const Rangef clip = GL_DepthClipRange();
return vrCfg().projectionMatrix(
fov, size, clip.start * clipRangeScale, clip.end * clipRangeScale) *
Matrix4f::scale(Vector3f(1, 1, -1));
}

Expand Down

0 comments on commit 99f9925

Please sign in to comment.