mirror of https://github.com/axmolengine/axmol.git
add force depth write
This commit is contained in:
parent
c364323bbc
commit
be6ca1b6d2
|
@ -1122,7 +1122,7 @@ public:
|
|||
*
|
||||
* @return An Action pointer
|
||||
*/
|
||||
Action* runAction(Action* action);
|
||||
virtual Action* runAction(Action* action);
|
||||
|
||||
/**
|
||||
* Stops and removes all actions from the running action list .
|
||||
|
|
|
@ -741,6 +741,10 @@ void Sprite3D::draw(Renderer *renderer, const Mat4 &transform, uint32_t flags)
|
|||
}
|
||||
//support tint and fade
|
||||
meshCommand.setDisplayColor(Vec4(color.r, color.g, color.b, color.a));
|
||||
if (_forceDepthWrite)
|
||||
{
|
||||
meshCommand.setDepthWriteEnabled(true);
|
||||
}
|
||||
meshCommand.setTransparent(isTransparent);
|
||||
renderer->addCommand(&meshCommand);
|
||||
}
|
||||
|
@ -801,6 +805,12 @@ const AABB& Sprite3D::getAABB() const
|
|||
return _aabb;
|
||||
}
|
||||
|
||||
Action* Sprite3D::runAction(Action *action)
|
||||
{
|
||||
setForceDepthWrite(true);
|
||||
return Node::runAction(action);
|
||||
}
|
||||
|
||||
Rect Sprite3D::getBoundingBox() const
|
||||
{
|
||||
AABB aabb = getAABB();
|
||||
|
|
|
@ -126,6 +126,22 @@ public:
|
|||
*/
|
||||
const AABB& getAABB() const;
|
||||
|
||||
/**
|
||||
* Executes an action, and returns the action that is executed. For Sprite3D special logic are needed to take care of Fading.
|
||||
*
|
||||
* This node becomes the action's target. Refer to Action::getTarget()
|
||||
* @warning Actions don't retain their target.
|
||||
*
|
||||
* @return An Action pointer
|
||||
*/
|
||||
virtual Action* runAction(Action* action) override;
|
||||
|
||||
/**
|
||||
* Force to write to depth buffer, this is useful if you want to achieve effects like fading.
|
||||
*/
|
||||
void setForceDepthWrite(bool value) { _forceDepthWrite = value; }
|
||||
bool isForceDepthWrite() const { return _forceDepthWrite;};
|
||||
|
||||
/**
|
||||
* Returns 2d bounding-box
|
||||
* Note: the bouding-box is just get from the AABB which as Z=0, so that is not very accurate.
|
||||
|
@ -200,6 +216,7 @@ protected:
|
|||
bool _aabbDirty;
|
||||
unsigned int _lightMask;
|
||||
bool _shaderUsingLight; // is current shader using light ?
|
||||
bool _forceDepthWrite; // Always write to depth buffer
|
||||
|
||||
struct AsyncLoadParam
|
||||
{
|
||||
|
|
|
@ -153,6 +153,7 @@ void MeshCommand::setDepthTestEnabled(bool enable)
|
|||
|
||||
void MeshCommand::setDepthWriteEnabled(bool enable)
|
||||
{
|
||||
_forceDepthWrite = enable;
|
||||
_depthWriteEnabled = enable;
|
||||
}
|
||||
|
||||
|
@ -166,7 +167,11 @@ void MeshCommand::setTransparent(bool value)
|
|||
_isTransparent = value;
|
||||
//Skip batching for transparent mesh
|
||||
_skipBatching = value;
|
||||
setDepthWriteEnabled(!_isTransparent);
|
||||
|
||||
if (!_forceDepthWrite)
|
||||
{
|
||||
_depthWriteEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
MeshCommand::~MeshCommand()
|
||||
|
|
|
@ -127,6 +127,7 @@ protected:
|
|||
GLenum _cullFace;
|
||||
bool _depthTestEnabled;
|
||||
bool _depthWriteEnabled;
|
||||
bool _forceDepthWrite;
|
||||
|
||||
bool _renderStateCullFace;
|
||||
bool _renderStateDepthTest;
|
||||
|
|
Loading…
Reference in New Issue