From 693223552d55dbc02ff645890f7e3f4c2696efc7 Mon Sep 17 00:00:00 2001 From: fgenesis Date: Sat, 21 May 2022 17:31:50 +0200 Subject: [PATCH] remove Quad::createStrip(), related members, and cleanup Bone strip handling Saves some work when rendering EVERY SINGLE QUAD in the game --- Aquaria/AnimationEditor.cpp | 4 -- BBGE/Quad.cpp | 92 ++++++------------------------------- BBGE/Quad.h | 7 +-- BBGE/SkeletalSprite.cpp | 3 +- BBGE/SkeletalSprite.h | 1 + 5 files changed, 16 insertions(+), 91 deletions(-) diff --git a/Aquaria/AnimationEditor.cpp b/Aquaria/AnimationEditor.cpp index fa5669f..59d882a 100644 --- a/Aquaria/AnimationEditor.cpp +++ b/Aquaria/AnimationEditor.cpp @@ -642,10 +642,6 @@ void AnimationEditor::moveBoneStripPoint(const Vector &mov) } b->strip[selectedStripPoint] = sel->changeStrip[selectedStripPoint] += mov*0.006f; - sel->setGridPoints(sel->stripVert, sel->strip); - - - } } } diff --git a/BBGE/Quad.cpp b/BBGE/Quad.cpp index e670d58..8c920dd 100644 --- a/BBGE/Quad.cpp +++ b/BBGE/Quad.cpp @@ -64,13 +64,6 @@ void Quad::setSegs(int x, int y, float dgox, float dgoy, float dgmx, float dgmy, } } -void Quad::createStrip(bool vert, int num) -{ - strip.resize(num); - stripVert = vert; - resetStrip(); -} - void Quad::createGrid(int xd, int yd) { deleteGrid(); @@ -134,29 +127,6 @@ void Quad::setGridPoints(bool vert, const std::vector &points) } } -float Quad::getStripSegmentSize() const -{ - return (1.0f/(float(strip.size()))); -} - -void Quad::resetStrip() -{ - if (!stripVert) - { - for (size_t i = 0; i < strip.size(); i++) - { - - float v = (i/(float(strip.size()))); - strip[i].x = v; - strip[i].y = 0; - } - } - else - { - errorLog("VERTICAL STRIP NOT SUPPORTED ^_-"); - } -} - void Quad::resetGrid() { for (size_t i = 0; i < xDivs; i++) @@ -422,66 +392,30 @@ void Quad::onRender(const RenderState& rs) const if (!renderQuad) return; - float _w2 = width*0.5f; - float _h2 = height*0.5f; + const float _w2 = width*0.5f; + const float _h2 = height*0.5f; - if (!strip.empty()) + if (!drawGrid) { - - - - const float texBits = 1.0f / (strip.size()-1); - - glBegin(GL_QUAD_STRIP); - - if (!stripVert) + glBegin(GL_QUADS); { - for (size_t i = 0; i < strip.size(); i++) - { - glTexCoord2f(texBits*i, 0); - glVertex2f(strip[i].x*width-_w2, strip[i].y*_h2*10 - _h2); - glTexCoord2f(texBits*i, 1); - glVertex2f(strip[i].x*width-_w2, strip[i].y*_h2*10 + _h2); - } - } - glEnd(); + glTexCoord2f(upperLeftTextureCoordinates.x, 1.0f-upperLeftTextureCoordinates.y); + glVertex2f(-_w2, +_h2); + glTexCoord2f(lowerRightTextureCoordinates.x, 1.0f-upperLeftTextureCoordinates.y); + glVertex2f(+_w2, +_h2); - glBindTexture( GL_TEXTURE_2D, 0 ); - glColor4f(1,0,0,1); - glPointSize(64); + glTexCoord2f(lowerRightTextureCoordinates.x, 1.0f-lowerRightTextureCoordinates.y); + glVertex2f(+_w2, -_h2); - glBegin(GL_POINTS); - for (size_t i = 0; i < strip.size(); i++) - { - glVertex2f((strip[i].x*width)-_w2, strip[i].y*height); + glTexCoord2f(upperLeftTextureCoordinates.x, 1.0f-lowerRightTextureCoordinates.y); + glVertex2f(-_w2, -_h2); } glEnd(); } else { - if (!drawGrid) - { - glBegin(GL_QUADS); - { - glTexCoord2f(upperLeftTextureCoordinates.x, 1.0f-upperLeftTextureCoordinates.y); - glVertex2f(-_w2, +_h2); - - glTexCoord2f(lowerRightTextureCoordinates.x, 1.0f-upperLeftTextureCoordinates.y); - glVertex2f(+_w2, +_h2); - - glTexCoord2f(lowerRightTextureCoordinates.x, 1.0f-lowerRightTextureCoordinates.y); - glVertex2f(+_w2, -_h2); - - glTexCoord2f(upperLeftTextureCoordinates.x, 1.0f-lowerRightTextureCoordinates.y); - glVertex2f(-_w2, -_h2); - } - glEnd(); - } - else - { - renderGrid(rs); - } + renderGrid(rs); } if (renderBorder) diff --git a/BBGE/Quad.h b/BBGE/Quad.h index a02273e..49771b4 100644 --- a/BBGE/Quad.h +++ b/BBGE/Quad.h @@ -62,10 +62,7 @@ public: void repeatTextureToFill(bool on); void refreshRepeatTextureToFill(); bool isRepeatingTextureToFill() const { return repeatTexture; } - void setGridPoints(bool vert, const std::vector &points); - virtual void createStrip(bool stripVert, int num); - float getStripSegmentSize() const; - void resetStrip(); + void setGridPoints(bool vert, const std::vector& points); Vector ** getDrawGrid() { return drawGrid; } void reloadDevice(); @@ -88,8 +85,6 @@ public: bool renderQuad, renderCenter; mutable bool renderBorder; // TODO: should be part of render state - bool stripVert; - std::vectorstrip; Vector texOff; float borderAlpha; diff --git a/BBGE/SkeletalSprite.cpp b/BBGE/SkeletalSprite.cpp index 5954266..0d87dd2 100644 --- a/BBGE/SkeletalSprite.cpp +++ b/BBGE/SkeletalSprite.cpp @@ -84,6 +84,7 @@ Bone::Bone() : CollideQuad() reverse = false; selectable = true; originalRenderPass = 0; + stripVert = false; } ParticleEffect *Bone::getEmitter(unsigned slot) const @@ -134,7 +135,6 @@ void Bone::createStrip(bool vert, int num) stripVert = vert; gridType = GRID_SET; changeStrip.resize(num); - setGridPoints(vert, strip); } @@ -603,7 +603,6 @@ bool AnimationLayer::createTransitionAnimation(const std::string& anim, float ti b.x = s->bones[i]->position.x; b.y = s->bones[i]->position.y; b.rot = s->bones[i]->rotation.z; - b.strip = s->bones[i]->strip; b.sx = s->bones[i]->scale.x; b.sy = s->bones[i]->scale.y; k.keyframes.push_back(b); diff --git a/BBGE/SkeletalSprite.h b/BBGE/SkeletalSprite.h index 67570c2..6050be4 100644 --- a/BBGE/SkeletalSprite.h +++ b/BBGE/SkeletalSprite.h @@ -87,6 +87,7 @@ public: void setSegmentProps(int minDist, int maxDist, bool reverse); Vector segmentOffset; + bool stripVert; bool fileRenderQuad; bool selectable; int originalRenderPass; // stores the render pass originally set in the XML file. For AC_RESET_PASS.