Portals - disable frustum culling gizmos with preview camera
When using the preview camera feature it turns out as well as culling the game objects, this also culls the editor gizmos from the preview camera, which makes the editor hard to use in this mode. To get around this problem we simply disable frustum culling for GLOBAL portal_mode objects when in preview camera mode. This could be a bit slower in an editor scene with lots of gizmos but is the simplest way of solving the problem.
This commit is contained in:
parent
78d9a4ae7e
commit
93c78af488
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
|
|
@ -228,10 +228,11 @@ void PortalTracer::cull_statics(const VSRoom &p_room, const LocalVector<Plane> &
|
|||
} // 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();
|
||||
int current_result = first_result;
|
||||
|
||||
if (!p_override_camera) {
|
||||
for (uint32_t n = 0; n < num_globals; n++) {
|
||||
const PortalRenderer::Moving &moving = _portal_renderer->get_moving_global(n);
|
||||
|
||||
|
@ -258,6 +259,25 @@ int PortalTracer::trace_globals(const LocalVector<Plane> &p_planes, VSInstance *
|
|||
}
|
||||
#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;
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
||||
// 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; }
|
||||
|
||||
|
|
Loading…
Reference in a new issue