physics water ripple placement logic improvement
This commit is contained in:
@@ -263,8 +263,7 @@ namespace wi::physics
|
||||
wi::primitive::Capsule capsule;
|
||||
|
||||
// water ripple stuff:
|
||||
float radius = 0;
|
||||
float time_since_waterripple = 0;
|
||||
bool was_underwater = false;
|
||||
|
||||
~RigidBody()
|
||||
{
|
||||
@@ -404,10 +403,6 @@ namespace wi::physics
|
||||
settings.mMotionQuality = cMotionQuality;
|
||||
settings.mUserData = (uint64_t)&physicsobject;
|
||||
|
||||
XMFLOAT3 extent = cast(physicsobject.shape->GetWorldSpaceBounds(mat, cast(transform.GetScale())).GetExtent());
|
||||
physicsobject.radius = std::sqrt(sqr(std::sqrt(sqr(extent.x) + sqr(extent.y))) + sqr(extent.z));
|
||||
physicsobject.time_since_waterripple = wi::random::GetRandom(1.0f); // randomize the water ripples a bit
|
||||
|
||||
BodyInterface& body_interface = physics_scene.physics_system.GetBodyInterface(); // locking version because this is called from job system!
|
||||
|
||||
const EActivation activation = physicscomponent.IsStartDeactivated() ? EActivation::DontActivate : EActivation::Activate;
|
||||
@@ -794,10 +789,6 @@ namespace wi::physics
|
||||
|
||||
physicsobject.physics_scene = scene.physics_scene;
|
||||
|
||||
XMFLOAT3 extent = cast(physicsobject.shape->GetWorldSpaceBounds(mat, Vec3(1, 1, 1)).GetExtent());
|
||||
physicsobject.radius = std::sqrt(sqr(std::sqrt(sqr(extent.x) + sqr(extent.y))) + sqr(extent.z));
|
||||
physicsobject.time_since_waterripple = wi::random::GetRandom(1.0f); // randomize the water ripples a bit
|
||||
|
||||
masses[c] = mass;
|
||||
positions[c] = mat.GetTranslation();
|
||||
constraint_positions[c] = root;
|
||||
@@ -1324,16 +1315,16 @@ namespace wi::physics
|
||||
scene.dt
|
||||
);
|
||||
|
||||
if (diff > -physicsobject.radius)
|
||||
if (!physicsobject.was_underwater)
|
||||
{
|
||||
physicsobject.time_since_waterripple += scene.dt;
|
||||
if (physicsobject.time_since_waterripple > 0.2f)
|
||||
{
|
||||
physicsobject.time_since_waterripple = 0;
|
||||
scene.PutWaterRipple(cast(surface_position));
|
||||
}
|
||||
physicsobject.was_underwater = true;
|
||||
scene.PutWaterRipple(cast(surface_position));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
physicsobject.was_underwater = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1512,16 +1503,16 @@ namespace wi::physics
|
||||
scene.dt
|
||||
);
|
||||
|
||||
if (diff > -rb.radius)
|
||||
if (!rb.was_underwater)
|
||||
{
|
||||
rb.time_since_waterripple += scene.dt;
|
||||
if (rb.time_since_waterripple > 0.2f)
|
||||
{
|
||||
rb.time_since_waterripple = 0;
|
||||
scene.PutWaterRipple(cast(surface_position));
|
||||
}
|
||||
rb.was_underwater = true;
|
||||
scene.PutWaterRipple(cast(surface_position));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rb.was_underwater = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace wi::version
|
||||
// minor features, major updates, breaking compatibility changes
|
||||
const int minor = 71;
|
||||
// minor bug fixes, alterations, refactors, updates
|
||||
const int revision = 691;
|
||||
const int revision = 692;
|
||||
|
||||
const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user