Skip to content

Commit

Permalink
Fix a bug where Magnification is not applied
Browse files Browse the repository at this point in the history
  • Loading branch information
durswd committed May 17, 2024
1 parent 7b16976 commit ab18c95
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 5 deletions.
9 changes: 8 additions & 1 deletion Dev/Cpp/Effekseer/Effekseer/Effekseer.Instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,14 @@ void Instance::UpdateTransform(float deltaFrame)
SIMD::Vec3f vel = SIMD::Vec3f::Transform(prevLocalVelocity_, r) + (velocity_modify_global_ + acc_global_sum);

InstanceGlobal* instanceGlobal = m_pContainer->GetRootInstance();
const auto result = CollisionsFunctions::Update(collisionState_, m_pEffectNode->Collisions, pos, prevGlobalPosition_, vel, instanceGlobal->EffectGlobalMatrix.GetTranslation());
const auto result = CollisionsFunctions::Update(
collisionState_,
m_pEffectNode->Collisions,
pos,
prevGlobalPosition_,
vel,
instanceGlobal->EffectGlobalMatrix.GetTranslation(),
m_pEffectNode->GetEffect()->GetMaginification());
location_modify_global_ -= std::get<1>(result);
acc_global_sum += std::get<0>(result);
}
Expand Down
9 changes: 6 additions & 3 deletions Dev/Cpp/Effekseer/Effekseer/Parameter/Collisions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ std::tuple<SIMD::Vec3f, SIMD::Vec3f> CollisionsFunctions::Update(
const SIMD::Vec3f& next_position_global,
const SIMD::Vec3f& position_global,
const SIMD::Vec3f& velocity_global,
const SIMD::Vec3f& position_center_local)
const SIMD::Vec3f& position_center_local,
float magnification)
{
if (!parameter.IsEnabled)
{
Expand All @@ -48,10 +49,12 @@ std::tuple<SIMD::Vec3f, SIMD::Vec3f> CollisionsFunctions::Update(
current_position -= position_center_local;
}

if (next_position.GetY() < parameter.Height && current_position.GetY() >= parameter.Height)
const auto height = parameter.Height * magnification;

if (next_position.GetY() < height && current_position.GetY() >= height)
{
auto diff = next_position - current_position;
auto pos_diff = diff * (current_position.GetY() - parameter.Height) / diff.GetY();
auto pos_diff = diff * (current_position.GetY() - height) / diff.GetY();
return {SIMD::Vec3f(0, -velocity_global.GetY() * (1.0f + parameter.Bounce), 0), pos_diff};
}
else
Expand Down
3 changes: 2 additions & 1 deletion Dev/Cpp/Effekseer/Effekseer/Parameter/Collisions.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ struct CollisionsFunctions
const SIMD::Vec3f& next_position_global,
const SIMD::Vec3f& position_global,
const SIMD::Vec3f& velocity_global,
const SIMD::Vec3f& position_center_local);
const SIMD::Vec3f& position_center_local,
float magnificationScale);
};

} // namespace Effekseer

0 comments on commit ab18c95

Please sign in to comment.