Using nonpremultiplied alpha when drawing damaged wall sections (-> no artifacts around windows anymore), particle collision optimization
This commit is contained in:
@@ -437,7 +437,7 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
if (damageEffect != null)
|
if (damageEffect != null)
|
||||||
{
|
{
|
||||||
float newCutoff = Math.Min((s.damage / prefab.MaxHealth), 0.65f);
|
float newCutoff = Math.Min((s.damage / prefab.MaxHealth), 0.65f);
|
||||||
|
|
||||||
if (Math.Abs(newCutoff - prevCutoff) > 0.01f)
|
if (Math.Abs(newCutoff - prevCutoff) > 0.01f)
|
||||||
{
|
{
|
||||||
@@ -539,7 +539,9 @@ namespace Barotrauma
|
|||||||
|
|
||||||
var section = sections[sectionIndex];
|
var section = sections[sectionIndex];
|
||||||
|
|
||||||
int particleAmount = (int)(Math.Min(Health - section.damage, damage) * Rand.Range(0.1f, 1.0f));
|
int particleAmount = (int)(Math.Min(Health - section.damage, damage) * Rand.Range(0.01f, 1.0f));
|
||||||
|
|
||||||
|
particleAmount = Math.Min(particleAmount, 200);
|
||||||
for (int i = 0; i < particleAmount; i++)
|
for (int i = 0; i < particleAmount; i++)
|
||||||
{
|
{
|
||||||
Vector2 particlePos = new Vector2(
|
Vector2 particlePos = new Vector2(
|
||||||
|
|||||||
@@ -38,9 +38,7 @@ namespace Barotrauma.Particles
|
|||||||
|
|
||||||
private Vector2 drawPosition;
|
private Vector2 drawPosition;
|
||||||
private float drawRotation;
|
private float drawRotation;
|
||||||
|
|
||||||
//private float checkCollisionTimer;
|
|
||||||
|
|
||||||
private Hull currentHull;
|
private Hull currentHull;
|
||||||
|
|
||||||
private List<Gap> hullGaps;
|
private List<Gap> hullGaps;
|
||||||
@@ -75,7 +73,6 @@ namespace Barotrauma.Particles
|
|||||||
|
|
||||||
public void Init(ParticlePrefab prefab, Vector2 position, Vector2 speed, float rotation, Hull hullGuess = null)
|
public void Init(ParticlePrefab prefab, Vector2 position, Vector2 speed, float rotation, Hull hullGuess = null)
|
||||||
{
|
{
|
||||||
|
|
||||||
this.prefab = prefab;
|
this.prefab = prefab;
|
||||||
|
|
||||||
spriteIndex = Rand.Int(prefab.Sprites.Count);
|
spriteIndex = Rand.Int(prefab.Sprites.Count);
|
||||||
@@ -116,8 +113,6 @@ namespace Barotrauma.Particles
|
|||||||
if (prefab.DeleteOnCollision || prefab.CollidesWithWalls)
|
if (prefab.DeleteOnCollision || prefab.CollidesWithWalls)
|
||||||
{
|
{
|
||||||
hullGaps = currentHull == null ? new List<Gap>() : currentHull.ConnectedGaps;
|
hullGaps = currentHull == null ? new List<Gap>() : currentHull.ConnectedGaps;
|
||||||
//hullLimits = new List<Hull>();
|
|
||||||
//hullLimits = FindLimits(position);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (prefab.RotateToDirection)
|
if (prefab.RotateToDirection)
|
||||||
@@ -128,18 +123,6 @@ namespace Barotrauma.Particles
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//private List<Hull> FindLimits(Vector2 position)
|
|
||||||
//{
|
|
||||||
// List<Hull> hullList = new List<Hull>();
|
|
||||||
|
|
||||||
// currentHull = Hull.FindHull(position);
|
|
||||||
// if (currentHull == null) return hullList;
|
|
||||||
|
|
||||||
// hullList.Add(currentHull);
|
|
||||||
|
|
||||||
// return FindAdjacentHulls(hullList, currentHull, Math.Abs(velocity.X) > Math.Abs(velocity.Y));
|
|
||||||
//}
|
|
||||||
|
|
||||||
public bool Update(float deltaTime)
|
public bool Update(float deltaTime)
|
||||||
{
|
{
|
||||||
prevPosition = position;
|
prevPosition = position;
|
||||||
@@ -190,12 +173,13 @@ namespace Barotrauma.Particles
|
|||||||
|
|
||||||
if (currentHull == null)
|
if (currentHull == null)
|
||||||
{
|
{
|
||||||
var collidedHull = Hull.FindHullOld(edgePos);
|
Hull collidedHull = Hull.FindHull(position);
|
||||||
if (collidedHull != null)
|
if (collidedHull != null)
|
||||||
{
|
{
|
||||||
if (prefab.DeleteOnCollision) return false;
|
if (prefab.DeleteOnCollision) return false;
|
||||||
OnWallCollisionOutside(collidedHull);
|
OnWallCollisionOutside(collidedHull);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else if (!Submarine.RectContains(currentHull.WorldRect, edgePos))
|
else if (!Submarine.RectContains(currentHull.WorldRect, edgePos))
|
||||||
{
|
{
|
||||||
@@ -216,11 +200,11 @@ namespace Barotrauma.Particles
|
|||||||
}
|
}
|
||||||
|
|
||||||
gapFound = true;
|
gapFound = true;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gapFound)
|
if (!gapFound)
|
||||||
{
|
{
|
||||||
|
|
||||||
OnWallCollisionInside(currentHull, edgePos);
|
OnWallCollisionInside(currentHull, edgePos);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -229,9 +213,8 @@ namespace Barotrauma.Particles
|
|||||||
hullGaps = currentHull == null ? new List<Gap>() : currentHull.ConnectedGaps;
|
hullGaps = currentHull == null ? new List<Gap>() : currentHull.ConnectedGaps;
|
||||||
|
|
||||||
if (OnChangeHull != null) OnChangeHull(edgePos, currentHull);
|
if (OnChangeHull != null) OnChangeHull(edgePos, currentHull);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lifeTime -= deltaTime;
|
lifeTime -= deltaTime;
|
||||||
|
|||||||
@@ -340,7 +340,7 @@ namespace Barotrauma
|
|||||||
spriteBatch.End();
|
spriteBatch.End();
|
||||||
|
|
||||||
spriteBatch.Begin(SpriteSortMode.Immediate,
|
spriteBatch.Begin(SpriteSortMode.Immediate,
|
||||||
BlendState.AlphaBlend, SamplerState.LinearWrap,
|
BlendState.NonPremultiplied, SamplerState.LinearWrap,
|
||||||
null, null,
|
null, null,
|
||||||
damageEffect,
|
damageEffect,
|
||||||
cam.Transform);
|
cam.Transform);
|
||||||
|
|||||||
Reference in New Issue
Block a user