Skip to content

Commit

Permalink
Code cleanup.
Browse files Browse the repository at this point in the history
  • Loading branch information
Rinnegatamante committed Jul 4, 2020
1 parent ee10d8a commit 8e47ee8
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 172 deletions.
83 changes: 28 additions & 55 deletions Source/HLEGraphics/BaseRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -438,22 +438,22 @@ void BaseRenderer::SetPositiveViewport()

bool BaseRenderer::TestVerts(u32 v0, u32 vn) const
{
if ((vn + v0) > kMaxN64Vertices) {
if ((vn + v0) >= kMaxN64Vertices) {
return false;
}

if (vn < v0) {
u32 flags = mVtxProjected[vn].ClipFlags;
for (u32 i = (vn+1); i <= v0; i++) {
flags &= mVtxProjected[i].ClipFlags;
if ((flags & CLIP_TEST_FLAGS) == 0)
if (flags == 0)
return true;
}
} else {
u32 flags = mVtxProjected[v0].ClipFlags;
for (u32 i = (v0+1); i <= vn; i++) {
flags &= mVtxProjected[i].ClipFlags;
if ((flags & CLIP_TEST_FLAGS) == 0)
if (flags == 0)
return true;
}
}
Expand Down Expand Up @@ -663,9 +663,9 @@ static u32 clipToHyperPlane( DaedalusVtx4 * dest, const DaedalusVtx4 * source, u

//CPU tris clip to frustum

u32 clip_tri_to_frustum( DaedalusVtx4 * v0, DaedalusVtx4 * v1 )
static u32 clip_tri_to_frustum( DaedalusVtx4 * v0, DaedalusVtx4 * v1 )
{
u32 vOut {3};
u32 vOut = 3;

vOut = clipToHyperPlane( v1, v0, vOut, NDCPlane[0] ); if ( vOut < 3 ) return vOut; // near
vOut = clipToHyperPlane( v0, v1, vOut, NDCPlane[1] ); if ( vOut < 3 ) return vOut; // far
Expand All @@ -677,6 +677,24 @@ u32 clip_tri_to_frustum( DaedalusVtx4 * v0, DaedalusVtx4 * v1 )
return vOut;
}

//*****************************************************************************
// Set Clipflags
//*****************************************************************************
static u32 set_clip_flags(const v4 & projected)
{
u32 clip_flags = 0;
if (projected.x < -projected.w) clip_flags |= X_POS;
else if (projected.x > projected.w) clip_flags |= X_NEG;

if (projected.y < -projected.w) clip_flags |= Y_POS;
else if (projected.y > projected.w) clip_flags |= Y_NEG;

if (projected.z < -projected.w) clip_flags |= Z_POS;
else if (projected.z > projected.w) clip_flags |= Z_NEG;

return clip_flags;
}

//

namespace
Expand Down Expand Up @@ -952,16 +970,7 @@ void BaseRenderer::SetNewVertexInfo(u32 address, u32 v0, u32 n)

// Initialise the clipping flags
//
u32 clip_flags = 0;
if (projected.x < -projected.w) clip_flags |= X_POS;
else if (projected.x > projected.w) clip_flags |= X_NEG;

if (projected.y < -projected.w) clip_flags |= Y_POS;
else if (projected.y > projected.w) clip_flags |= Y_NEG;

if (projected.z < -projected.w) clip_flags |= Z_POS;
else if (projected.z > projected.w) clip_flags |= Z_NEG;
mVtxProjected[i].ClipFlags = clip_flags;
mVtxProjected[i].ClipFlags = set_clip_flags( projected );

// LIGHTING OR COLOR
//
Expand Down Expand Up @@ -1061,16 +1070,7 @@ void BaseRenderer::SetNewVertexInfoDAM(u32 address, u32 v0, u32 n)

// Initialise the clipping flags
//
u32 clip_flags = 0;
if (projected.x < -projected.w) clip_flags |= X_POS;
else if (projected.x > projected.w) clip_flags |= X_NEG;

if (projected.y < -projected.w) clip_flags |= Y_POS;
else if (projected.y > projected.w) clip_flags |= Y_NEG;

if (projected.z < -projected.w) clip_flags |= Z_POS;
else if (projected.z > projected.w) clip_flags |= Z_NEG;
mVtxProjected[i].ClipFlags = clip_flags;
mVtxProjected[i].ClipFlags = set_clip_flags( projected );

// LIGHTING OR COLOR
//
Expand Down Expand Up @@ -1190,16 +1190,7 @@ void BaseRenderer::SetNewVertexInfoConker(u32 address, u32 v0, u32 n)

// Initialise the clipping flags
//
u32 clip_flags = 0;
if (projected.x < -projected.w) clip_flags |= X_POS;
else if (projected.x > projected.w) clip_flags |= X_NEG;

if (projected.y < -projected.w) clip_flags |= Y_POS;
else if (projected.y > projected.w) clip_flags |= Y_NEG;

if (projected.z < -projected.w) clip_flags |= Z_POS;
else if (projected.z > projected.w) clip_flags |= Z_NEG;
mVtxProjected[i].ClipFlags = clip_flags;
mVtxProjected[i].ClipFlags = set_clip_flags( projected );

mVtxProjected[i].Colour.x = (f32)vert.rgba_r * (1.0f / 255.0f);
mVtxProjected[i].Colour.y = (f32)vert.rgba_g * (1.0f / 255.0f);
Expand Down Expand Up @@ -1385,16 +1376,7 @@ void BaseRenderer::SetNewVertexInfoDKR(u32 address, u32 v0, u32 n, bool billboar
projected = mat_world_project.Transform( transformed ); //Do projection

// Set Clipflags
u32 clip_flags = 0;
if (projected.x < -projected.w) clip_flags |= X_POS;
else if (projected.x > projected.w) clip_flags |= X_NEG;

if (projected.y < -projected.w) clip_flags |= Y_POS;
else if (projected.y > projected.w) clip_flags |= Y_NEG;

if (projected.z < -projected.w) clip_flags |= Z_POS;
else if (projected.z > projected.w) clip_flags |= Z_NEG;
mVtxProjected[i].ClipFlags = clip_flags;
mVtxProjected[i].ClipFlags = set_clip_flags( projected );

// Assign true vert colour
const u32 WL = *(u16*)((pVtxBase + 6) ^ 2);
Expand Down Expand Up @@ -1438,16 +1420,7 @@ void BaseRenderer::SetNewVertexInfoPD(u32 address, u32 v0, u32 n)


// Set Clipflags //Corn
u32 clip_flags {};
if (projected.x < -projected.w) clip_flags |= X_POS;
else if (projected.x > projected.w) clip_flags |= X_NEG;

if (projected.y < -projected.w) clip_flags |= Y_POS;
else if (projected.y > projected.w) clip_flags |= Y_NEG;

if (projected.z < -projected.w) clip_flags |= Z_POS;
else if (projected.z > projected.w) clip_flags |= Z_NEG;
mVtxProjected[i].ClipFlags = clip_flags;
mVtxProjected[i].ClipFlags = set_clip_flags( projected );

if( mTnL.Flags.Light )
{
Expand Down
117 changes: 0 additions & 117 deletions vita.toolchain.cmake

This file was deleted.

0 comments on commit 8e47ee8

Please sign in to comment.