Merge pull request #51092 from lawnjelly/portals_preview_globals
Portals - disable frustum culling gizmos with preview camera
This commit is contained in:
commit
3875cdaec4
3 changed files with 39 additions and 19 deletions
|
@ -994,7 +994,7 @@ int PortalRenderer::cull_convex_implementation(const Vector3 &p_point, const Vec
|
||||||
return out_count;
|
return out_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
out_count = _tracer.trace_globals(planes, p_result_array, out_count, p_result_max, p_mask);
|
out_count = _tracer.trace_globals(planes, p_result_array, out_count, p_result_max, p_mask, _override_camera);
|
||||||
|
|
||||||
return out_count;
|
return out_count;
|
||||||
}
|
}
|
||||||
|
|
|
@ -228,36 +228,56 @@ void PortalTracer::cull_statics(const VSRoom &p_room, const LocalVector<Plane> &
|
||||||
} // for n through statics
|
} // for n through statics
|
||||||
}
|
}
|
||||||
|
|
||||||
int PortalTracer::trace_globals(const LocalVector<Plane> &p_planes, VSInstance **p_result_array, int first_result, int p_result_max, uint32_t p_mask) {
|
int PortalTracer::trace_globals(const LocalVector<Plane> &p_planes, VSInstance **p_result_array, int first_result, int p_result_max, uint32_t p_mask, bool p_override_camera) {
|
||||||
uint32_t num_globals = _portal_renderer->get_num_moving_globals();
|
uint32_t num_globals = _portal_renderer->get_num_moving_globals();
|
||||||
int current_result = first_result;
|
int current_result = first_result;
|
||||||
|
|
||||||
for (uint32_t n = 0; n < num_globals; n++) {
|
if (!p_override_camera) {
|
||||||
const PortalRenderer::Moving &moving = _portal_renderer->get_moving_global(n);
|
for (uint32_t n = 0; n < num_globals; n++) {
|
||||||
|
const PortalRenderer::Moving &moving = _portal_renderer->get_moving_global(n);
|
||||||
|
|
||||||
#ifdef PORTAL_RENDERER_STORE_MOVING_RIDS
|
#ifdef PORTAL_RENDERER_STORE_MOVING_RIDS
|
||||||
// debug check the instance is valid
|
// debug check the instance is valid
|
||||||
void *vss_instance = VSG::scene->_instance_get_from_rid(moving.instance_rid);
|
void *vss_instance = VSG::scene->_instance_get_from_rid(moving.instance_rid);
|
||||||
|
|
||||||
if (vss_instance) {
|
if (vss_instance) {
|
||||||
#endif
|
#endif
|
||||||
if (test_cull_inside(moving.exact_aabb, p_planes, false)) {
|
if (test_cull_inside(moving.exact_aabb, p_planes, false)) {
|
||||||
if (VSG::scene->_instance_cull_check(moving.instance, p_mask)) {
|
if (VSG::scene->_instance_cull_check(moving.instance, p_mask)) {
|
||||||
p_result_array[current_result++] = moving.instance;
|
p_result_array[current_result++] = moving.instance;
|
||||||
|
|
||||||
// full up?
|
// full up?
|
||||||
if (current_result >= p_result_max) {
|
if (current_result >= p_result_max) {
|
||||||
return current_result;
|
return current_result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
#ifdef PORTAL_RENDERER_STORE_MOVING_RIDS
|
#ifdef PORTAL_RENDERER_STORE_MOVING_RIDS
|
||||||
} else {
|
} else {
|
||||||
WARN_PRINT("vss instance is null " + PortalRenderer::_addr_to_string(moving.instance));
|
WARN_PRINT("vss instance is null " + PortalRenderer::_addr_to_string(moving.instance));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
} // if not override camera
|
||||||
|
else {
|
||||||
|
// If we are overriding the camera there is a potential problem in the editor:
|
||||||
|
// gizmos BEHIND the override camera will not be drawn.
|
||||||
|
// As this should be editor only and performance is not critical, we will just disable
|
||||||
|
// frustum culling for global objects when the camera is overriden.
|
||||||
|
for (uint32_t n = 0; n < num_globals; n++) {
|
||||||
|
const PortalRenderer::Moving &moving = _portal_renderer->get_moving_global(n);
|
||||||
|
|
||||||
|
if (VSG::scene->_instance_cull_check(moving.instance, p_mask)) {
|
||||||
|
p_result_array[current_result++] = moving.instance;
|
||||||
|
|
||||||
|
// full up?
|
||||||
|
if (current_result >= p_result_max) {
|
||||||
|
return current_result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} // if override camera
|
||||||
|
|
||||||
return current_result;
|
return current_result;
|
||||||
}
|
}
|
||||||
|
|
|
@ -105,7 +105,7 @@ public:
|
||||||
void trace(PortalRenderer &p_portal_renderer, const Vector3 &p_pos, const LocalVector<Plane> &p_planes, int p_start_room_id, TraceResult &r_result);
|
void trace(PortalRenderer &p_portal_renderer, const Vector3 &p_pos, const LocalVector<Plane> &p_planes, int p_start_room_id, TraceResult &r_result);
|
||||||
|
|
||||||
// globals are handled separately as they don't care about the rooms
|
// globals are handled separately as they don't care about the rooms
|
||||||
int trace_globals(const LocalVector<Plane> &p_planes, VSInstance **p_result_array, int first_result, int p_result_max, uint32_t p_mask);
|
int trace_globals(const LocalVector<Plane> &p_planes, VSInstance **p_result_array, int first_result, int p_result_max, uint32_t p_mask, bool p_override_camera);
|
||||||
|
|
||||||
void set_depth_limit(int p_limit) { _depth_limit = p_limit; }
|
void set_depth_limit(int p_limit) { _depth_limit = p_limit; }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue