Skip to content

Commit

Permalink
[spline/bezier]Fix normal generation flag and some minor stuffs.
Browse files Browse the repository at this point in the history
  • Loading branch information
xebra committed Oct 7, 2018
1 parent ca4e246 commit b11f9e6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
22 changes: 9 additions & 13 deletions GPU/Common/SplineCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,6 @@ static void SplinePatchFullQuality(u8 *&dest, u16 *indices, int &count, const Sp

// int max_idx = spatch.count_u * spatch.count_v;

bool computeNormals = spatch.computeNormals;

float one_over_patch_div_s = 1.0f / (float)(patch_div_s);
float one_over_patch_div_t = 1.0f / (float)(patch_div_t);

Expand Down Expand Up @@ -541,9 +539,9 @@ static void _BezierPatchHighQuality(u8 *&dest, u16 *&indices, int &count, int te
// First compute all the vertices and put them in an array
SimpleVertex *&vertices = (SimpleVertex*&)dest;

const bool computeNormals = patch.computeNormals;
const bool sampleColors = (origVertType & GE_VTYPE_COL_MASK) != 0;
const bool sampleTexcoords = (origVertType & GE_VTYPE_TC_MASK) != 0;
const bool sampleNrm = (origVertType & GE_VTYPE_NRM_MASK) != 0;
const bool sampleCol = (origVertType & GE_VTYPE_COL_MASK) != 0;
const bool sampleTex = (origVertType & GE_VTYPE_TC_MASK) != 0;

Weight2D weights(bezierWeightsCache, tess_u, tess_v);

Expand All @@ -564,11 +562,11 @@ static void _BezierPatchHighQuality(u8 *&dest, u16 *&indices, int &count, int te
const Weight &wu = weights.u[tile_u];

tess_pos.SampleU(wu.weights);
if (sampleColors)
if (sampleCol)
tess_col.SampleU(wu.weights);
if (sampleTexcoords)
if (sampleTex)
tess_tex.SampleU(wu.weights);
if (computeNormals)
if (sampleNrm)
tess_nrm.SampleU(wu.derivs);

for (int tile_v = 0; tile_v < tess_v + 1; ++tile_v) {
Expand All @@ -577,19 +575,19 @@ static void _BezierPatchHighQuality(u8 *&dest, u16 *&indices, int &count, int te
SimpleVertex &vert = vertices[tile_v * (tess_u + 1) + tile_u];

vert.pos = tess_pos.SampleV(wv.weights);
if (sampleColors) {
if (sampleCol) {
vert.color_32 = tess_col.SampleV(wv.weights).ToRGBA();
} else {
vert.color_32 = patch.defcolor;
}
if (sampleTexcoords) {
if (sampleTex) {
tess_tex.SampleV(wv.weights).Write(vert.uv);
} else {
// Generate texcoord
vert.uv[0] = patch_u + tile_u * inv_u;
vert.uv[1] = patch_v + tile_v * inv_v;
}
if (computeNormals) {
if (sampleNrm) {
const Vec3f derivU = tess_nrm.SampleV(wv.weights);
const Vec3f derivV = tess_pos.SampleV(wv.derivs);

Expand Down Expand Up @@ -733,7 +731,6 @@ void DrawEngineCommon::SubmitSpline(const void *control_points, const void *indi
patch.type_v = type_v;
patch.count_u = count_u;
patch.count_v = count_v;
patch.computeNormals = computeNormals;
patch.primType = prim_type;
patch.patchFacing = patchFacing;
patch.defcolor = points[0]->color_32;
Expand Down Expand Up @@ -839,7 +836,6 @@ void DrawEngineCommon::SubmitBezier(const void *control_points, const void *indi
patch.count_u = count_u;
patch.count_v = count_v;
patch.primType = prim_type;
patch.computeNormals = computeNormals;
patch.patchFacing = patchFacing;
patch.defcolor = points[0]->color_32;
patch.pos = (Vec3f *)managedBuf.Allocate(sizeof(Vec3f) * count_u * count_v);
Expand Down
2 changes: 0 additions & 2 deletions GPU/Common/SplineCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ struct BezierPatch {
int count_u;
int count_v;
GEPatchPrimType primType;
bool computeNormals;
bool patchFacing;
};

Expand All @@ -58,7 +57,6 @@ struct SplinePatchLocal {
int count_v;
int type_u;
int type_v;
bool computeNormals;
bool patchFacing;
GEPatchPrimType primType;
};
Expand Down

0 comments on commit b11f9e6

Please sign in to comment.