From c605359b0e7fe2c729a917eeacd6ac20fc3a1d71 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 15 Apr 2020 19:41:15 +0200 Subject: [PATCH] - animator transitioned. --- src/common/textures/texturemanager.h | 1 + src/common/textures/textures.h | 7 ++++- src/gamedata/textures/animations.cpp | 46 ++++++++++++++-------------- 3 files changed, 30 insertions(+), 24 deletions(-) diff --git a/src/common/textures/texturemanager.h b/src/common/textures/texturemanager.h index 51ff8af04e..304d771c9f 100644 --- a/src/common/textures/texturemanager.h +++ b/src/common/textures/texturemanager.h @@ -158,6 +158,7 @@ public: } FTexture* Texture(FTextureID id) { return Textures[id.GetIndex()].Texture; } + FGameTexture* GameTexture(FTextureID id) { return reinterpret_cast(Textures[id.GetIndex()].Texture); } void SetTranslation(FTextureID fromtexnum, FTextureID totexnum); private: diff --git a/src/common/textures/textures.h b/src/common/textures/textures.h index d95e5ac6c4..17047050d6 100644 --- a/src/common/textures/textures.h +++ b/src/common/textures/textures.h @@ -668,7 +668,8 @@ public: double GetDisplayTopOffset(int adjusted = 0) /*const*/ { return wrapped.GetDisplayTopOffsetDouble(adjusted); } bool isValid() { return wrapped.isValid(); } - bool isWarped() { return wrapped.isWarped(); } + int isWarped() { return wrapped.isWarped(); } + void SetWarpStyle(int style) { wrapped.bWarped = style; } bool isMasked() { return wrapped.isMasked(); } bool isHardwareCanvas() const { return wrapped.isHardwareCanvas(); } // There's two here so that this can deal with software canvases in the hardware renderer later. bool isSoftwareCanvas() const { return wrapped.isCanvas(); } @@ -678,7 +679,9 @@ public: bool isFullbright() const { return wrapped.isFullbright(); } bool expandSprites() const { return wrapped.bExpandSprite; } bool useWorldPanning() const { return wrapped.UseWorldPanning(); } + void SetWorldPanning(bool on) { wrapped.SetWorldPanning(on); } bool allowNoDecals() const { return wrapped.allowNoDecals(); } + void SetNoDecals(bool on) { wrapped.bNoDecals = on; } void SetTranslucent(bool on) { wrapped.bTranslucent = on; } ETextureType GetUseType() const { return wrapped.GetUseType(); } void SetUseType(ETextureType type) { wrapped.SetUseType(type); } @@ -686,6 +689,7 @@ public: float GetShaderSpeed() const { return wrapped.GetShaderSpeed(); } uint16_t GetRotations() const { return wrapped.GetRotations(); } void SetRotations(int index) { wrapped.SetRotations(index); } + void SetSkyOffset(int ofs) { wrapped.SetSkyOffset(ofs); } int GetSkyOffset() const { return wrapped.GetSkyOffset(); } FTextureID GetID() const { return wrapped.GetID(); } ISoftwareTexture* GetSoftwareTexture() { return wrapped.GetSoftwareTexture(); } @@ -739,6 +743,7 @@ public: int CheckRealHeight() { return wrapped.CheckRealHeight(); } bool isSkybox() const { return wrapped.isSkybox(); } void SetSize(int x, int y) { wrapped.SetSize(x, y); } + void SetDisplaySize(float w, float h) { wrapped.SetSize((int)w, (int)h); } void SetSpriteRect() { wrapped.SetSpriteRect(); } const SpritePositioningInfo& GetSpritePositioning(int which) { /* todo: keep two sets of positioning infd*/ if (wrapped.mTrimResult == -1) wrapped.SetupSpriteData(); return wrapped.spi; } diff --git a/src/gamedata/textures/animations.cpp b/src/gamedata/textures/animations.cpp index e45a594e1b..ab4a5d2a8c 100644 --- a/src/gamedata/textures/animations.cpp +++ b/src/gamedata/textures/animations.cpp @@ -245,8 +245,8 @@ void FTextureAnimator::InitAnimated (void) // [RH] Bit 1 set means allow decals on walls with this texture bool nodecals = !(*anim_p & 2); - TexMan.Texture(pic2)->SetNoDecals(nodecals); - TexMan.Texture(pic1)->SetNoDecals(nodecals); + TexMan.GameTexture(pic2)->SetNoDecals(nodecals); + TexMan.GameTexture(pic1)->SetNoDecals(nodecals); } else { @@ -255,8 +255,8 @@ void FTextureAnimator::InitAnimated (void) continue; } - FTexture *tex1 = TexMan.Texture(pic1); - FTexture *tex2 = TexMan.Texture(pic2); + auto tex1 = TexMan.GameTexture(pic1); + auto tex2 = TexMan.GameTexture(pic2); animspeed = (anim_p[19] << 0) | (anim_p[20] << 8) | (anim_p[21] << 16) | (anim_p[22] << 24); @@ -355,7 +355,7 @@ void FTextureAnimator::InitAnimDefs () sc.MustGetNumber(); if (picnum.Exists()) { - TexMan.Texture(picnum)->SetSkyOffset(sc.Number); + TexMan.GameTexture(picnum)->SetSkyOffset(sc.Number); } } else @@ -408,7 +408,7 @@ void FTextureAnimator::ParseAnim (FScanner &sc, ETextureType usetype) // no decals on animating textures, by default if (picnum.isValid()) { - TexMan.Texture(picnum)->SetNoDecals(true); + TexMan.GameTexture(picnum)->SetNoDecals(true); } while (sc.GetString ()) @@ -417,7 +417,7 @@ void FTextureAnimator::ParseAnim (FScanner &sc, ETextureType usetype) { if (picnum.isValid()) { - TexMan.Texture(picnum)->SetNoDecals(false); + TexMan.GameTexture(picnum)->SetNoDecals(false); } continue; } @@ -439,7 +439,7 @@ void FTextureAnimator::ParseAnim (FScanner &sc, ETextureType usetype) } else if (sc.Compare ("range")) { - if (picnum.Exists() && TexMan.Texture(picnum)->GetName().IsEmpty()) + if (picnum.Exists() && TexMan.GameTexture(picnum)->GetName().IsEmpty()) { // long texture name: We cannot do ranged anims on these because they have no defined order sc.ScriptError ("You cannot use \"range\" for long texture names."); @@ -513,7 +513,7 @@ FAnimDef *FTextureAnimator::ParseRangeAnim (FScanner &sc, FTextureID picnum, ETe return NULL; // Animation is only one frame or does not exist } - if (TexMan.Texture(framenum)->GetName().IsEmpty()) + if (TexMan.GameTexture(framenum)->GetName().IsEmpty()) { // long texture name: We cannot do ranged anims on these because they have no defined order sc.ScriptError ("You cannot use \"range\" for long texture names."); @@ -522,7 +522,7 @@ FAnimDef *FTextureAnimator::ParseRangeAnim (FScanner &sc, FTextureID picnum, ETe if (framenum < picnum) { type = FAnimDef::ANIM_Backward; - TexMan.Texture(framenum)->SetNoDecals(TexMan.Texture(picnum)->allowNoDecals()); + TexMan.GameTexture(framenum)->SetNoDecals(TexMan.GameTexture(picnum)->allowNoDecals()); std::swap (framenum, picnum); } FAnimDef *ani = AddSimpleAnim (picnum, framenum - picnum + 1, min, max - min); @@ -649,7 +649,7 @@ void FTextureAnimator::ParseWarp(FScanner &sc) if (picnum.isValid()) { - FTexture *warper = TexMan.Texture(picnum); + auto warper = TexMan.GameTexture(picnum); if (warper->GetName().IsEmpty()) { @@ -666,7 +666,7 @@ void FTextureAnimator::ParseWarp(FScanner &sc) if (sc.CheckFloat()) { - warper->SetSpeed(float(sc.Float)); + warper->SetShaderSpeed(float(sc.Float)); } // No decals on warping textures, by default. @@ -699,7 +699,7 @@ void FTextureAnimator::ParseCameraTexture(FScanner &sc) { const BITFIELD texflags = FTextureManager::TEXMAN_Overridable | FTextureManager::TEXMAN_TryAny | FTextureManager::TEXMAN_ShortNameOnly; int width, height; - int fitwidth, fitheight; + double fitwidth, fitheight; FString picname; sc.MustGetString (); @@ -709,14 +709,14 @@ void FTextureAnimator::ParseCameraTexture(FScanner &sc) sc.MustGetNumber (); height = sc.Number; FTextureID picnum = TexMan.CheckForTexture (picname, ETextureType::Flat, texflags); - FTexture *viewer = new FCanvasTexture (picname, width, height); + FGameTexture *viewer = reinterpret_cast(new FCanvasTexture (picname, width, height)); if (picnum.Exists()) { - FTexture *oldtex = TexMan.Texture(picnum); + auto oldtex = TexMan.GameTexture(picnum); fitwidth = oldtex->GetDisplayWidth (); fitheight = oldtex->GetDisplayHeight (); viewer->SetUseType(oldtex->GetUseType()); - TexMan.ReplaceTexture (picnum, viewer, true); + TexMan.ReplaceTexture (picnum, viewer->GetTexture(), true); } else { @@ -724,7 +724,7 @@ void FTextureAnimator::ParseCameraTexture(FScanner &sc) fitheight = height; // [GRB] No need for oldtex viewer->SetUseType(ETextureType::Wall); - TexMan.AddTexture (viewer); + TexMan.AddTexture (viewer->GetTexture()); } if (sc.GetString()) { @@ -751,7 +751,7 @@ void FTextureAnimator::ParseCameraTexture(FScanner &sc) sc.UnGet(); } } - viewer->SetDisplaySize(fitwidth, fitheight); + viewer->SetDisplaySize((float)fitwidth, (float)fitheight); } //========================================================================== @@ -778,11 +778,11 @@ void FTextureAnimator::FixAnimations () bool noremap = false; const char *name; - name = TexMan.Texture(anim->BasePic)->GetName(); - nodecals = TexMan.Texture(anim->BasePic)->allowNoDecals(); + name = TexMan.GameTexture(anim->BasePic)->GetName(); + nodecals = TexMan.GameTexture(anim->BasePic)->allowNoDecals(); for (j = 0; j < anim->NumFrames; ++j) { - FTexture *tex = TexMan.Texture(anim->BasePic + j); + auto tex = TexMan.GameTexture(anim->BasePic + j); tex->SetNoDecals(nodecals); } } @@ -815,7 +815,7 @@ void FTextureAnimator::ParseAnimatedDoor(FScanner &sc) } else { - TexMan.Texture(anim.BaseTexture)->SetNoDecals(true); + TexMan.GameTexture(anim.BaseTexture)->SetNoDecals(true); } while (sc.GetString()) { @@ -848,7 +848,7 @@ void FTextureAnimator::ParseAnimatedDoor(FScanner &sc) } else if (sc.Compare("allowdecals")) { - if (anim.BaseTexture.Exists()) TexMan.Texture(anim.BaseTexture)->SetNoDecals(false); + if (anim.BaseTexture.Exists()) TexMan.GameTexture(anim.BaseTexture)->SetNoDecals(false); } else {