frustum check refactor

This commit is contained in:
h4570
2022-08-18 09:51:13 +02:00
parent b9cde6346f
commit 1ba2cb55b7
12 changed files with 146 additions and 47 deletions
+2 -5
View File
@@ -27,11 +27,8 @@ BBox::BBox(Vec4* t_vertices, u32* faces, u32 count)
BBox::BBox(const BBox& t_bbox) : CoreBBox(t_bbox) { setData(); }
BBox::BBox(const BBox& t_bbox, const M4x4& t_matrix) {
for (u32 i = 0; i < 8; i++) {
vertices[i] = t_matrix * t_bbox.vertices[i];
}
BBox::BBox(const BBox& t_bbox, const M4x4& t_matrix)
: CoreBBox(t_bbox, t_matrix) {
setData();
}
@@ -126,8 +126,8 @@ void DynPipCore::render(DynPipBag** bags, const u32& count) {
auto* bag = bags[i];
CoreBBox bbox(bag->verticesTo, bag->count);
if (bbox.isInFrustum(rendererCore->renderer3D.frustumPlanes.getAll(),
*bag->info->model) ==
if (bbox.frustumCheck(rendererCore->renderer3D.frustumPlanes.getAll(),
*bag->info->model) ==
CoreBBoxFrustum::OUTSIDE_FRUSTUM) {
continue;
}
@@ -65,7 +65,7 @@ void DynamicPipeline::render(DynamicMesh* mesh, const DynPipOptions* options) {
if (options->frustumCulling == PipelineFrustumCulling_Simple) {
auto* frameTo = mesh->frames[mesh->animation.getState().nextFrame];
if (frameTo->bbox->isInFrustum(
if (frameTo->bbox->frustumCheck(
rendererCore->renderer3D.frustumPlanes.getAll(), model) ==
CoreBBoxFrustum::OUTSIDE_FRUSTUM) {
return;
@@ -117,7 +117,7 @@ void MinecraftPipeline::render(std::vector<McpipBlock*> blocks, Texture* t_tex,
CoreBBoxFrustum MinecraftPipeline::isInFrustum(const McpipBlock& block) const {
const auto* frustumPlanes = rendererCore->renderer3D.frustumPlanes.getAll();
return bbox->clipIsInFrustum(frustumPlanes, *block.model);
return bbox->clipFrustumCheck(frustumPlanes, *block.model);
}
void MinecraftPipeline::cull(std::vector<McpipBlock*> blocks,
@@ -105,12 +105,14 @@ CoreBBoxFrustum StaPipBagPackager::checkFrustum(const StaPipBagPackage& pkg) {
if (pkg.size <= (maxVertCount / 3)) { // Is subpackage
auto& bbox = renderBBox->getChildBBox1By3(pkg.indexOf1By3BBox);
return bbox.clipIsInFrustum(frustumPlanes->getAll(), *pkg.bag->info->model);
return bbox.clipFrustumCheck(frustumPlanes->getAll(),
*pkg.bag->info->model);
} else { // Is package
const auto& indexOfPart = pkg.indexOf1By3BBox;
auto partSize = ceil(pkg.size / static_cast<float>(maxVertCount / 3));
auto bbox = renderBBox->createChildBBox(indexOfPart, partSize);
return bbox.clipIsInFrustum(frustumPlanes->getAll(), *pkg.bag->info->model);
return bbox.clipFrustumCheck(frustumPlanes->getAll(),
*pkg.bag->info->model);
}
}
@@ -119,7 +119,7 @@ void StaPipCore::render(StaPipBag* bag, StaPipBagPackagesBBox* bbox) {
else
renderBbox = bbox;
frustumCheck = renderBbox->getMainBBox()->clipIsInFrustum(
frustumCheck = renderBbox->getMainBBox()->clipFrustumCheck(
rendererCore->renderer3D.frustumPlanes.getAll(), *bag->info->model);
if (frustumCheck == OUTSIDE_FRUSTUM) {
@@ -62,7 +62,7 @@ void StaticPipeline::render(StaticMesh* mesh, const StaPipOptions* options) {
if (options->frustumCulling == PipelineFrustumCulling_Simple) {
auto* frame = mesh->frame;
if (frame->bbox->isInFrustum(
if (frame->bbox->frustumCheck(
rendererCore->renderer3D.frustumPlanes.getAll(), model) ==
CoreBBoxFrustum::OUTSIDE_FRUSTUM) {
return;