3.6.3同步修正

This commit is contained in:
lujun
2023-03-21 22:56:22 +08:00
parent d52561ee76
commit 76563d4c40
5 changed files with 174 additions and 122 deletions

View File

@@ -102,18 +102,21 @@ void Batcher2d::syncRootNodesToNative(ccstd::vector<Node*>&& rootNodes) {
void Batcher2d::fillBuffersAndMergeBatches() {
for (auto* rootNode : _rootNodeArr) {
walk(rootNode, 1, true, 0);
walk(rootNode, 1, true, 0, 0);
// CC_LOG_INFO("-------------- flushRendererCache 1 -------------- %d", _rootNodeArr.size());
flushRendererCache(); // LCC_UI_SORTING_GROUP
generateBatch(_currEntity, _currDrawInfo);
}
}
void Batcher2d::walk(Node* node, float parentOpacity, bool cacheEnable, float sortingPriority) { // NOLINT(misc-no-recursion)
void Batcher2d::walk(Node* node, float parentOpacity, bool cacheEnable, float sortingPriority, int sortingLevel) { // NOLINT(misc-no-recursion)
if (!node->isActiveInHierarchy()) {
return;
}
sortingPriority = node->isUISortingEnabled() ? node->getUISortingPriority() : sortingPriority;
if(node->isUISortingEnabled()){
++sortingLevel;
}
bool breakWalk = false;
auto* entity = static_cast<RenderEntity*>(node->getUserData());
@@ -128,22 +131,31 @@ void Batcher2d::walk(Node* node, float parentOpacity, bool cacheEnable, float so
// LCC_UI_SORTING_GROUP
if (entity->isEnabled()) {
if(entity->getIsMask() || !cacheEnable){
// CC_LOG_INFO("-------------- flushRendererCache 2 --------------");
flushRendererCache();
uint32_t size = entity->getRenderDrawInfosSize();
for (uint32_t i = 0; i < size; i++) {
auto* drawInfo = entity->getRenderDrawInfoAt(i);
handleDrawInfo(entity, drawInfo, node);
}
entity->setVBColorDirty(false);
}else{
rendererCache.push_back(entity);
entity->setRenderPriority(sortingPriority);
if(sortingPriority != 0){
rendererOrder = true;
}
}
if(sortingLevel > 0){
if(entity->getIsMask() || !cacheEnable){
// CC_LOG_INFO("-------------- flushRendererCache 2 --------------");
flushRendererCache();
uint32_t size = entity->getRenderDrawInfosSize();
for (uint32_t i = 0; i < size; i++) {
auto* drawInfo = entity->getRenderDrawInfoAt(i);
handleDrawInfo(entity, drawInfo, node);
}
entity->setVBColorDirty(false);
}else{
rendererCache.push_back(entity);
entity->setRenderPriority(sortingPriority);
if(sortingPriority != 0){
rendererOrder = true;
}
}
}else{
uint32_t size = entity->getRenderDrawInfosSize();
for (uint32_t i = 0; i < size; i++) {
auto* drawInfo = entity->getRenderDrawInfoAt(i);
handleDrawInfo(entity, drawInfo, node);
}
entity->setVBColorDirty(false);
}
}
if (entity->getRenderEntityType() == RenderEntityType::CROSSED) {
@@ -156,7 +168,7 @@ void Batcher2d::walk(Node* node, float parentOpacity, bool cacheEnable, float so
float thisOpacity = entity ? entity->getOpacity() : parentOpacity;
for (const auto& child : children) {
// we should find parent opacity recursively upwards if it doesn't have an entity.
walk(child, thisOpacity, cacheEnable, sortingPriority);
walk(child, thisOpacity, cacheEnable, sortingPriority, sortingLevel);
}
}
@@ -164,6 +176,13 @@ void Batcher2d::walk(Node* node, float parentOpacity, bool cacheEnable, float so
if (_stencilManager->getMaskStackSize() > 0 && entity && entity->isEnabled()) {
handlePostRender(entity);
}
if(node->isUISortingEnabled()){
--sortingLevel;
if(sortingLevel <= 0){
flushRendererCache();
}
}
}
void Batcher2d::handlePostRender(RenderEntity* entity) {
@@ -314,7 +333,7 @@ CC_FORCE_INLINE void Batcher2d::handleMiddlewareDraw(RenderEntity* entity, Rende
CC_FORCE_INLINE void Batcher2d::handleSubNode(RenderEntity* entity, RenderDrawInfo* drawInfo) { // NOLINT
if (drawInfo->getSubNode()) {
walk(drawInfo->getSubNode(), entity->getOpacity(), false, 0);
walk(drawInfo->getSubNode(), entity->getOpacity(), false, 0, 0);
}
}

View File

@@ -64,7 +64,7 @@ public:
void updateDescriptorSet();
void fillBuffersAndMergeBatches();
void walk(Node* node, float parentOpacity, bool cacheEnable, float sortingPriority);
void walk(Node* node, float parentOpacity, bool cacheEnable, float sortingPriority, int sortingLevel);
void handlePostRender(RenderEntity* entity);
void handleDrawInfo(RenderEntity* entity, RenderDrawInfo* drawInfo, Node* node);
void handleComponentDraw(RenderEntity* entity, RenderDrawInfo* drawInfo, Node* node);