A fast 2D and 3D game engine — TypeScript SDK, C++/WebAssembly core, visual editor. Ship one project to web, desktop, WeChat MiniGames, playable ads, and native Android / iOS.
TypeScript 2d-game-engine3d3d-game-engineandroidcppecsgame-editorgame-enginegamedeviostypescriptwebassemblywebglwebgpuwechat-minigame
// SPDX-License-Identifier: Apache-2.0
// SPDX-FileCopyrightText: Copyright (c) 2024-present ESEngine Team
/**
* @file Frustum.hpp
* @brief The six planes a projection bounds, and the box test against them.
*
* @details Its own header because both sides of the collect need it: the frame
* builds one, and the collect context each plugin is handed answers
* "is this visible" with it. Left inside RenderFrame.hpp those two
* could not both see it — RenderFrame.hpp includes RenderTypePlugin.hpp,
* so the plugin side only ever had a forward declaration.
*/
#pragma once
#include "../../core/Types.hpp"
#include <glm/glm.hpp>
namespace esengine {
struct Plane {
glm::vec3 normal;
f32 distance;
f32 signedDistance(const glm::vec3& point) const;
};
struct Frustum {
Plane planes[6];
void extractFromMatrix(const glm::mat4& vp);
bool intersectsAABB(const glm::vec3& center, const glm::vec3& halfExtents) const;
/// Whether the sphere of @p radius swept from @p a to @p b can touch the volume: false only when both ends stand outside the same
/// plane by more than the radius, so a capsule that clips a corner is kept.
bool intersectsSweptSphere(const glm::vec3& a, const glm::vec3& b, f32 radius) const;
};
} // namespace esengine