From d581025b391fdf3b429d362f4b1a94e1f6e53413 Mon Sep 17 00:00:00 2001 From: DeaDDooMER Date: Tue, 18 Jan 2022 23:11:14 +0300 Subject: [PATCH] render: remove graphics data from TAnimationState --- src/game/g_monsters.pas | 16 ++++++++-------- src/game/g_panel.pas | 6 ++---- src/game/g_player.pas | 10 +++++----- src/game/g_textures.pas | 13 ++++--------- src/game/opengl/r_animations.pas | 12 ++++++------ src/game/opengl/r_gfx.pas | 11 ++++++----- src/game/opengl/r_items.pas | 2 +- src/game/opengl/r_map.pas | 4 ++-- src/game/opengl/r_monsters.pas | 4 ++-- src/game/opengl/r_player.pas | 2 +- src/game/opengl/r_playermodel.pas | 14 ++++++-------- src/game/opengl/r_weapons.pas | 4 ++-- 12 files changed, 45 insertions(+), 53 deletions(-) diff --git a/src/game/g_monsters.pas b/src/game/g_monsters.pas index 3301dd4..b6e68b5 100644 --- a/src/game/g_monsters.pas +++ b/src/game/g_monsters.pas @@ -4140,7 +4140,7 @@ begin anim := (vilefire <> nil); utils.writeBool(st, anim); // Если есть - сохраняем: - if anim then vilefire.SaveState(st); + if anim then vilefire.SaveState(st, 0, False); // Анимации for i := ANIM_SLEEP to ANIM_PAIN do begin @@ -4148,12 +4148,12 @@ begin anim := (FAnim[i, TDirection.D_LEFT] <> nil); utils.writeBool(st, anim); // Если есть - сохраняем - if anim then FAnim[i, TDirection.D_LEFT].SaveState(st); + if anim then FAnim[i, TDirection.D_LEFT].SaveState(st, 0, False); // Есть ли правая анимация anim := (FAnim[i, TDirection.D_RIGHT] <> nil); utils.writeBool(st, anim); // Если есть - сохраняем - if anim then FAnim[i, TDirection.D_RIGHT].SaveState(st); + if anim then FAnim[i, TDirection.D_RIGHT].SaveState(st, 0, False); end; end; @@ -4161,8 +4161,8 @@ end; procedure TMonster.LoadState (st: TStream); var i: Integer; - b: Byte; - anim: Boolean; + b, alpha: Byte; + anim, blending: Boolean; begin assert(st <> nil); @@ -4222,7 +4222,7 @@ begin if anim then begin Assert(vilefire <> nil, 'TMonster.LoadState: no vilefire anim'); - vilefire.LoadState(st); + vilefire.LoadState(st, alpha, blending); end; // Анимации for i := ANIM_SLEEP to ANIM_PAIN do @@ -4233,7 +4233,7 @@ begin if anim then begin Assert(FAnim[i, TDirection.D_LEFT] <> nil, 'TMonster.LoadState: no '+IntToStr(i)+'_left anim'); - FAnim[i, TDirection.D_LEFT].LoadState(st); + FAnim[i, TDirection.D_LEFT].LoadState(st, alpha, blending); end; // Есть ли правая анимация anim := utils.readBool(st); @@ -4241,7 +4241,7 @@ begin if anim then begin Assert(FAnim[i, TDirection.D_RIGHT] <> nil, 'TMonster.LoadState: no '+IntToStr(i)+'_right anim'); - FAnim[i, TDirection.D_RIGHT].LoadState(st); + FAnim[i, TDirection.D_RIGHT].LoadState(st, alpha, blending); end; end; end; diff --git a/src/game/g_panel.pas b/src/game/g_panel.pas index b1c8994..87bbb47 100644 --- a/src/game/g_panel.pas +++ b/src/game/g_panel.pas @@ -346,8 +346,6 @@ begin if FTextureIDs[i].Anim then begin // Àíèìèðîâàííàÿ òåêñòóðà FTextureIDs[i].AnTex := TAnimationState.Create(True, Textures[AddTextures[i].Texture].Speed, Textures[AddTextures[i].Texture].FramesCount); - FTextureIDs[i].AnTex.Blending := ByteBool(PanelRec.Flags and PANEL_FLAG_BLENDING); - FTextureIDs[i].AnTex.Alpha := PanelRec.Alpha; end end; @@ -949,7 +947,7 @@ begin end; utils.writeBool(st, anim); // Åñëè äà - ñîõðàíÿåì àíèìàöèþ - if anim then FTextureIDs[FCurTexture].AnTex.SaveState(st); + if anim then FTextureIDs[FCurTexture].AnTex.SaveState(st, FAlpha, FBlending); // moving platform state utils.writeInt(st, Integer(mMovingSpeed.X)); @@ -998,7 +996,7 @@ begin (FTextureIDs[FCurTexture].Anim) and (FTextureIDs[FCurTexture].AnTex <> nil), 'TPanel.LoadState: No animation object'); - FTextureIDs[FCurTexture].AnTex.LoadState(st); + FTextureIDs[FCurTexture].AnTex.LoadState(st, FAlpha, FBlending); end; // moving platform state diff --git a/src/game/g_player.pas b/src/game/g_player.pas index 39848ac..7d25ca5 100644 --- a/src/game/g_player.pas +++ b/src/game/g_player.pas @@ -5864,16 +5864,16 @@ begin // animation anim := (FModel <> nil); utils.writeBool(st, anim); - if anim then FModel.AnimState.SaveState(st); + if anim then FModel.AnimState.SaveState(st, 0, False); // animation for mask (same as animation, compat with older saves) anim := (FModel <> nil); utils.writeBool(st, anim); - if anim then FModel.AnimState.SaveState(st); + if anim then FModel.AnimState.SaveState(st, 0, False); end; procedure TCorpse.LoadState (st: TStream); - var anim: Boolean; r, g, b: Byte; stub: TAnimationState; + var anim, blending: Boolean; r, g, b, alpha: Byte; stub: TAnimationState; begin assert(st <> nil); @@ -5897,7 +5897,7 @@ begin anim := utils.readBool(st); if anim then begin - stub.LoadState(st); + stub.LoadState(st, alpha, blending); FModel.AnimState.CurrentFrame := Min(stub.CurrentFrame, FModel.AnimState.Length); end else @@ -5907,7 +5907,7 @@ begin end; // animation for mask (same as animation, compat with older saves) anim := utils.readBool(st); - if anim then stub.LoadState(st); + if anim then stub.LoadState(st, alpha, blending); stub.Free; end; diff --git a/src/game/g_textures.pas b/src/game/g_textures.pas index 8190ea3..dcfbd1a 100644 --- a/src/game/g_textures.pas +++ b/src/game/g_textures.pas @@ -33,8 +33,6 @@ type TAnimationState = class{$IFDEF USE_MEMPOOL}(TPoolObject){$ENDIF} private - mAlpha: Byte; - mBlending: Boolean; mCounter: Byte; // Ñ÷åò÷èê îæèäàíèÿ ìåæäó êàäðàìè mSpeed: Byte; // Âðåìÿ îæèäàíèÿ ìåæäó êàäðàìè mCurrentFrame: Integer; // Òåêóùèé êàäð (íà÷èíàÿ ñ 0) @@ -56,8 +54,8 @@ type procedure disable (); procedure revert (r: Boolean); - procedure saveState (st: TStream); - procedure loadState (st: TStream); + procedure saveState (st: TStream; mAlpha: Byte; mBlending: Boolean); + procedure loadState (st: TStream; out mAlpha: Byte; out mBlending: Boolean); function totalFrames (): Integer; inline; @@ -71,8 +69,6 @@ type property currentFrame: Integer read mCurrentFrame write mCurrentFrame; property currentCounter: Byte read mCounter write mCounter; property counter: Byte read mCounter; - property blending: Boolean read mBlending write mBlending; - property alpha: Byte read mAlpha write mAlpha; property length: Integer read mLength; end; @@ -92,7 +88,6 @@ begin mSpeed := aspeed; mEnabled := true; mCurrentFrame := 0; - mAlpha := 0; mPlayed := false; end; @@ -187,7 +182,7 @@ begin result := mLength end; -procedure TAnimationState.saveState (st: TStream); +procedure TAnimationState.saveState (st: TStream; mAlpha: Byte; mBlending: Boolean); begin if (st = nil) then exit; @@ -216,7 +211,7 @@ begin end; -procedure TAnimationState.loadState (st: TStream); +procedure TAnimationState.loadState (st: TStream; out mAlpha: Byte; out mBlending: Boolean); begin if (st = nil) then exit; diff --git a/src/game/opengl/r_animations.pas b/src/game/opengl/r_animations.pas index 74c2ebb..f50ce92 100644 --- a/src/game/opengl/r_animations.pas +++ b/src/game/opengl/r_animations.pas @@ -19,8 +19,8 @@ interface uses g_base, g_textures, MAPDEF, Imaging; // TMirrorType, TAnimationState, TDFPoint, TDynImageDataArray - procedure r_AnimationState_Draw (TID: DWORD; t: TAnimationState; x, y: Integer; mirror: TMirrorType); - procedure r_AnimationState_DrawEx (FID: DWORD; t: TAnimationState; x, y: Integer; mirror: TMirrorType; rpoint: TDFPoint; angle: SmallInt); + procedure r_AnimationState_Draw (FID: DWORD; t: TAnimationState; x, y: Integer; alpha: Byte; mirror: TMirrorType; blending: Boolean); + procedure r_AnimationState_DrawEx (FID: DWORD; t: TAnimationState; x, y: Integer; alpha: Byte; mirror: TMirrorType; blending: Boolean; rpoint: TDFPoint; angle: SmallInt); function g_CreateFramesImg (ia: TDynImageDataArray; ID: PDWORD; const Name: AnsiString; BackAnimation: Boolean = false): Boolean; @@ -56,16 +56,16 @@ implementation g_language, g_game ; - procedure r_AnimationState_Draw (TID: DWORD; t: TAnimationState; x, y: Integer; mirror: TMirrorType); + procedure r_AnimationState_Draw (FID: DWORD; t: TAnimationState; x, y: Integer; alpha: Byte; mirror: TMirrorType; blending: Boolean); begin if t.enabled then - e_DrawAdv(framesArray[TID].TexturesID[t.currentFrame], x, y, t.alpha, true, t.blending, 0, nil, mirror) + e_DrawAdv(framesArray[FID].TexturesID[t.currentFrame], x, y, alpha, true, blending, 0, nil, mirror) end; - procedure r_AnimationState_DrawEx (FID: DWORD; t: TAnimationState; x, y: Integer; mirror: TMirrorType; rpoint: TDFPoint; angle: SmallInt); + procedure r_AnimationState_DrawEx (FID: DWORD; t: TAnimationState; x, y: Integer; alpha: Byte; mirror: TMirrorType; blending: Boolean; rpoint: TDFPoint; angle: SmallInt); begin if t.enabled then - e_DrawAdv(framesArray[FID].TexturesID[t.currentFrame], x, y, t.alpha, true, t.blending, angle, @rpoint, mirror) + e_DrawAdv(framesArray[FID].TexturesID[t.currentFrame], x, y, alpha, true, blending, angle, @rpoint, mirror) end; function allocFrameSlot (): LongWord; diff --git a/src/game/opengl/r_gfx.pas b/src/game/opengl/r_gfx.pas index 5ec0017..79b3c2b 100644 --- a/src/game/opengl/r_gfx.pas +++ b/src/game/opengl/r_gfx.pas @@ -46,6 +46,7 @@ implementation type TOnceAnim = record AnimType: Byte; + Alpha: Byte; x, y: Integer; oldX, oldY: Integer; Animation: TAnimationState; @@ -109,10 +110,11 @@ implementation end; procedure r_GFX_OnceAnim (AnimType, x, y: Integer); - var find_id: DWORD; a: TAnimationState; + var find_id: DWORD; a: TAnimationState; alpha: Byte; begin if not gpart_dbg_enabled then exit; find_id := FindOnceAnim(); + alpha := 0; case AnimType of R_GFX_NONE: a := nil; R_GFX_TELEPORT: a := TAnimationState.Create(false, 6, 10); // !!! speed can be 3 @@ -137,7 +139,7 @@ implementation begin AnimType := R_GFX_SMOKE; a := TAnimationState.Create(false, 3, 10); - a.alpha := 150; + alpha := 150; end; R_GFX_EXPLODE_SKELFIRE: a := TAnimationState.Create(false, 8, 3); R_GFX_EXPLODE_PLASMA: a := TAnimationState.Create(false, 3, 4); @@ -150,9 +152,8 @@ implementation assert(false) end; OnceAnims[find_id].AnimType := AnimType; + OnceAnims[find_id].Alpha := alpha; OnceAnims[find_id].Animation := a; -// OnceAnims[find_id].Animation.Blending := Anim.Blending; -// OnceAnims[find_id].Animation.alpha := Anim.alpha; OnceAnims[find_id].x := x; OnceAnims[find_id].y := y; end; @@ -240,7 +241,7 @@ begin begin fx := nlerp(oldx, x, gLerpFactor); fy := nlerp(oldy, y, gLerpFactor); - r_AnimationState_Draw(gfxFrames[AnimType], Animation, x, y, TMirrorType.None); + r_AnimationState_Draw(gfxFrames[AnimType], Animation, x, y, Alpha, TMirrorType.None, False); end; end; end; diff --git a/src/game/opengl/r_items.pas b/src/game/opengl/r_items.pas index f42cb1f..a36feec 100644 --- a/src/game/opengl/r_items.pas +++ b/src/game/opengl/r_items.pas @@ -198,7 +198,7 @@ begin end else if itemFrames[it.ItemType] <> 0 then begin - r_AnimationState_Draw(itemFrames[it.ItemType], Animation, fX, fY, TMirrorType.None) + r_AnimationState_Draw(itemFrames[it.ItemType], Animation, fX, fY, 0, TMirrorType.None, False) end; if g_debug_Frames then diff --git a/src/game/opengl/r_map.pas b/src/game/opengl/r_map.pas index b3efdc3..35445c3 100644 --- a/src/game/opengl/r_map.pas +++ b/src/game/opengl/r_map.pas @@ -263,7 +263,7 @@ end; else Mirror := TMirrorType.None; dx := IfThen(f.Direction = TDirection.D_LEFT, -1, +1); - r_AnimationState_Draw(FlagFrames[i], FlagAnim, f.Obj.X + dx, f.Obj.Y + 1, Mirror); + r_AnimationState_Draw(FlagFrames[i], FlagAnim, f.Obj.X + dx, f.Obj.Y + 1, 0, Mirror, False); if g_debug_Frames then e_DrawQuad(f.Obj.X + f.Obj.Rect.X, f.Obj.Y + f.Obj.Rect.Y, f.Obj.X + f.Obj.Rect.X + f.Obj.Rect.Width - 1, f.Obj.Y + f.Obj.Rect.Y + f.Obj.Rect.Height - 1, 0, 255, 0) end @@ -287,7 +287,7 @@ end; h := RenTextures[Texture].Height; for xx := 0 to p.Width div w - 1 do for yy := 0 to p.Height div h - 1 do - r_AnimationState_Draw(FramesID, p.TextureIDs[p.FCurTexture].AnTex, p.X + xx * w, p.Y + yy * h, TMirrorType.None); + r_AnimationState_Draw(FramesID, p.TextureIDs[p.FCurTexture].AnTex, p.X + xx * w, p.Y + yy * h, p.Alpha, TMirrorType.None, p.Blending); end end else diff --git a/src/game/opengl/r_monsters.pas b/src/game/opengl/r_monsters.pas index 8acec37..7b1fcc4 100644 --- a/src/game/opengl/r_monsters.pas +++ b/src/game/opengl/r_monsters.pas @@ -385,7 +385,7 @@ implementation if MonsterType = MONSTER_VILE then if MonsterState = MONSTATE_SHOOT then if GetPos(MonsterTargetUID, @o) then - r_AnimationState_Draw(VileFire, VileFireAnim, o.X + o.Rect.X + (o.Rect.Width div 2) - 32, o.Y + o.Rect.Y + o.Rect.Height - 128, TMirrorType.None); + r_AnimationState_Draw(VileFire, VileFireAnim, o.X + o.Rect.X + (o.Rect.Width div 2) - 32, o.Y + o.Rect.Y + o.Rect.Height - 128, 0, TMirrorType.None, False); // Не в области рисования не ресуем: //FIXME! @@ -435,7 +435,7 @@ implementation dy := MONSTER_ANIMTABLE[MonsterType].AnimDeltaRight[MonsterAnim].Y; end; - r_AnimationState_Draw(monFrames[MonsterType, MonsterAnim, GameDirection], DirAnim[MonsterAnim, GameDirection], fX + dx, fY + dy, m); + r_AnimationState_Draw(monFrames[MonsterType, MonsterAnim, GameDirection], DirAnim[MonsterAnim, GameDirection], fX + dx, fY + dy, 0, m, False); end; if g_debug_Frames then diff --git a/src/game/opengl/r_player.pas b/src/game/opengl/r_player.pas index 6d87a18..2a962f7 100644 --- a/src/game/opengl/r_player.pas +++ b/src/game/opengl/r_player.pas @@ -360,7 +360,7 @@ begin if p.FKeys[KEY_DOWN].Pressed then ID := PunchFrames[R_BERSERK in p.FRulez, 2] else if p.FKeys[KEY_UP].Pressed then ID := PunchFrames[R_BERSERK in p.FRulez, 1] else ID := PunchFrames[R_BERSERK in p.FRulez, 0]; - r_AnimationState_Draw(ID, p.PunchAnim, fX + IfThen(p.Direction = TDirection.D_LEFT, 15 - p.Obj.Rect.X, p.Obj.Rect.X - 15), fY + fSlope + p.Obj.Rect.Y - 11, Mirror); + r_AnimationState_Draw(ID, p.PunchAnim, fX + IfThen(p.Direction = TDirection.D_LEFT, 15 - p.Obj.Rect.X, p.Obj.Rect.X - 15), fY + fSlope + p.Obj.Rect.Y - 11, 0, Mirror, False); end; if (p.FMegaRulez[MR_INVUL] > gTime) and ((gPlayerDrawn <> p) or (p.SpawnInvul >= gTime)) then diff --git a/src/game/opengl/r_playermodel.pas b/src/game/opengl/r_playermodel.pas index c4fe391..e987730 100644 --- a/src/game/opengl/r_playermodel.pas +++ b/src/game/opengl/r_playermodel.pas @@ -321,7 +321,9 @@ begin FlagAnimState, X + IfThen(pm.Direction = TDirection.D_LEFT, fp.X - 1, 2 * FLAG_BASEPOINT.X - fp.X + 1) - FLAG_BASEPOINT.X, Y + fp.Y - FLAG_BASEPOINT.Y + 1, + 0, Mirror, + False, p, IfThen(pm.Direction = TDirection.D_RIGHT, fa, -fa) ); @@ -363,15 +365,13 @@ begin // Модель: if (pm.Direction = TDirection.D_LEFT) and (Models[pm.id].Frames[TDirection.D_LEFT, pm.CurrentAnimation].base <> 0) then begin - pm.AnimState.Alpha := Alpha; // !!! FramesID := Models[pm.id].Frames[TDirection.D_LEFT, pm.CurrentAnimation].base; - r_AnimationState_Draw(FramesID, pm.AnimState, X, Y, TMirrorType.None); + r_AnimationState_Draw(FramesID, pm.AnimState, X, Y, Alpha, TMirrorType.None, False); end else begin - pm.AnimState.Alpha := Alpha; // !!! FramesID := Models[pm.id].Frames[TDirection.D_RIGHT, pm.CurrentAnimation].base; - r_AnimationState_Draw(FramesID, pm.AnimState, X, Y, Mirror); + r_AnimationState_Draw(FramesID, pm.AnimState, X, Y, Alpha, Mirror, False); end; // Маска модели: @@ -379,15 +379,13 @@ begin if (pm.Direction = TDirection.D_LEFT) and (Models[pm.id].Frames[TDirection.D_LEFT, pm.CurrentAnimation].mask <> 0) then begin - pm.AnimState.Alpha := Alpha; // !!! FramesID := Models[pm.id].Frames[TDirection.D_LEFT, pm.CurrentAnimation].mask; - r_AnimationState_Draw(FramesID, pm.AnimState, X, Y, TMirrorType.None); + r_AnimationState_Draw(FramesID, pm.AnimState, X, Y, Alpha, TMirrorType.None, False); end else begin - pm.AnimState.Alpha := Alpha; // !!! FramesID := Models[pm.id].Frames[TDirection.D_RIGHT, pm.CurrentAnimation].mask; - r_AnimationState_Draw(FramesID, pm.AnimState, X, Y, Mirror); + r_AnimationState_Draw(FramesID, pm.AnimState, X, Y, Alpha, Mirror, False); end; e_Colors.R := 255; diff --git a/src/game/opengl/r_weapons.pas b/src/game/opengl/r_weapons.pas index 648ff50..fb5e612 100644 --- a/src/game/opengl/r_weapons.pas +++ b/src/game/opengl/r_weapons.pas @@ -147,9 +147,9 @@ implementation if Animation <> nil then begin if Shots[i].ShotType in [WEAPON_BARON_FIRE, WEAPON_MANCUB_FIRE, WEAPON_SKEL_FIRE] then - r_AnimationState_DrawEx(ShotFrames[Shots[i].ShotType], Animation, fX, fY, TMirrorType.None, p, a) + r_AnimationState_DrawEx(ShotFrames[Shots[i].ShotType], Animation, fX, fY, 0, TMirrorType.None, False, p, a) else - r_AnimationState_Draw(ShotFrames[Shots[i].ShotType], Animation, fX, fY, TMirrorType.None); + r_AnimationState_Draw(ShotFrames[Shots[i].ShotType], Animation, fX, fY, 0, TMirrorType.None, False); end else if ShotTexture[Shots[i].ShotType] <> 0 then begin -- 2.29.2