summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2014-08-10 21:34:34 -0400
committerLioncash <mathew1800@gmail.com>2014-08-10 22:28:04 -0400
commit2918f46d8bcc033a0d89dc46bbdeb4fa893b3ed2 (patch)
tree16eaea7c192c09cc3ef8cfb723a60027f940d01b /Source
parent6625d9cba5604d29454a6e3b540916a451cf1bf7 (diff)
Software: Fix the formatting and function casing in Vec3.h
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/VideoBackends/Software/TransformUnit.cpp20
-rw-r--r--Source/Core/VideoBackends/Software/Vec3.h156
2 files changed, 119 insertions, 57 deletions
diff --git a/Source/Core/VideoBackends/Software/TransformUnit.cpp b/Source/Core/VideoBackends/Software/TransformUnit.cpp
index e0907d7543..bb2b50ad41 100644
--- a/Source/Core/VideoBackends/Software/TransformUnit.cpp
+++ b/Source/Core/VideoBackends/Software/TransformUnit.cpp
@@ -95,12 +95,12 @@ void TransformNormal(const InputVertexData *src, bool nbt, OutputVertexData *dst
MultiplyVec3Mat33(src->normal[0], mat, dst->normal[0]);
MultiplyVec3Mat33(src->normal[1], mat, dst->normal[1]);
MultiplyVec3Mat33(src->normal[2], mat, dst->normal[2]);
- dst->normal[0].normalize();
+ dst->normal[0].Normalize();
}
else
{
MultiplyVec3Mat33(src->normal[0], mat, dst->normal[0]);
- dst->normal[0].normalize();
+ dst->normal[0].Normalize();
}
}
@@ -170,7 +170,7 @@ static void TransformTexCoordRegular(const TexMtxInfo &texinfo, int coordNum, bo
else
{
if (postInfo.normalize)
- tempCoord = dst->normalized();
+ tempCoord = dst->Normalized();
else
tempCoord = *dst;
@@ -222,14 +222,14 @@ static void LightColor(const Vec3 &pos, const Vec3 &normal, u8 lightNum, const L
break;
case LIGHTDIF_SIGN:
{
- Vec3 ldir = (light->pos - pos).normalized();
+ Vec3 ldir = (light->pos - pos).Normalized();
float diffuse = ldir * normal;
AddScaledIntegerColor(light->color, diffuse, lightCol);
}
break;
case LIGHTDIF_CLAMP:
{
- Vec3 ldir = (light->pos - pos).normalized();
+ Vec3 ldir = (light->pos - pos).Normalized();
float diffuse = std::max(0.0f, ldir * normal);
AddScaledIntegerColor(light->color, diffuse, lightCol);
}
@@ -245,7 +245,7 @@ static void LightColor(const Vec3 &pos, const Vec3 &normal, u8 lightNum, const L
if (chan.attnfunc == 3) // spot
{
- float dist2 = ldir.length2();
+ float dist2 = ldir.Length2();
float dist = sqrtf(dist2);
ldir = ldir / dist;
attn = std::max(0.0f, ldir * light->dir);
@@ -307,14 +307,14 @@ static void LightAlpha(const Vec3 &pos, const Vec3 &normal, u8 lightNum, const L
break;
case LIGHTDIF_SIGN:
{
- Vec3 ldir = (light->pos - pos).normalized();
+ Vec3 ldir = (light->pos - pos).Normalized();
float diffuse = ldir * normal;
lightCol += light->color[0] * diffuse;
}
break;
case LIGHTDIF_CLAMP:
{
- Vec3 ldir = (light->pos - pos).normalized();
+ Vec3 ldir = (light->pos - pos).Normalized();
float diffuse = std::max(0.0f, ldir * normal);
lightCol += light->color[0] * diffuse;
}
@@ -329,7 +329,7 @@ static void LightAlpha(const Vec3 &pos, const Vec3 &normal, u8 lightNum, const L
if (chan.attnfunc == 3) // spot
{
- float dist2 = ldir.length2();
+ float dist2 = ldir.Length2();
float dist = sqrtf(dist2);
ldir = ldir / dist;
attn = std::max(0.0f, ldir * light->dir);
@@ -478,7 +478,7 @@ void TransformTexCoord(const InputVertexData *src, OutputVertexData *dst, bool s
{
const LightPointer *light = (const LightPointer*)&xfmem.lights[texinfo.embosslightshift];
- Vec3 ldir = (light->pos - dst->mvPosition).normalized();
+ Vec3 ldir = (light->pos - dst->mvPosition).Normalized();
float d1 = ldir * dst->normal[1];
float d2 = ldir * dst->normal[2];
diff --git a/Source/Core/VideoBackends/Software/Vec3.h b/Source/Core/VideoBackends/Software/Vec3.h
index 192355cf7d..af1bbfd91e 100644
--- a/Source/Core/VideoBackends/Software/Vec3.h
+++ b/Source/Core/VideoBackends/Software/Vec3.h
@@ -12,93 +12,155 @@
class Vec3
{
public:
- float x,y,z;
- Vec3() { }
- explicit Vec3(float f) {x=y=z=f;}
- explicit Vec3(const float *f) {x=f[0]; y=f[1]; z=f[2];}
- Vec3(const float _x, const float _y, const float _z) {
- x=_x; y=_y; z=_z;
+ float x, y, z;
+
+ Vec3()
+ {
}
- void set(const float _x, const float _y, const float _z) {
- x=_x; y=_y; z=_z;
+
+ explicit Vec3(float f)
+ {
+ x = y = z = f;
}
- Vec3 operator + (const Vec3 &other) const {
- return Vec3(x+other.x, y+other.y, z+other.z);
+
+ explicit Vec3(const float *f)
+ {
+ x = f[0];
+ y = f[1];
+ z = f[2];
}
- void operator += (const Vec3 &other) {
- x+=other.x; y+=other.y; z+=other.z;
+
+ Vec3(const float _x, const float _y, const float _z)
+ {
+ x = _x;
+ y = _y;
+ z = _z;
}
- Vec3 operator -(const Vec3 &v) const {
- return Vec3(x-v.x,y-v.y,z-v.z);
+
+ void set(const float _x, const float _y, const float _z)
+ {
+ x = _x;
+ y = _y;
+ z = _z;
}
- void operator -= (const Vec3 &other)
+
+ Vec3 operator+(const Vec3 &other) const
{
- x-=other.x; y-=other.y; z-=other.z;
+ return Vec3(x + other.x, y + other.y, z + other.z);
}
- Vec3 operator -() const {
- return Vec3(-x,-y,-z);
+
+ void operator+=(const Vec3 &other)
+ {
+ x += other.x;
+ y += other.y;
+ z += other.z;
+ }
+
+ Vec3 operator-(const Vec3 &v) const
+ {
+ return Vec3(x - v.x, y - v.y, z - v.z);
}
- Vec3 operator * (const float f) const {
- return Vec3(x*f,y*f,z*f);
+ void operator-=(const Vec3 &other)
+ {
+ x -= other.x;
+ y -= other.y;
+ z -= other.z;
+ }
+
+ Vec3 operator-() const
+ {
+ return Vec3(-x, -y, -z);
+ }
+
+ Vec3 operator*(const float f) const
+ {
+ return Vec3(x * f, y * f, z * f);
}
- Vec3 operator / (const float f) const {
- float invf = (1.0f/f);
- return Vec3(x*invf,y*invf,z*invf);
+
+ Vec3 operator/(const float f) const
+ {
+ float invf = (1.0f / f);
+ return Vec3(x * invf, y * invf, z * invf);
}
- void operator /= (const float f)
+
+ void operator/=(const float f)
{
*this = *this / f;
}
- float operator * (const Vec3 &other) const {
- return x*other.x + y*other.y + z*other.z;
+
+ float operator*(const Vec3 &other) const
+ {
+ return (x * other.x) +
+ (y * other.y) +
+ (z * other.z);
}
- void operator *= (const float f) {
+
+ void operator*=(const float f)
+ {
*this = *this * f;
}
- Vec3 scaled_by(const Vec3 &other) const {
- return Vec3(x*other.x, y*other.y, z*other.z);
+
+ Vec3 ScaledBy(const Vec3 &other) const
+ {
+ return Vec3(x * other.x, y * other.y, z * other.z);
}
- Vec3 operator %(const Vec3 &v) const {
- return Vec3(y*v.z-z*v.y, z*v.x-x*v.z, x*v.y-y*v.x);
+ Vec3 operator%(const Vec3 &v) const
+ {
+ return Vec3((y * v.z) - (z * v.y),
+ (z * v.x) - (x * v.z),
+ (x * v.y) - (y * v.x));
}
- float length2() const {
- return x*x+y*y+z*z;
+
+ float Length2() const
+ {
+ return (x * x) + (y * y) + (z * z);
}
- float length() const {
- return sqrtf(length2());
+
+ float Length() const
+ {
+ return sqrtf(Length2());
}
- float distance2_to(Vec3 &other)
+
+ float Distance2To(Vec3 &other)
{
- return (other-(*this)).length2();
+ return (other - (*this)).Length2();
}
- Vec3 normalized() const {
- return (*this) / length();
+ Vec3 Normalized() const
+ {
+ return (*this) / Length();
}
- void normalize() {
- (*this) /= length();
+
+ void Normalize()
+ {
+ (*this) /= Length();
}
- float &operator [] (int i)
+
+ float &operator[](int i)
{
return *((&x) + i);
}
- float operator [] (const int i) const
+
+ float operator[](const int i) const
{
return *((&x) + i);
}
- bool operator == (const Vec3 &other) const
+
+ bool operator==(const Vec3 &other) const
{
- if (x==other.x && y==other.y && z==other.z)
+ if (x == other.x && y == other.y && z == other.z)
return true;
else
return false;
}
- void setZero()
+
+ void SetZero()
{
- memset((void *)this,0,sizeof(float)*3);
+ memset((void*)this, 0, sizeof(float) * 3);
}
+
void DoState(PointerWrap &p)
{
p.Do(x);