From 063c270e6a1ac43962dc7074e4df22e5eef2b277 Mon Sep 17 00:00:00 2001 From: fgenesis Date: Tue, 6 Feb 2024 01:36:38 +0100 Subject: [PATCH] fix bone with spline deform not deforming (forgot tp update VBO) also fix SplineGrid to actually deform own texture (note to self: GRID_WAVY resets deform in update(). oops) --- BBGE/RenderGrid.h | 2 +- BBGE/SkeletalSprite.cpp | 6 ++++-- BBGE/SplineGrid.cpp | 3 ++- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/BBGE/RenderGrid.h b/BBGE/RenderGrid.h index d6064ff..ae0fda8 100644 --- a/BBGE/RenderGrid.h +++ b/BBGE/RenderGrid.h @@ -51,7 +51,7 @@ public: size_t height() const { return grid.height(); } size_t linearsize() const { return grid.linearsize(); } const Vector *data() const { return grid.data(); } - Vector *data() { return grid.data(); } + Vector *dataRW() { this->needVBOUpdate = true; return grid.data(); } Array2d& array2d() { return grid; } const Array2d& array2d() const { return grid; } const DynamicGPUBuffer& getVBO() const { return vbo; } diff --git a/BBGE/SkeletalSprite.cpp b/BBGE/SkeletalSprite.cpp index 3018885..cd5e958 100644 --- a/BBGE/SkeletalSprite.cpp +++ b/BBGE/SkeletalSprite.cpp @@ -2056,7 +2056,7 @@ void AnimationLayer::updateBones() DynamicRenderGrid::ResetWithAlpha(&bkey2->grid[0], grid->width(), grid->height(), 1.0f); } - Vector *dst = grid->data(); + Vector *dst = grid->dataRW(); for(size_t i = 0; i < N; ++i) { dst[i].x = lerp(bkey1->grid[i].x, bkey2->grid[i].x, dt, lerpType); @@ -2196,6 +2196,8 @@ void BoneGridInterpolator::updateGridOnly(BoneKeyframe& bk, const Bone *bone) void BoneGridInterpolator::updateGridAndBone(BoneKeyframe& bk, Bone *bone) { updateGridOnly(bk, bone); - Vector *dst = bone->getGrid()->data(); + DynamicRenderGrid *g = bone->getGrid(); + Vector *dst = g->dataRW(); std::copy(bk.grid.begin(), bk.grid.end(), dst); + } diff --git a/BBGE/SplineGrid.cpp b/BBGE/SplineGrid.cpp index 1cc8d35..ccbed40 100644 --- a/BBGE/SplineGrid.cpp +++ b/BBGE/SplineGrid.cpp @@ -91,6 +91,7 @@ DynamicRenderGrid *SplineGrid::resize(size_t w, size_t h, size_t xres, size_t yr size_t oldcpy = bsp.ctrlY(); DynamicRenderGrid *ret = this->createGrid(xres, yres); + ret->gridType = GRID_INTERP; std::vector oldp; ctrlp.swap(oldp); @@ -135,7 +136,7 @@ void SplineGrid::recalc() exportControlPoints(&bsp.controlpoints[0]); if(grid) { - bsp.recalc(grid->data(), grid->width(), grid->height()); + bsp.recalc(grid->dataRW(), grid->width(), grid->height()); wasModified = true; } }