GPU/Math3D: Replace * and % operators with the less ambiguous function names Dot and Cross.

This commit is contained in:
neobrain committed 2013-07-29 22:26:41 +02:00
1 parent f70e8a2fe0
commit 17759082dc
2 files changed
+16 -14

No files matched your search

+5 -5
View File
@@ -303,7 +303,7 @@ void Lighter::Light(float colorOut0[4], float colorOut1[4], const float colorIn[
if (distanceToLight > 0.0f) {
toLight /= distanceToLight;
dot = toLight * norm;
dot = Dot(toLight, norm);
}
// Clamp dot to zero.
if (dot < 0.0f) dot = 0.0f;
@@ -321,7 +321,7 @@ void Lighter::Light(float colorOut0[4], float colorOut1[4], const float colorIn[
break;
case GE_LIGHTTYPE_SPOT:
lightDir = gstate_c.lightdir[l];
angle = toLight.Normalized() * lightDir.Normalized();
angle = Dot(toLight.Normalized(), lightDir.Normalized());
if (angle >= gstate_c.lightangle[l])
lightScale = clamp(1.0f / (gstate_c.lightatt[l][0] + gstate_c.lightatt[l][1]*distanceToLight + gstate_c.lightatt[l][2]*distanceToLight*distanceToLight), 0.0f, 1.0f) * powf(angle, gstate_c.lightspotCoef[l]);
break;
@@ -343,7 +343,7 @@ void Lighter::Light(float colorOut0[4], float colorOut1[4], const float colorIn[
Vec3 halfVec = (toLight + toViewer);
halfVec.Normalize();
dot = halfVec * norm;
dot = Dot(halfVec, norm);
if (dot > 0.0f)
{
Color4 lightSpec(gstate_c.lightColor[2][l], 0.0f);
@@ -714,8 +714,8 @@ void TransformDrawEngine::SoftwareTransformAndDraw(
Vec3 lightpos0 = Vec3(gstate_c.lightpos[gstate.getUVLS0()]).Normalized();
Vec3 lightpos1 = Vec3(gstate_c.lightpos[gstate.getUVLS1()]).Normalized();
uv[0] = (1.0f + (lightpos0 * normal))/2.0f;
uv[1] = (1.0f - (lightpos1 * normal))/2.0f;
uv[0] = (1.0f + Dot(lightpos0, normal))/2.0f;
uv[1] = (1.0f - Dot(lightpos1, normal))/2.0f;
uv[2] = 1.0f;
}
break;
+11 -9
View File
@@ -32,7 +32,7 @@ public:
};
Vec3(unsigned int rgb) {
x = (rgb & 0xFF) * (1.0f/255.0f);
y = ((rgb >> 8) & 0xFF) * (1.0f/255.0f);
y = ((rgb >> 8) & 0xFF) * (1.0f/255.0f);
z = ((rgb >> 16) & 0xFF) * (1.0f/255.0f);
}
Vec3(const float a[3]) {
@@ -67,10 +67,6 @@ public:
{
return Vec3(-x,-y,-z);
}
float operator *(const Vec3 &other) const
{
return x*other.x + y*other.y + z*other.z;
}
Vec3 Mul(const Vec3 &other) const
{
return Vec3(x*other.x, y*other.y, z*other.z);
@@ -92,10 +88,6 @@ public:
{
*this = *this / f;
}
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;
@@ -160,3 +152,13 @@ inline float Vec3Dot(const float v1[3], const float v2[3])
{
return v1[0]*v2[0] + v1[1]*v2[1] + v1[2]*v2[2];
}
inline float Dot(const Vec3 &a, const Vec3& b)
{
return a.x*b.x + a.y*b.y + a.z*b.z;
}
inline Vec3 Cross(const Vec3 &a, const Vec3& b)
{
return Vec3(a.y*b.z-a.z*b.y, a.z*b.x-a.x*b.z, a.x*b.y-a.y*b.x);
}