修复透明度bug

This commit is contained in:
owen
2019-06-27 16:20:33 +08:00
parent 63222190b4
commit eec0bace41
12 changed files with 243 additions and 262 deletions
+35 -12
View File
@@ -81,7 +81,7 @@ RenderFlow::RenderFlow(DeviceGraphics* device, Scene* scene, ForwardRenderer* fo
RenderFlow::~RenderFlow()
{
delete _paralleTask;
CC_SAFE_DELETE(_paralleTask);
CC_SAFE_DELETE(_batcher);
}
@@ -163,7 +163,8 @@ void RenderFlow::calculateLocalMatrix(int tid)
{
if (signData->freeFlag == SPACE_FREE_FLAG) continue;
// reset world transform changed flag
*dirty &= ~WORLD_TRANSFORM_CHANGED;
*dirty &= ~(WORLD_TRANSFORM_CHANGED | OPACITY_CHANGED);
// reset opacity changed flag
if (!(*dirty & LOCAL_TRANSFORM)) continue;
localMat->setIdentity();
@@ -202,18 +203,40 @@ void RenderFlow::calculateLevelWorldMatrix(int tid)
for(std::size_t index = begin; index < end; index++)
{
auto& info = levelInfos[index];
auto selfDirty = *info.dirty & WORLD_TRANSFORM;
if (info.parentDirty != nullptr && ((*info.parentDirty & WORLD_TRANSFORM_CHANGED) || selfDirty))
auto selfWorldDirty = *info.dirty & WORLD_TRANSFORM;
auto selfOpacityDirty = *info.dirty & OPACITY;
if (info.parentDirty)
{
cocos2d::Mat4::multiply(*info.parentWorldMat, *info.localMat, info.worldMat);
*info.dirty |= WORLD_TRANSFORM_CHANGED;
*info.dirty &= ~WORLD_TRANSFORM;
if ((*info.parentDirty & WORLD_TRANSFORM_CHANGED) || selfWorldDirty)
{
cocos2d::Mat4::multiply(*info.parentWorldMat, *info.localMat, info.worldMat);
*info.dirty |= WORLD_TRANSFORM_CHANGED;
*info.dirty &= ~WORLD_TRANSFORM;
}
if ((*info.parentDirty & OPACITY_CHANGED) || selfOpacityDirty)
{
*info.realOpacity = *info.opacity * *info.parentRealOpacity / 255.0f;
*info.dirty |= OPACITY_CHANGED;
*info.dirty &= ~OPACITY;
}
}
else if (selfDirty)
else
{
*info.worldMat = *info.localMat;
*info.dirty |= WORLD_TRANSFORM_CHANGED;
*info.dirty &= ~WORLD_TRANSFORM;
if (selfWorldDirty)
{
*info.worldMat = *info.localMat;
*info.dirty |= WORLD_TRANSFORM_CHANGED;
*info.dirty &= ~WORLD_TRANSFORM;
}
if (selfOpacityDirty)
{
*info.realOpacity = *info.opacity;
*info.dirty |= OPACITY_CHANGED;
*info.dirty &= ~OPACITY;
}
}
}
}
@@ -301,7 +324,7 @@ void RenderFlow::render(NodeProxy* scene, float deltaTime)
#endif
_batcher->startBatch();
scene->visitAsRoot(_batcher, _scene);
scene->render(_batcher, _scene);
_batcher->terminateBatch();
_forward->render(_scene);