From: DeaDDooMER Date: Tue, 18 Jan 2022 20:11:14 +0000 (+0300) Subject: render: remove graphics data from TAnimationState X-Git-Url: http://deadsoftware.ru/gitweb?a=commitdiff_plain;h=ac375654231a010b2f2bdbd90dd74d1c2903f967;p=d2df-sdl.git render: remove graphics data from TAnimationState --- diff --git a/src/game/g_monsters.pas b/src/game/g_monsters.pas index d31219c..8f62a39 100644 --- a/src/game/g_monsters.pas +++ b/src/game/g_monsters.pas @@ -4142,7 +4142,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 @@ -4150,12 +4150,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; @@ -4163,8 +4163,8 @@ end; procedure TMonster.LoadState (st: TStream); var i: Integer; - b: Byte; - anim: Boolean; + b, alpha: Byte; + anim, blending: Boolean; begin assert(st <> nil); @@ -4224,7 +4224,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 @@ -4235,7 +4235,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); @@ -4243,7 +4243,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; // update cache diff --git a/src/game/g_panel.pas b/src/game/g_panel.pas index e3c52b0..c3f47cf 100644 --- a/src/game/g_panel.pas +++ b/src/game/g_panel.pas @@ -356,8 +356,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; @@ -1012,7 +1010,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)); @@ -1065,7 +1063,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 56199ce..9ae2b6e 100644 --- a/src/game/g_player.pas +++ b/src/game/g_player.pas @@ -5944,16 +5944,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); @@ -5977,7 +5977,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 @@ -5987,7 +5987,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 587d0da..2ec57d4 100644 --- a/src/game/opengl/r_map.pas +++ b/src/game/opengl/r_map.pas @@ -264,7 +264,7 @@ end; else Mirror := TMirrorType.None; dx := IfThen(f.Direction = TDirection.D_LEFT, -1, +1); - r_AnimationState_Draw(FlagFrames[i], FlagAnim, tx + dx, ty + 1, Mirror); + r_AnimationState_Draw(FlagFrames[i], FlagAnim, tx + dx, ty + 1, 0, Mirror, False); if g_debug_Frames then e_DrawQuad(tx + f.Obj.Rect.X, ty + f.Obj.Rect.Y, tx + f.Obj.Rect.X + f.Obj.Rect.Width - 1, ty + f.Obj.Rect.Y + f.Obj.Rect.Height - 1, 0, 255, 0) end @@ -307,7 +307,7 @@ end; h := RenTextures[Texture].Height; for xx := 0 to tw div w - 1 do for yy := 0 to th div h - 1 do - r_AnimationState_Draw(FramesID, p.TextureIDs[p.FCurTexture].AnTex, tx + xx * w, ty + yy * h, TMirrorType.None); + r_AnimationState_Draw(FramesID, p.TextureIDs[p.FCurTexture].AnTex, tx + xx * w, ty + 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 650aa22..da9f8da 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