Skip to content

Commit

Permalink
Fix namespace Vec2f.
Browse files Browse the repository at this point in the history
  • Loading branch information
xebra committed Oct 7, 2018
1 parent 15a11d5 commit 62ad5fe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
14 changes: 7 additions & 7 deletions GPU/Common/SplineCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ inline float bern2deriv(float x) { return 3 * (2 - 3 * x) * x; }
inline float bern3deriv(float x) { return 3 * x * x; }

// http://en.wikipedia.org/wiki/Bernstein_polynomial
static Math3D::Vec2f Bernstein3D(const Math3D::Vec2f& p0, const Math3D::Vec2f& p1, const Math3D::Vec2f& p2, const Math3D::Vec2f& p3, float x) {
static Vec2f Bernstein3D(const Vec2f& p0, const Vec2f& p1, const Vec2f& p2, const Vec2f& p3, float x) {
if (x == 0) return p0;
else if (x == 1) return p3;
return p0 * bern0(x) + p1 * bern1(x) + p2 * bern2(x) + p3 * bern3(x);
Expand Down Expand Up @@ -693,7 +693,7 @@ static void _BezierPatchHighQuality(u8 *&dest, u16 *&indices, int &count, int te

PrecomputedCurves<Vec3f> prepos(tess_u + 1);
PrecomputedCurves<Vec4f> precol(tess_u + 1);
PrecomputedCurves<Math3D::Vec2f> pretex(tess_u + 1);
PrecomputedCurves<Vec2f> pretex(tess_u + 1);
PrecomputedCurves<Vec3f> prederivU(tess_u + 1);

const bool computeNormals = patch.computeNormals;
Expand All @@ -715,10 +715,10 @@ static void _BezierPatchHighQuality(u8 *&dest, u16 *&indices, int &count, int te
precol.horiz4[i] = Bernstein3D(patch.points[12]->color_32, patch.points[13]->color_32, patch.points[14]->color_32, patch.points[15]->color_32, u);
}
if (sampleTexcoords) {
pretex.horiz1[i] = Bernstein3D(Math3D::Vec2f(patch.points[0]->uv), Math3D::Vec2f(patch.points[1]->uv), Math3D::Vec2f(patch.points[2]->uv), Math3D::Vec2f(patch.points[3]->uv), u);
pretex.horiz2[i] = Bernstein3D(Math3D::Vec2f(patch.points[4]->uv), Math3D::Vec2f(patch.points[5]->uv), Math3D::Vec2f(patch.points[6]->uv), Math3D::Vec2f(patch.points[7]->uv), u);
pretex.horiz3[i] = Bernstein3D(Math3D::Vec2f(patch.points[8]->uv), Math3D::Vec2f(patch.points[9]->uv), Math3D::Vec2f(patch.points[10]->uv), Math3D::Vec2f(patch.points[11]->uv), u);
pretex.horiz4[i] = Bernstein3D(Math3D::Vec2f(patch.points[12]->uv), Math3D::Vec2f(patch.points[13]->uv), Math3D::Vec2f(patch.points[14]->uv), Math3D::Vec2f(patch.points[15]->uv), u);
pretex.horiz1[i] = Bernstein3D(Vec2f(patch.points[0]->uv), Vec2f(patch.points[1]->uv), Vec2f(patch.points[2]->uv), Vec2f(patch.points[3]->uv), u);
pretex.horiz2[i] = Bernstein3D(Vec2f(patch.points[4]->uv), Vec2f(patch.points[5]->uv), Vec2f(patch.points[6]->uv), Vec2f(patch.points[7]->uv), u);
pretex.horiz3[i] = Bernstein3D(Vec2f(patch.points[8]->uv), Vec2f(patch.points[9]->uv), Vec2f(patch.points[10]->uv), Vec2f(patch.points[11]->uv), u);
pretex.horiz4[i] = Bernstein3D(Vec2f(patch.points[12]->uv), Vec2f(patch.points[13]->uv), Vec2f(patch.points[14]->uv), Vec2f(patch.points[15]->uv), u);
}

if (computeNormals) {
Expand Down Expand Up @@ -757,7 +757,7 @@ static void _BezierPatchHighQuality(u8 *&dest, u16 *&indices, int &count, int te
vert.uv[1] = v + patch.v_index * third;
} else {
// Sample UV from control points
const Math3D::Vec2f res = pretex.Bernstein3D(tile_u, bv);
const Vec2f res = pretex.Bernstein3D(tile_u, bv);
vert.uv[0] = res.x;
vert.uv[1] = res.y;
}
Expand Down
3 changes: 1 addition & 2 deletions GPU/Math3D.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,6 @@ class Vec2
const Vec2 ts() const { return Vec2(y, x); }
};

typedef Vec2<float> Vec2f;

template<typename T>
class Vec3Packed;

Expand Down Expand Up @@ -817,6 +815,7 @@ class Mat4x4

}; // namespace Math3D

typedef Math3D::Vec2<float> Vec2f;
typedef Math3D::Vec3<float> Vec3f;
typedef Math3D::Vec3Packed<float> Vec3Packedf;
typedef Math3D::Vec4<float> Vec4f;
Expand Down

0 comments on commit 62ad5fe

Please sign in to comment.