Skip to content

Commit

Permalink
Rename normalize
Browse files Browse the repository at this point in the history
  • Loading branch information
durswd committed Jul 25, 2023
1 parent 86c164b commit cb13af5
Show file tree
Hide file tree
Showing 13 changed files with 58 additions and 56 deletions.
4 changes: 2 additions & 2 deletions Dev/Cpp/Effekseer/Effekseer/Effekseer.Instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ void Instance::UpdateTransform(float deltaFrame)

if (toTarget.GetLength() > followParentParam.maxFollowSpeed)
{
toTarget = toTarget.Normalize();
toTarget = toTarget.GetNormal();
toTarget *= followParentParam.maxFollowSpeed;
}

Expand All @@ -659,7 +659,7 @@ void Instance::UpdateTransform(float deltaFrame)

if (steeringVec_.GetLength() > followParentParam.maxFollowSpeed)
{
steeringVec_ = steeringVec_.Normalize();
steeringVec_ = steeringVec_.GetNormal();
steeringVec_ *= followParentParam.maxFollowSpeed;
}

Expand Down
2 changes: 1 addition & 1 deletion Dev/Cpp/Effekseer/Effekseer/Geometry/GeometryUtility.h
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ class GeometryUtility
for (size_t i = 0; i < ret.size(); i++)
{
const auto component = planeComponents[i];
const auto normal = SIMD::Vec3f::Cross(points3[component[1]] - points3[component[0]], points3[component[2]] - points3[component[0]]).Normalize();
const auto normal = SIMD::Vec3f::Cross(points3[component[1]] - points3[component[0]], points3[component[2]] - points3[component[0]]).GetNormal();
const auto distance = SIMD::Vec3f::Dot(points3[component[0]], normal);

ret[i].Normal = SIMD::ToStruct(normal);
Expand Down
20 changes: 10 additions & 10 deletions Dev/Cpp/Effekseer/Effekseer/Model/ProceduralModelGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,10 @@ static void CalcTangentSpace(const ProceduralMeshVertex& v1, const ProceduralMes
}

tangent = SIMD::Vec3f(u[0], u[1], u[2]);
tangent = tangent.Normalize();
tangent = tangent.GetNormal();

binormal = SIMD::Vec3f(v[0], v[1], v[2]);
binormal = binormal.Normalize();
binormal = binormal.GetNormal();
}

static void CalculateNormal(ProceduralMesh& mesh)
Expand Down Expand Up @@ -109,7 +109,7 @@ static void CalculateNormal(ProceduralMesh& mesh)
continue;
}

const auto normal = SIMD::Vec3f::Cross(v3.Position - v1.Position, v2.Position - v1.Position).Normalize();
const auto normal = SIMD::Vec3f::Cross(v3.Position - v1.Position, v2.Position - v1.Position).GetNormal();

faceNormals[i] = normal;
SIMD::Vec3f binotmal;
Expand Down Expand Up @@ -162,8 +162,8 @@ static void CalculateNormal(ProceduralMesh& mesh)
mesh.Vertexes[i].Normal = normals[key] / static_cast<float>(vertexCounts[key]);
mesh.Vertexes[i].Tangent = tangents[key] / static_cast<float>(vertexCounts[key]);

mesh.Vertexes[i].Normal = mesh.Vertexes[i].Normal.Normalize();
mesh.Vertexes[i].Tangent = mesh.Vertexes[i].Tangent.Normalize();
mesh.Vertexes[i].Normal = mesh.Vertexes[i].Normal.GetNormal();
mesh.Vertexes[i].Tangent = mesh.Vertexes[i].Tangent.GetNormal();
}
}

Expand Down Expand Up @@ -680,8 +680,8 @@ struct RotatedWireMeshGenerator
auto normal = SIMD::Vec3f::Cross(pos_diff_angle - pos, pos_diff_axis - pos);

vs.emplace_back(pos);
normals.emplace_back(normal.Normalize());
binormals.emplace_back((pos_diff - pos).Normalize());
normals.emplace_back(normal.GetNormal());
binormals.emplace_back((pos_diff - pos).GetNormal());
currentDepth += depthSpeed;
currentAngle += rotateSpeed;
}
Expand All @@ -697,7 +697,7 @@ struct RotatedWireMeshGenerator

for (int32_t v = 0; v < vs.size(); v++)
{
const auto tangent = SIMD::Vec3f::Cross(normals[v], binormals[v]).Normalize();
const auto tangent = SIMD::Vec3f::Cross(normals[v], binormals[v]).GetNormal();
const auto normal = normals[v];

const auto percent = v / static_cast<float>(vs.size() - 1);
Expand Down Expand Up @@ -829,8 +829,8 @@ ModelRef ProceduralModelGenerator::Generate(const ProceduralModelParameter& para

SIMD::Vec3f dirX(cos(angleX), sin(angleX), 0.0f);
SIMD::Vec3f dirZ(0.0f, sin(angleY), cos(angleY));
SIMD::Vec3f dirY = SIMD::Vec3f::Cross(dirZ, dirX).Normalize();
dirZ = SIMD::Vec3f::Cross(dirX, dirY).Normalize();
SIMD::Vec3f dirY = SIMD::Vec3f::Cross(dirZ, dirX).GetNormal();
dirZ = SIMD::Vec3f::Cross(dirX, dirY).GetNormal();

v = SIMD::Vec3f(0.0f, v.GetY(), 0.0f) + dirX * v.GetX() + dirZ * v.GetZ();
}
Expand Down
2 changes: 1 addition & 1 deletion Dev/Cpp/Effekseer/Effekseer/Noise/CurlNoise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ LightCurlNoise::LightCurlNoise(int32_t seed, float scale, int32_t octave)
}

// It is better to normalize.
// v.Normalize();
// v = v.GetNormal();

vectorField_[z][y][x] = Pack(v);
}
Expand Down
4 changes: 2 additions & 2 deletions Dev/Cpp/Effekseer/Effekseer/Parameter/Rotation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ void RotationFunctions::InitRotation(RotationState& rotation_values, const Rotat
{
rotation_values.axis.axis = SIMD::Vec3f(0, 1, 0);
}
rotation_values.axis.axis = rotation_values.axis.axis.Normalize();
rotation_values.axis.axis = rotation_values.axis.axis.GetNormal();
}
else if (rotationParam.RotationType == ParameterRotationType::ParameterRotationType_AxisEasing)
{
Expand All @@ -229,7 +229,7 @@ void RotationFunctions::InitRotation(RotationState& rotation_values, const Rotat
{
rotation_values.axis.axis = SIMD::Vec3f(0, 1, 0);
}
rotation_values.axis.axis = rotation_values.axis.axis.Normalize();
rotation_values.axis.axis = rotation_values.axis.axis.GetNormal();
}
else if (rotationParam.RotationType == ParameterRotationType::ParameterRotationType_FCurve)
{
Expand Down
8 changes: 4 additions & 4 deletions Dev/Cpp/Effekseer/Effekseer/Parameter/SpawnMethod.h
Original file line number Diff line number Diff line change
Expand Up @@ -263,14 +263,14 @@ struct ParameterGenerationLocation
if (fabs(dir.GetY()) > 0.999f)
{
xdir = dir;
zdir = SIMD::Vec3f::Cross(xdir, SIMD::Vec3f(-1, 0, 0)).Normalize();
ydir = SIMD::Vec3f::Cross(zdir, xdir).Normalize();
zdir = SIMD::Vec3f::Cross(xdir, SIMD::Vec3f(-1, 0, 0)).GetNormal();
ydir = SIMD::Vec3f::Cross(zdir, xdir).GetNormal();
}
else
{
xdir = dir;
ydir = SIMD::Vec3f::Cross(SIMD::Vec3f(0, 0, 1), xdir).Normalize();
zdir = SIMD::Vec3f::Cross(xdir, ydir).Normalize();
ydir = SIMD::Vec3f::Cross(SIMD::Vec3f(0, 0, 1), xdir).GetNormal();
zdir = SIMD::Vec3f::Cross(xdir, ydir).GetNormal();
}

if (param.EffectsRotation)
Expand Down
12 changes: 6 additions & 6 deletions Dev/Cpp/Effekseer/Effekseer/SIMD/Vec3f.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ struct Vec3f
float GetSquaredLength() const;
float GetLength() const;
bool IsZero(float epsiron = DefaultEpsilon) const;
Vec3f Normalize() const;
Vec3f NormalizePrecisely() const;
Vec3f NormalizeFast() const;
Vec3f GetNormal() const;
Vec3f GetNormalPrecisely() const;
Vec3f GetNormalFast() const;

static Vec3f Load(const void* mem);
static void Store(void* mem, const Vec3f& i);
Expand Down Expand Up @@ -226,17 +226,17 @@ inline bool Vec3f::IsZero(float epsiron) const
return (Float4::MoveMask(Float4::IsZero(s, epsiron)) & 0x7) == 0x7;
}

inline Vec3f Vec3f::Normalize() const
inline Vec3f Vec3f::GetNormal() const
{
return *this * Effekseer::SIMD::Rsqrt(GetSquaredLength());
}

inline Vec3f Vec3f::NormalizePrecisely() const
inline Vec3f Vec3f::GetNormalPrecisely() const
{
return *this / Effekseer::SIMD::Sqrt(GetSquaredLength());
}

inline Vec3f Vec3f::NormalizeFast() const
inline Vec3f Vec3f::GetNormalFast() const
{
return *this * Effekseer::SIMD::Rsqrt(GetSquaredLength());
}
Expand Down
20 changes: 10 additions & 10 deletions Dev/Cpp/EffekseerRendererCommon/EffekseerRenderer.CommonUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,16 +104,16 @@ void CalcBillboard(::Effekseer::BillboardType billboardType,
::Effekseer::SIMD::Vec3f Up(0.0f, 1.0f, 0.0f);

F = frontDir;
R = ::Effekseer::SIMD::Vec3f::Cross(Up, F).Normalize();
U = ::Effekseer::SIMD::Vec3f::Cross(F, R).Normalize();
R = ::Effekseer::SIMD::Vec3f::Cross(Up, F).GetNormal();
U = ::Effekseer::SIMD::Vec3f::Cross(F, R).GetNormal();
}
else if (billboardType == ::Effekseer::BillboardType::RotatedBillboard)
{
::Effekseer::SIMD::Vec3f Up(0.0f, 1.0f, 0.0f);

F = frontDir;
R = ::Effekseer::SIMD::Vec3f::Cross(Up, F).Normalize();
U = ::Effekseer::SIMD::Vec3f::Cross(F, R).Normalize();
R = ::Effekseer::SIMD::Vec3f::Cross(Up, F).GetNormal();
U = ::Effekseer::SIMD::Vec3f::Cross(F, R).GetNormal();

float c_zx2 = Effekseer::SIMD::Vec3f::Dot(r.Y, r.Y) - r.Y.GetZ() * r.Y.GetZ();
float c_zx = sqrt(std::max(0.0f, c_zx2));
Expand Down Expand Up @@ -141,8 +141,8 @@ void CalcBillboard(::Effekseer::BillboardType billboardType,
{
U = ::Effekseer::SIMD::Vec3f(r.X.GetY(), r.Y.GetY(), r.Z.GetY());
F = frontDir;
R = ::Effekseer::SIMD::Vec3f::Cross(U, F).Normalize();
F = ::Effekseer::SIMD::Vec3f::Cross(R, U).Normalize();
R = ::Effekseer::SIMD::Vec3f::Cross(U, F).GetNormal();
F = ::Effekseer::SIMD::Vec3f::Cross(R, U).GetNormal();
}

dst.X = {R.GetX(), U.GetX(), F.GetX(), t.GetX()};
Expand Down Expand Up @@ -218,7 +218,7 @@ void ApplyDepthParameters(::Effekseer::SIMD::Mat43f& mat,

auto objPos = mat.GetTranslation();
auto dir = cameraPos - objPos;
dir = dir.Normalize();
dir = dir.GetNormal();

if (isRightHand)
{
Expand Down Expand Up @@ -282,7 +282,7 @@ void ApplyDepthParameters(::Effekseer::SIMD::Mat43f& mat,

auto objPos = translationValues;
auto dir = cameraPos - objPos;
dir = dir.Normalize();
dir = dir.GetNormal();

if (isRightHand)
{
Expand Down Expand Up @@ -349,7 +349,7 @@ void ApplyDepthParameters(::Effekseer::SIMD::Mat43f& mat,

auto objPos = mat.GetTranslation();
auto dir = cameraPos - objPos;
dir = dir.Normalize();
dir = dir.GetNormal();

if (isRightHand)
{
Expand Down Expand Up @@ -412,7 +412,7 @@ void ApplyDepthParameters(::Effekseer::SIMD::Mat44f& mat,

auto objPos = mat.GetTranslation();
auto dir = cameraPos - objPos;
dir = dir.Normalize();
dir = dir.GetNormal();

if (isRightHand)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ class ModelRendererBase : public ::Effekseer::ModelRenderer, public ::Effekseer:
float lightAmbientColor[4];

::Effekseer::SIMD::Vec3f lightDirection3 = renderer->GetLightDirection();
lightDirection3 = lightDirection3.Normalize();
lightDirection3 = lightDirection3.GetNormal();

VectorToFloat4(lightDirection3, lightDirection);
ColorToFloat4(renderer->GetLightColor(), lightColor);
Expand Down Expand Up @@ -631,7 +631,7 @@ class ModelRendererBase : public ::Effekseer::ModelRenderer, public ::Effekseer:
if (param.BasicParameterPtr->MaterialType == Effekseer::RendererMaterialType::Lighting)
{
::Effekseer::SIMD::Vec3f lightDirection = renderer->GetLightDirection();
lightDirection = lightDirection.Normalize();
lightDirection = lightDirection.GetNormal();
VectorToFloat4(lightDirection, vcb->LightDirection);
VectorToFloat4(lightDirection, pcb->LightDirection);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -405,9 +405,9 @@ class RibbonRendererBase : public ::Effekseer::RibbonRenderer, public ::Effeksee
::Effekseer::SIMD::Vec3f U;

U = ::Effekseer::SIMD::Vec3f(r.X.GetY(), r.Y.GetY(), r.X.GetY());
F = ::Effekseer::SIMD::Vec3f(-m_renderer->GetCameraFrontDirection()).Normalize();
R = ::Effekseer::SIMD::Vec3f::Cross(U, F).Normalize();
F = ::Effekseer::SIMD::Vec3f::Cross(R, U).Normalize();
F = ::Effekseer::SIMD::Vec3f(-m_renderer->GetCameraFrontDirection()).GetNormal();
R = ::Effekseer::SIMD::Vec3f::Cross(U, F).GetNormal();
F = ::Effekseer::SIMD::Vec3f::Cross(R, U).GetNormal();

::Effekseer::SIMD::Mat43f mat_rot(-R.GetX(),
-R.GetY(),
Expand Down Expand Up @@ -527,9 +527,9 @@ class RibbonRendererBase : public ::Effekseer::RibbonRenderer, public ::Effeksee

U = ::Effekseer::SIMD::Vec3f(r.X.GetY(), r.Y.GetY(), r.Z.GetY());

F = ::Effekseer::SIMD::Vec3f(-m_renderer->GetCameraFrontDirection()).Normalize();
R = ::Effekseer::SIMD::Vec3f::Cross(U, F).Normalize();
F = ::Effekseer::SIMD::Vec3f::Cross(R, U).Normalize();
F = ::Effekseer::SIMD::Vec3f(-m_renderer->GetCameraFrontDirection()).GetNormal();
R = ::Effekseer::SIMD::Vec3f::Cross(U, F).GetNormal();
F = ::Effekseer::SIMD::Vec3f::Cross(R, U).GetNormal();

::Effekseer::SIMD::Mat43f mat_rot(-R.GetX(),
-R.GetY(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -558,9 +558,9 @@ class RingRendererBase : public ::Effekseer::RingRenderer, public ::Effekseer::S
::Effekseer::SIMD::Vec3f outerNN{c_n * outerRadius, s_n * outerRadius, 0.0f};
outerTransform.Transform(outerNN);

::Effekseer::SIMD::Vec3f tangent0 = (outerCurrent - outerBefore).Normalize();
::Effekseer::SIMD::Vec3f tangent1 = (outerNext - outerCurrent).Normalize();
::Effekseer::SIMD::Vec3f tangent2 = (outerNN - outerNext).Normalize();
::Effekseer::SIMD::Vec3f tangent0 = (outerCurrent - outerBefore).GetNormal();
::Effekseer::SIMD::Vec3f tangent1 = (outerNext - outerCurrent).GetNormal();
::Effekseer::SIMD::Vec3f tangent2 = (outerNN - outerNext).GetNormal();

auto tangentCurrent = (tangent0 + tangent1) / 2.0f;
auto tangentNext = (tangent1 + tangent2) / 2.0f;
Expand All @@ -580,11 +580,11 @@ class RingRendererBase : public ::Effekseer::RingRenderer, public ::Effekseer::S
normalNext = -normalNext;
}

normalCurrent = normalCurrent.Normalize();
normalNext = normalNext.Normalize();
normalCurrent = normalCurrent.GetNormal();
normalNext = normalNext.GetNormal();

tangentCurrent = tangentCurrent.Normalize();
tangentNext = tangentNext.Normalize();
tangentCurrent = tangentCurrent.GetNormal();
tangentNext = tangentNext.GetNormal();

const auto packedNormalCurrent = PackVector3DF(normalCurrent);
const auto packedNormalNext = PackVector3DF(normalNext);
Expand Down Expand Up @@ -688,11 +688,13 @@ class RingRendererBase : public ::Effekseer::RingRenderer, public ::Effekseer::S

if (param.DepthParameterPtr->ZSort == Effekseer::ZSortType::NormalOrder)
{
std::sort(instances_.begin(), instances_.end(), [](const KeyValue& a, const KeyValue& b) -> bool { return a.Key < b.Key; });
std::sort(instances_.begin(), instances_.end(), [](const KeyValue& a, const KeyValue& b) -> bool
{ return a.Key < b.Key; });
}
else
{
std::sort(instances_.begin(), instances_.end(), [](const KeyValue& a, const KeyValue& b) -> bool { return a.Key > b.Key; });
std::sort(instances_.begin(), instances_.end(), [](const KeyValue& a, const KeyValue& b) -> bool
{ return a.Key > b.Key; });
}

const auto& state = m_renderer->GetStandardRenderer()->GetState();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,8 @@ class SpriteRendererBase : public ::Effekseer::SpriteRenderer, public ::Effeksee
StrideView<VERTEX> vs(verteies.pointerOrigin_, stride_, 4);
auto tangentX = efkVector3D(mat.X.GetX(), mat.Y.GetX(), mat.Z.GetX());
auto tangentZ = efkVector3D(mat.X.GetZ(), mat.Y.GetZ(), mat.Z.GetZ());
tangentX = tangentX.Normalize();
tangentZ = tangentZ.Normalize();
tangentX = tangentX.GetNormal();
tangentZ = tangentZ.GetNormal();

if (!parameter.IsRightHand)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ class StandardRenderer
float lightAmbientColor[4];

::Effekseer::SIMD::Vec3f lightDirection3 = m_renderer->GetLightDirection();
lightDirection3 = lightDirection3.Normalize();
lightDirection3 = lightDirection3.GetNormal();
VectorToFloat4(lightDirection3, lightDirection);
ColorToFloat4(m_renderer->GetLightColor(), lightColor);
ColorToFloat4(m_renderer->GetLightAmbientColor(), lightAmbientColor);
Expand Down

0 comments on commit cb13af5

Please sign in to comment.