Fixed an issue where sprite offsets defined in TEXTURES were not used

This commit is contained in:
biwa 2023-07-29 13:32:42 +02:00
parent f34ab6a606
commit 085df399f5
5 changed files with 10 additions and 22 deletions

View file

@ -48,6 +48,8 @@ namespace CodeImp.DoomBuilder.Data
protected long longname; protected long longname;
protected int width; protected int width;
protected int height; protected int height;
protected int offsetx;
protected int offsety;
protected Vector2D scale; protected Vector2D scale;
protected bool worldpanning; protected bool worldpanning;
private bool usecolorcorrection; private bool usecolorcorrection;
@ -141,6 +143,8 @@ namespace CodeImp.DoomBuilder.Data
public int MipMapLevels { get { return mipmaplevels; } set { mipmaplevels = value; } } public int MipMapLevels { get { return mipmaplevels; } set { mipmaplevels = value; } }
public virtual int Width { get { return width; } } public virtual int Width { get { return width; } }
public virtual int Height { get { return height; } } public virtual int Height { get { return height; } }
public int OffsetX { get { return offsetx; } }
public int OffsetY { get { return offsety; } }
//mxd. Scaled texture size is integer in ZDoom. //mxd. Scaled texture size is integer in ZDoom.
public virtual float ScaledWidth { get { return (float)Math.Round(width * scale.x); } } public virtual float ScaledWidth { get { return (float)Math.Round(width * scale.x); } }
public virtual float ScaledHeight { get { return (float)Math.Round(height * scale.y); } } public virtual float ScaledHeight { get { return (float)Math.Round(height * scale.y); } }

View file

@ -35,20 +35,6 @@ namespace CodeImp.DoomBuilder.Data
public sealed class SpriteImage : ImageData, ISpriteImage public sealed class SpriteImage : ImageData, ISpriteImage
{ {
#region ================== Variables
private int offsetx;
private int offsety;
#endregion
#region ================== Properties
public int OffsetX { get { return offsetx; } }
public int OffsetY { get { return offsety; } }
#endregion
#region ================== Constructor / Disposer #region ================== Constructor / Disposer
// Constructor // Constructor

View file

@ -52,12 +52,14 @@ namespace CodeImp.DoomBuilder.Data
#region ================== Constructor / Disposer #region ================== Constructor / Disposer
// Constructor // Constructor
public TEXTURESImage(string name, string virtualpath, int width, int height, float scalex, float scaley, public TEXTURESImage(string name, string virtualpath, int width, int height, int offsetx, int offsety, float scalex, float scaley,
bool worldpanning, TextureNamespace texturenamespace, bool optional, bool nulltexture) bool worldpanning, TextureNamespace texturenamespace, bool optional, bool nulltexture)
{ {
// Initialize // Initialize
this.width = width; this.width = width;
this.height = height; this.height = height;
this.offsetx = offsetx;
this.offsety = offsety;
this.scale.x = scalex; this.scale.x = scalex;
this.scale.y = scaley; this.scale.y = scaley;
this.worldpanning = worldpanning; this.worldpanning = worldpanning;

View file

@ -249,7 +249,7 @@ namespace CodeImp.DoomBuilder.ZDoom
float scaley = ((yscale == 0.0f) ? General.Map.Config.DefaultTextureScale : 1f / yscale); float scaley = ((yscale == 0.0f) ? General.Map.Config.DefaultTextureScale : 1f / yscale);
// Make texture // Make texture
TEXTURESImage tex = new TEXTURESImage(name, virtualpath, width, height, scalex, scaley, worldpanning, texturenamespace, optional, nulltexture); TEXTURESImage tex = new TEXTURESImage(name, virtualpath, width, height, xoffset, yoffset, scalex, scaley, worldpanning, texturenamespace, optional, nulltexture);
// Add patches // Add patches
foreach(PatchStructure p in patches) tex.AddPatch(new TexturePatch(p));//mxd foreach(PatchStructure p in patches) tex.AddPatch(new TexturePatch(p));//mxd

View file

@ -322,12 +322,8 @@ namespace CodeImp.DoomBuilder.BuilderModes
// Determine sprite size and offset // Determine sprite size and offset
float radius = sprite.ScaledWidth * 0.5f; float radius = sprite.ScaledWidth * 0.5f;
float height = sprite.ScaledHeight; float height = sprite.ScaledHeight;
ISpriteImage spriteimg = sprite as ISpriteImage; offsets.x = radius - sprite.OffsetX;
if(spriteimg != null) offsets.y = sprite.OffsetY - height;
{
offsets.x = radius - spriteimg.OffsetX;
offsets.y = spriteimg.OffsetY - height;
}
// Scale by thing type/actor scale // Scale by thing type/actor scale
// We do this after the offset x/y determination above, because that is entirely in sprite pixels space // We do this after the offset x/y determination above, because that is entirely in sprite pixels space