(7cc515e57) SpriteDeformation optimization: don't update deformations on disabled or SimplePhysics characters, don't check if resolution has changed in the SpriteDeformation.Resolution getter because it's called very frequently

This commit is contained in:
Joonas Rikkonen
2019-04-18 12:05:27 +03:00
parent b0580a9050
commit c77c30fda7
3 changed files with 16 additions and 33 deletions
@@ -104,14 +104,7 @@ namespace Barotrauma.SpriteDeformations
public Point Resolution
{
get
{
if (deformationParams.Resolution.X != Deformation.GetLength(0) || deformationParams.Resolution.Y != Deformation.GetLength(1))
{
Deformation = new Vector2[deformationParams.Resolution.X, deformationParams.Resolution.Y];
}
return deformationParams.Resolution;
}
get { return deformationParams.Resolution; }
set { SetResolution(value); }
}
@@ -202,6 +195,15 @@ namespace Barotrauma.SpriteDeformations
public static Vector2[,] GetDeformation(IEnumerable<SpriteDeformation> animations, Vector2 scale)
{
foreach (SpriteDeformation animation in animations)
{
if (animation.deformationParams.Resolution.X != animation.Deformation.GetLength(0) ||
animation.deformationParams.Resolution.Y != animation.Deformation.GetLength(1))
{
animation.Deformation = new Vector2[animation.deformationParams.Resolution.X, animation.deformationParams.Resolution.Y];
}
}
Point resolution = animations.First().Resolution;
if (animations.Any(a => a.Resolution != resolution))
{
@@ -211,7 +213,6 @@ namespace Barotrauma.SpriteDeformations
}
Vector2[,] deformation = new Vector2[resolution.X, resolution.Y];
foreach (SpriteDeformation animation in animations)
{
animation.GetDeformation(out Vector2[,] animDeformation, out float multiplier);