mirror of
https://github.com/AleziaKurdis/overte.git
synced 2025-06-15 12:46:05 +02:00
wip
This commit is contained in:
parent
97c4184db1
commit
4806f901b4
5 changed files with 10 additions and 92 deletions
|
@ -308,6 +308,7 @@ void EntityRenderer::computeMirrorView(ViewFrustum& viewFrustum) const {
|
||||||
projection[3][2] = c.w;
|
projection[3][2] = c.w;
|
||||||
|
|
||||||
viewFrustum.setProjection(projection);
|
viewFrustum.setProjection(projection);
|
||||||
|
viewFrustum.setIsOblique(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void EntityRenderer::render(RenderArgs* args) {
|
void EntityRenderer::render(RenderArgs* args) {
|
||||||
|
@ -596,7 +597,7 @@ graphics::MaterialPointer EntityRenderer::getTopMaterial() {
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityRenderer::Pipeline EntityRenderer::getPipelineType(const graphics::MultiMaterial& materials) {
|
EntityRenderer::Pipeline EntityRenderer::getPipelineType(const graphics::MultiMaterial& materials) {
|
||||||
if (_mirrorMode != MirrorMode::NONE) {
|
if (_mirrorMode == MirrorMode::MIRROR || (_mirrorMode == MirrorMode::PORTAL && !_portalExitID.isNull())) {
|
||||||
return Pipeline::MIRROR;
|
return Pipeline::MIRROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -325,73 +325,6 @@ void CullSpatialSelection::run(const RenderContextPointer& renderContext,
|
||||||
std::static_pointer_cast<Config>(renderContext->jobConfig)->numItems = (int)outItems.size();
|
std::static_pointer_cast<Config>(renderContext->jobConfig)->numItems = (int)outItems.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CullShapeBounds::run(const RenderContextPointer& renderContext, const Inputs& inputs, Outputs& outputs) {
|
|
||||||
assert(renderContext->args);
|
|
||||||
assert(renderContext->args->hasViewFrustum());
|
|
||||||
RenderArgs* args = renderContext->args;
|
|
||||||
|
|
||||||
const auto& inShapes = inputs.get0();
|
|
||||||
const auto& cullFilter = inputs.get1();
|
|
||||||
const auto& boundsFilter = inputs.get2();
|
|
||||||
ViewFrustumPointer antiFrustum;
|
|
||||||
auto& outShapes = outputs.edit0();
|
|
||||||
auto& outBounds = outputs.edit1();
|
|
||||||
|
|
||||||
if (!inputs[3].isNull()) {
|
|
||||||
antiFrustum = inputs.get3();
|
|
||||||
}
|
|
||||||
outShapes.clear();
|
|
||||||
outBounds = AABox();
|
|
||||||
|
|
||||||
if (!cullFilter.selectsNothing() || !boundsFilter.selectsNothing()) {
|
|
||||||
auto& details = args->_details.edit(_detailType);
|
|
||||||
CullTest test(_cullFunctor, args, details, antiFrustum);
|
|
||||||
auto scene = args->_scene;
|
|
||||||
|
|
||||||
for (auto& inItems : inShapes) {
|
|
||||||
auto key = inItems.first;
|
|
||||||
auto outItems = outShapes.find(key);
|
|
||||||
if (outItems == outShapes.end()) {
|
|
||||||
outItems = outShapes.insert(std::make_pair(key, ItemBounds{})).first;
|
|
||||||
outItems->second.reserve(inItems.second.size());
|
|
||||||
}
|
|
||||||
|
|
||||||
details._considered += (int)inItems.second.size();
|
|
||||||
|
|
||||||
if (antiFrustum == nullptr) {
|
|
||||||
for (auto& item : inItems.second) {
|
|
||||||
if (test.solidAngleTest(item.bound) && test.frustumTest(item.bound)) {
|
|
||||||
const auto shapeKey = scene->getItem(item.id).getKey();
|
|
||||||
if (cullFilter.test(shapeKey)) {
|
|
||||||
outItems->second.emplace_back(item);
|
|
||||||
}
|
|
||||||
if (boundsFilter.test(shapeKey)) {
|
|
||||||
outBounds += item.bound;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
for (auto& item : inItems.second) {
|
|
||||||
if (test.solidAngleTest(item.bound) && test.frustumTest(item.bound) && test.antiFrustumTest(item.bound)) {
|
|
||||||
const auto shapeKey = scene->getItem(item.id).getKey();
|
|
||||||
if (cullFilter.test(shapeKey)) {
|
|
||||||
outItems->second.emplace_back(item);
|
|
||||||
}
|
|
||||||
if (boundsFilter.test(shapeKey)) {
|
|
||||||
outBounds += item.bound;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
details._rendered += (int)outItems->second.size();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto& items : outShapes) {
|
|
||||||
items.second.shrink_to_fit();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void ApplyCullFunctorOnItemBounds::run(const RenderContextPointer& renderContext, const Inputs& inputs, Outputs& outputs) {
|
void ApplyCullFunctorOnItemBounds::run(const RenderContextPointer& renderContext, const Inputs& inputs, Outputs& outputs) {
|
||||||
assert(renderContext->args);
|
assert(renderContext->args);
|
||||||
assert(renderContext->args->hasViewFrustum());
|
assert(renderContext->args->hasViewFrustum());
|
||||||
|
|
|
@ -121,29 +121,6 @@ namespace render {
|
||||||
void run(const RenderContextPointer& renderContext, const Inputs& inputs, ItemBounds& outItems);
|
void run(const RenderContextPointer& renderContext, const Inputs& inputs, ItemBounds& outItems);
|
||||||
};
|
};
|
||||||
|
|
||||||
class CullShapeBounds {
|
|
||||||
public:
|
|
||||||
using Inputs = render::VaryingSet4<ShapeBounds, ItemFilter, ItemFilter, ViewFrustumPointer>;
|
|
||||||
using Outputs = render::VaryingSet2<ShapeBounds, AABox>;
|
|
||||||
using JobModel = Job::ModelIO<CullShapeBounds, Inputs, Outputs>;
|
|
||||||
|
|
||||||
CullShapeBounds(CullFunctor cullFunctor, RenderDetails::Type type) :
|
|
||||||
_cullFunctor{ cullFunctor },
|
|
||||||
_detailType(type) {}
|
|
||||||
|
|
||||||
CullShapeBounds(CullFunctor cullFunctor) :
|
|
||||||
_cullFunctor{ cullFunctor } {
|
|
||||||
}
|
|
||||||
|
|
||||||
void run(const RenderContextPointer& renderContext, const Inputs& inputs, Outputs& outputs);
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
CullFunctor _cullFunctor;
|
|
||||||
RenderDetails::Type _detailType{ RenderDetails::OTHER };
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
class ApplyCullFunctorOnItemBounds {
|
class ApplyCullFunctorOnItemBounds {
|
||||||
public:
|
public:
|
||||||
using Inputs = render::VaryingSet2<ItemBounds, ViewFrustumPointer>;
|
using Inputs = render::VaryingSet2<ItemBounds, ViewFrustumPointer>;
|
||||||
|
|
|
@ -208,6 +208,11 @@ bool ViewFrustum::sphereIntersectsFrustum(const glm::vec3& center, float radius)
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ViewFrustum::boxIntersectsFrustum(const AABox& box) const {
|
bool ViewFrustum::boxIntersectsFrustum(const AABox& box) const {
|
||||||
|
// FIXME: remove once we fix culling
|
||||||
|
if (_isOblique) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
// only check against frustum
|
// only check against frustum
|
||||||
for(int i = 0; i < NUM_FRUSTUM_PLANES; i++) {
|
for(int i = 0; i < NUM_FRUSTUM_PLANES; i++) {
|
||||||
const glm::vec3& normal = _planes[i].getNormal();
|
const glm::vec3& normal = _planes[i].getNormal();
|
||||||
|
|
|
@ -51,6 +51,7 @@ public:
|
||||||
void setProjection(float cameraFov, float cameraAspectRatio, float cameraNearClip, float cameraFarClip);
|
void setProjection(float cameraFov, float cameraAspectRatio, float cameraNearClip, float cameraFarClip);
|
||||||
void setFocalLength(float focalLength) { _focalLength = focalLength; }
|
void setFocalLength(float focalLength) { _focalLength = focalLength; }
|
||||||
bool isPerspective() const;
|
bool isPerspective() const;
|
||||||
|
void setIsOblique(bool isOblique) { _isOblique = isOblique; }
|
||||||
|
|
||||||
// getters for lens attributes
|
// getters for lens attributes
|
||||||
const glm::mat4& getProjection() const { return _projection; }
|
const glm::mat4& getProjection() const { return _projection; }
|
||||||
|
@ -103,7 +104,6 @@ public:
|
||||||
|
|
||||||
bool pointIntersectsFrustum(const glm::vec3& point) const;
|
bool pointIntersectsFrustum(const glm::vec3& point) const;
|
||||||
bool sphereIntersectsFrustum(const glm::vec3& center, float radius) const;
|
bool sphereIntersectsFrustum(const glm::vec3& center, float radius) const;
|
||||||
bool cubeIntersectsFrustum(const AACube& box) const;
|
|
||||||
bool boxIntersectsFrustum(const AABox& box) const;
|
bool boxIntersectsFrustum(const AABox& box) const;
|
||||||
bool boxInsideFrustum(const AABox& box) const;
|
bool boxInsideFrustum(const AABox& box) const;
|
||||||
|
|
||||||
|
@ -175,6 +175,8 @@ private:
|
||||||
float _nearClip { DEFAULT_NEAR_CLIP };
|
float _nearClip { DEFAULT_NEAR_CLIP };
|
||||||
float _farClip { DEFAULT_FAR_CLIP };
|
float _farClip { DEFAULT_FAR_CLIP };
|
||||||
|
|
||||||
|
bool _isOblique { false };
|
||||||
|
|
||||||
const char* debugPlaneName (int plane) const;
|
const char* debugPlaneName (int plane) const;
|
||||||
|
|
||||||
// Used to project points
|
// Used to project points
|
||||||
|
|
Loading…
Reference in a new issue