mirror of
https://github.com/cocos/cocos4.git
synced 2026-12-06 19:42:39 +08:00
refine: cache lodGroup's state and reduce api call of getVisibleLODLevel (#13800)
* refine: cache lodGroup's state and reduce api call of getVisibleLODLevel
This commit is contained in:
@@ -17,7 +17,6 @@
|
||||
#include "cocos/renderer/gfx-base/GFXDef-common.h"
|
||||
#include "cocos/renderer/gfx-base/GFXDevice.h"
|
||||
#include "cocos/renderer/pipeline/InstancedBuffer.h"
|
||||
#include "cocos/renderer/pipeline/LODModelsUtil.h"
|
||||
#include "cocos/scene/Model.h"
|
||||
#include "cocos/scene/Octree.h"
|
||||
#include "cocos/scene/Pass.h"
|
||||
@@ -844,7 +843,7 @@ void octreeCulling(
|
||||
if (!model.isEnabled()) {
|
||||
continue;
|
||||
}
|
||||
if (pipeline::LODModelsCachedUtils::isLODModelCulled(&model)) {
|
||||
if (scene->isCulledByLod(&camera, &model)) {
|
||||
continue;
|
||||
}
|
||||
if (any(queue.sceneFlags & SceneFlags::SHADOW_CASTER) && model.isCastShadow()) {
|
||||
@@ -863,7 +862,7 @@ void octreeCulling(
|
||||
for (const auto& pModel : models) {
|
||||
const auto& model = *pModel;
|
||||
CC_EXPECTS(!isPointInstance(model));
|
||||
if (pipeline::LODModelsCachedUtils::isLODModelCulled(&model)) {
|
||||
if (scene->isCulledByLod(&camera, &model)) {
|
||||
continue;
|
||||
}
|
||||
addRenderObject(camera, model, queue);
|
||||
@@ -882,7 +881,7 @@ void frustumCulling(
|
||||
continue;
|
||||
}
|
||||
// filter model by view visibility
|
||||
if (pipeline::LODModelsCachedUtils::isLODModelCulled(&model)) {
|
||||
if (scene->isCulledByLod(&camera, &model)) {
|
||||
continue;
|
||||
}
|
||||
const auto visibility = camera.getVisibility();
|
||||
@@ -953,13 +952,11 @@ void buildRenderQueues(
|
||||
if (!camera->isCullingEnabled()) {
|
||||
continue;
|
||||
}
|
||||
pipeline::LODModelsCachedUtils::updateCachedLODModels(scene, camera);
|
||||
if (octree && octree->isEnabled()) {
|
||||
octreeCulling(octree, scene, skyBox, *camera, queue);
|
||||
} else {
|
||||
frustumCulling(scene, *camera, queue);
|
||||
}
|
||||
pipeline::LODModelsCachedUtils::clearCachedLODModels();
|
||||
|
||||
queue.sort();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user