mirror of
https://github.com/AquariaOSE/Aquaria.git
synced 2025-01-24 17:26:41 +00:00
Remove RenderObject::setColorMult() hack and related members
This commit is contained in:
parent
cec6bc5ebf
commit
5c558c122f
9 changed files with 36 additions and 113 deletions
|
@ -4452,10 +4452,10 @@ void Avatar::render(const RenderState& rs) const
|
|||
|
||||
if (dsq->continuity.form == FORM_SPIRIT && !skeletalSprite.getParent())
|
||||
{
|
||||
RenderState rx(rs);
|
||||
rx.color = Vector(0.2f, 0.3f, 0.6f);
|
||||
skeletalSprite.position = bodyPosition+bodyOffset;
|
||||
skeletalSprite.color = Vector(0.2f, 0.3f, 0.6f);
|
||||
skeletalSprite.render(rs);
|
||||
skeletalSprite.color = Vector(1,1,1);
|
||||
skeletalSprite.render(rx);
|
||||
}
|
||||
|
||||
Entity::render(rs);
|
||||
|
|
|
@ -2477,16 +2477,12 @@ void Entity::doEntityAvoidance(float dt, int range, float mod, Entity *ignore)
|
|||
}
|
||||
}
|
||||
|
||||
void Entity::render(const RenderState& rs) const
|
||||
void Entity::render(const RenderState& rsold) const
|
||||
{
|
||||
InterpolatedVector bcolor = color;
|
||||
InterpolatedVector bscale = scale;
|
||||
|
||||
scale *= flipScale;
|
||||
if (multColor.isInterpolating())
|
||||
{
|
||||
color *= multColor;
|
||||
}
|
||||
|
||||
|
||||
if (dsq->game->isSceneEditorActive() && dsq->game->sceneEditor.editType == ET_ENTITIES)
|
||||
{
|
||||
|
@ -2498,17 +2494,15 @@ void Entity::render(const RenderState& rs) const
|
|||
|
||||
}
|
||||
|
||||
// HACK: need to multiply base + etc
|
||||
skeletalSprite.setColorMult(this->color, this->alpha.x);
|
||||
|
||||
RenderState rs(rsold);
|
||||
rs.color *= color;
|
||||
if (multColor.isInterpolating())
|
||||
rs.color *= multColor;
|
||||
rs.alpha *= alpha.x;
|
||||
|
||||
Quad::render(rs);
|
||||
|
||||
|
||||
|
||||
renderBorder = false;
|
||||
skeletalSprite.clearColorMult();
|
||||
color = bcolor;
|
||||
scale = bscale;
|
||||
}
|
||||
|
||||
|
|
|
@ -164,8 +164,6 @@ public:
|
|||
|
||||
bool update;
|
||||
|
||||
Vector color;
|
||||
|
||||
protected:
|
||||
inline void renderOneObject(const RenderState& rs, const RenderObject *robj);
|
||||
|
||||
|
|
|
@ -315,7 +315,7 @@ void Quad::updateGrid(float dt)
|
|||
}
|
||||
}
|
||||
|
||||
void Quad::renderGrid() const
|
||||
void Quad::renderGrid(const RenderState& rs) const
|
||||
{
|
||||
if (xDivs < 2 || yDivs < 2)
|
||||
return;
|
||||
|
@ -340,10 +340,10 @@ void Quad::renderGrid() const
|
|||
const float w = this->getWidth();
|
||||
const float h = this->getHeight();
|
||||
|
||||
const float red = this->color.x;
|
||||
const float green = this->color.y;
|
||||
const float blue = this->color.z;
|
||||
const float alpha = this->alpha.x * this->alphaMod;
|
||||
const float red = rs.color.x * this->color.x;
|
||||
const float green = rs.color.y * this->color.y;
|
||||
const float blue = rs.color.z * this->color.z;
|
||||
const float alpha = rs.alpha * this->alpha.x * this->alphaMod;
|
||||
|
||||
|
||||
glBegin(GL_QUADS);
|
||||
|
@ -422,8 +422,8 @@ void Quad::onRender(const RenderState& rs) const
|
|||
if (!renderQuad) return;
|
||||
|
||||
|
||||
float _w2 = width/2.0f;
|
||||
float _h2 = height/2.0f;
|
||||
float _w2 = width*0.5f;
|
||||
float _h2 = height*0.5f;
|
||||
|
||||
if (!strip.empty())
|
||||
{
|
||||
|
@ -480,7 +480,7 @@ void Quad::onRender(const RenderState& rs) const
|
|||
}
|
||||
else
|
||||
{
|
||||
renderGrid();
|
||||
renderGrid(rs);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,7 +30,6 @@ public:
|
|||
void setWidthHeight(int w, int h);
|
||||
void setLineSize(int ls);
|
||||
|
||||
bool renderCenter;
|
||||
protected:
|
||||
|
||||
int w, h, w2, h2;
|
||||
|
@ -103,7 +102,7 @@ protected:
|
|||
|
||||
void resetGrid();
|
||||
void updateGrid(float dt);
|
||||
void renderGrid() const;
|
||||
void renderGrid(const RenderState& rs) const;
|
||||
|
||||
|
||||
float drawGridOffsetX;
|
||||
|
|
|
@ -55,44 +55,6 @@ int RenderObject::getTopLayer() const
|
|||
return layer;
|
||||
}
|
||||
|
||||
void RenderObject::setColorMult(const Vector &color, const float alpha) const
|
||||
{
|
||||
if (colorIsSaved)
|
||||
{
|
||||
debugLog("setColorMult() WARNING: can't do nested multiplies");
|
||||
return;
|
||||
}
|
||||
this->colorIsSaved = true;
|
||||
this->savedColor.x = this->color.x;
|
||||
this->savedColor.y = this->color.y;
|
||||
this->savedColor.z = this->color.z;
|
||||
this->savedAlpha = this->alpha.x;
|
||||
this->color *= color;
|
||||
this->alpha.x *= alpha;
|
||||
for (Children::const_iterator i = children.begin(); i != children.end(); i++)
|
||||
{
|
||||
(*i)->setColorMult(color, alpha);
|
||||
}
|
||||
}
|
||||
|
||||
void RenderObject::clearColorMult() const
|
||||
{
|
||||
if (!colorIsSaved)
|
||||
{
|
||||
debugLog("clearColorMult() WARNING: no saved color to restore");
|
||||
return;
|
||||
}
|
||||
this->color.x = this->savedColor.x;
|
||||
this->color.y = this->savedColor.y;
|
||||
this->color.z = this->savedColor.z;
|
||||
this->alpha.x = this->savedAlpha;
|
||||
this->colorIsSaved = false;
|
||||
for (Children::const_iterator i = children.begin(); i != children.end(); i++)
|
||||
{
|
||||
(*i)->clearColorMult();
|
||||
}
|
||||
}
|
||||
|
||||
RenderObject::RenderObject()
|
||||
{
|
||||
addType(SCO_RENDEROBJECT);
|
||||
|
@ -136,8 +98,6 @@ RenderObject::RenderObject()
|
|||
|
||||
renderBeforeParent = false;
|
||||
|
||||
|
||||
colorIsSaved = false;
|
||||
shareAlphaWithChildren = false;
|
||||
shareColorWithChildren = false;
|
||||
}
|
||||
|
@ -500,21 +460,20 @@ void RenderObject::render(const RenderState& rs) const
|
|||
|
||||
if (MotionBlurData *mb = this->motionBlur)
|
||||
{
|
||||
RenderState rx(rs);
|
||||
const Vector oldPos = position;
|
||||
const float oldAlpha = alpha.x;
|
||||
const float oldRotZ = rotation.z;
|
||||
const size_t sz = mb->positions.size();
|
||||
const float m = 1.0f / float(sz);
|
||||
const float m2 = 0.5f * (mb->transition ? mb->transitionTimer : 1.0f);
|
||||
const float m2 = alpha.x * 0.5f * (mb->transition ? mb->transitionTimer : 1.0f);
|
||||
for (size_t i = 0; i < sz; i++)
|
||||
{
|
||||
position = mb->positions[i].position;
|
||||
rotation.z = mb->positions[i].rotz;
|
||||
alpha = (1.0f-(float(i) * m)) * m2;
|
||||
renderCall(rs);
|
||||
rx.alpha = (1.0f-(float(i) * m)) * m2;
|
||||
renderCall(rx);
|
||||
}
|
||||
position = oldPos;
|
||||
alpha.x = oldAlpha;
|
||||
rotation.z = oldRotZ;
|
||||
}
|
||||
|
||||
|
@ -608,22 +567,12 @@ void RenderObject::renderCall(const RenderState& rs) const
|
|||
glScalef(scale.x, scale.y, 1);
|
||||
glTranslatef(internalOffset.x, internalOffset.y, internalOffset.z);
|
||||
|
||||
|
||||
for (Children::const_iterator i = children.begin(); i != children.end(); i++)
|
||||
{
|
||||
if (!(*i)->isDead() && (*i)->renderBeforeParent)
|
||||
(*i)->render(rs);
|
||||
}
|
||||
|
||||
|
||||
{
|
||||
Vector col = color;
|
||||
if (rlayer)
|
||||
col *= rlayer->color;
|
||||
|
||||
glColor4f(col.x, col.y, col.z, alpha.x*alphaMod);
|
||||
}
|
||||
|
||||
if (texture)
|
||||
{
|
||||
|
||||
|
@ -644,8 +593,6 @@ void RenderObject::renderCall(const RenderState& rs) const
|
|||
}
|
||||
}
|
||||
|
||||
rs.gpu.setBlend(getBlendType());
|
||||
|
||||
|
||||
bool doRender = true;
|
||||
int pass = renderPass;
|
||||
|
@ -661,12 +608,21 @@ void RenderObject::renderCall(const RenderState& rs) const
|
|||
doRender = (core->currentLayerPass == pass);
|
||||
}
|
||||
|
||||
if (renderCollisionShape)
|
||||
renderCollision(rs);
|
||||
|
||||
if (doRender)
|
||||
{
|
||||
// RenderState color applies to everything in the scene graph,
|
||||
// so that needs to be multiplied in unconditionally
|
||||
{
|
||||
Vector col = this->color * rs.color;
|
||||
glColor4f(color.x, color.y, color.z, rs.alpha*alpha.x*alphaMod);
|
||||
}
|
||||
rs.gpu.setBlend(getBlendType());
|
||||
onRender(rs);
|
||||
|
||||
if (renderCollisionShape)
|
||||
renderCollision(rs);
|
||||
}
|
||||
|
||||
|
||||
for (Children::const_iterator i = children.begin(); i != children.end(); i++)
|
||||
{
|
||||
|
|
|
@ -164,9 +164,6 @@ public:
|
|||
|
||||
int getTopLayer() const;
|
||||
|
||||
void setColorMult(const Vector &color, const float alpha) const; // HACK: const
|
||||
void clearColorMult() const; // HACK: const
|
||||
|
||||
void enableMotionBlur(int sz=10, int off=5);
|
||||
void disableMotionBlur();
|
||||
|
||||
|
@ -254,7 +251,7 @@ public:
|
|||
|
||||
|
||||
mutable InterpolatedVector position, scale;
|
||||
mutable InterpolatedVector color, alpha; // HACK: mutable should go! this is for setColorMult()
|
||||
InterpolatedVector color, alpha;
|
||||
mutable InterpolatedVector rotation;
|
||||
InterpolatedVector offset, rotationOffset, internalOffset, beforeScaleOffset;
|
||||
InterpolatedVector velocity, gravity;
|
||||
|
@ -275,11 +272,6 @@ public:
|
|||
int renderPass;
|
||||
float overrideCullRadiusSqr;
|
||||
|
||||
// --- This is hack and should not exist ---
|
||||
mutable bool colorIsSaved; // Used for both color and alpha
|
||||
mutable Vector savedColor; // Saved values from setColorMult()
|
||||
mutable float savedAlpha;
|
||||
|
||||
|
||||
float width, height; // Only used by Quads, but stored here for getCullRadius()
|
||||
|
||||
|
|
|
@ -32,8 +32,6 @@ RenderObjectLayer::RenderObjectLayer()
|
|||
followCameraLock = FCL_NONE;
|
||||
update = true;
|
||||
|
||||
color = Vector(1,1,1);
|
||||
|
||||
const int size = renderObjects.size();
|
||||
for (int i = 0; i < size; i++)
|
||||
renderObjects[i] = 0;
|
||||
|
|
|
@ -24,7 +24,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
OutlineRect::OutlineRect() : RenderObject()
|
||||
{
|
||||
lineSize = 1;
|
||||
renderCenter = false;
|
||||
}
|
||||
|
||||
void OutlineRect::setWidthHeight(int w, int h)
|
||||
|
@ -57,19 +56,6 @@ void OutlineRect::onRender(const RenderState& rs) const
|
|||
glVertex2f(-w2,h2);
|
||||
glVertex2f(w2,h2);
|
||||
glEnd();
|
||||
|
||||
if (renderCenter)
|
||||
{
|
||||
glColor3f(0.9f, 0.9f, 1);
|
||||
glBegin(GL_LINES);
|
||||
// lr
|
||||
glVertex2f(-w2,0);
|
||||
glVertex2f(w2,0);
|
||||
// ud
|
||||
glVertex2f(0,-h2);
|
||||
glVertex2f(0,h2);
|
||||
glEnd();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue