Improved particle collision logic:
- checking if any of the extents of the particle collide with the edges of the hull, instead of just checking if a position in the direction the particle is heading is outside the hull - separate fields for friction and restitution
This commit is contained in:
@@ -195,7 +195,7 @@ namespace Barotrauma
|
||||
if (Rand.Int(5) == 1)
|
||||
{
|
||||
var smokeParticle = GameMain.ParticleManager.CreateParticle("smoke",
|
||||
particlePos, particleVel * 0.1f, 0.0f, hull);
|
||||
particlePos, new Vector2(particleVel.X, particleVel.Y * 0.1f), 0.0f, hull);
|
||||
|
||||
if (smokeParticle != null)
|
||||
{
|
||||
@@ -236,9 +236,10 @@ namespace Barotrauma
|
||||
{
|
||||
if (particleHull == hull || particleHull==null) return;
|
||||
|
||||
if (particleHull.FireSources.Find(fs => pos.X > fs.position.X-100.0f && pos.X < fs.position.X+fs.size.X+100.0f)!=null) return;
|
||||
//hull already has a firesource roughly at the particles position -> don't create a new one
|
||||
if (particleHull.FireSources.Find(fs => pos.X > fs.position.X - 100.0f && pos.X < fs.position.X + fs.size.X + 100.0f) != null) return;
|
||||
|
||||
new FireSource(new Vector2(pos.X, particleHull.WorldRect.Y-particleHull.Rect.Height + 5.0f));
|
||||
new FireSource(new Vector2(pos.X, particleHull.WorldRect.Y - particleHull.Rect.Height + 5.0f));
|
||||
}
|
||||
|
||||
private void DamageCharacters(float deltaTime)
|
||||
@@ -293,7 +294,7 @@ namespace Barotrauma
|
||||
{
|
||||
Vector2 spawnPos = new Vector2(
|
||||
WorldPosition.X + Rand.Range(0.0f, size.X),
|
||||
Rand.Range(position.Y - size.Y, WorldPosition.Y) + 10.0f);
|
||||
WorldPosition.Y + 10.0f);
|
||||
|
||||
Vector2 speed = new Vector2((spawnPos.X - (WorldPosition.X + size.X / 2.0f)), (float)Math.Sqrt(size.X) * Rand.Range(20.0f, 25.0f));
|
||||
|
||||
|
||||
@@ -266,7 +266,7 @@ namespace Barotrauma
|
||||
|
||||
lerpedFlowForce = Vector2.Lerp(lerpedFlowForce, flowForce, deltaTime);
|
||||
|
||||
if (LerpedFlowForce.LengthSquared() > 10000.0f && flowTargetHull != null && flowTargetHull.Volume < flowTargetHull.FullVolume)
|
||||
if (LerpedFlowForce.LengthSquared() > 20000.0f && flowTargetHull != null && flowTargetHull.Volume < flowTargetHull.FullVolume)
|
||||
{
|
||||
//UpdateFlowForce();
|
||||
|
||||
@@ -274,7 +274,7 @@ namespace Barotrauma
|
||||
if (isHorizontal)
|
||||
{
|
||||
pos.X += Math.Sign(flowForce.X);
|
||||
pos.Y = MathHelper.Clamp((higherSurface + lowerSurface) / 2.0f, rect.Y - rect.Height, rect.Y);
|
||||
pos.Y = MathHelper.Clamp((higherSurface + lowerSurface) / 2.0f, rect.Y - rect.Height, rect.Y) + 10;
|
||||
|
||||
Vector2 velocity = new Vector2(
|
||||
MathHelper.Clamp(flowForce.X, -5000.0f, 5000.0f) * Rand.Range(0.5f, 0.7f),
|
||||
@@ -283,7 +283,7 @@ namespace Barotrauma
|
||||
var particle = GameMain.ParticleManager.CreateParticle(
|
||||
"watersplash",
|
||||
(Submarine == null ? pos : pos + Submarine.Position) - Vector2.UnitY * Rand.Range(0.0f, 10.0f),
|
||||
velocity);
|
||||
velocity, 0, flowTargetHull);
|
||||
|
||||
if (particle != null)
|
||||
{
|
||||
@@ -298,7 +298,7 @@ namespace Barotrauma
|
||||
GameMain.ParticleManager.CreateParticle(
|
||||
"bubbles",
|
||||
Submarine == null ? pos : pos + Submarine.Position,
|
||||
flowForce / 10.0f);
|
||||
flowForce / 10.0f, 0, flowTargetHull);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user