Skip to content

Commit

Permalink
Fixed line culling.
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriySalnikov committed Nov 5, 2024
1 parent a93e677 commit 39b8310
Showing 4 changed files with 9 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/3d/debug_draw_3d.cpp
Original file line number Diff line number Diff line change
@@ -768,6 +768,8 @@ void DebugDraw3D::add_or_update_line_with_thickness(real_t p_exp_time, std::uniq
GET_SCOPED_CFG_AND_DGC();

if (!scfg->thickness) {
AABB aabb = MathUtils::calculate_vertex_bounds(p_lines.get(), p_line_count);

#if defined(REAL_T_IS_DOUBLE) && defined(FIX_PRECISION_ENABLED)
for (size_t l = 0; l < p_line_count; l++) {
p_lines[l] -= dgc->get_center_position();
@@ -779,7 +781,8 @@ void DebugDraw3D::add_or_update_line_with_thickness(real_t p_exp_time, std::uniq
GET_PROC_TYPE(),
std::move(p_lines),
p_line_count,
p_col);
p_col,
aabb);
} else {
for (int i = 0; i < p_line_count; i += 2) {
ZoneScopedN("Convert AB to xf");
3 changes: 2 additions & 1 deletion src/3d/debug_geometry_container.cpp
Original file line number Diff line number Diff line change
@@ -402,7 +402,8 @@ void DebugGeometryContainer::update_geometry(double p_delta) {
ProcessType::PROCESS,
std::move(l),
s,
Colors::red);
Colors::red,
MathUtils::calculate_vertex_bounds(l.get(), s));
}
}
}
4 changes: 2 additions & 2 deletions src/3d/render_instances.cpp
Original file line number Diff line number Diff line change
@@ -485,7 +485,7 @@ void GeometryPool::add_or_update_instance(const std::shared_ptr<DebugDraw3DScope
inst->is_visible = true;
}

void GeometryPool::add_or_update_line(const std::shared_ptr<DebugDraw3DScopeConfig::Data> &p_cfg, const real_t &p_exp_time, const ProcessType &p_proc, std::unique_ptr<Vector3[]> p_lines, const size_t p_line_count, const Color &p_col) {
void GeometryPool::add_or_update_line(const std::shared_ptr<DebugDraw3DScopeConfig::Data> &p_cfg, const real_t &p_exp_time, const ProcessType &p_proc, std::unique_ptr<Vector3[]> p_lines, const size_t p_line_count, const Color &p_col, const AABB &p_aabb) {
ZoneScoped;
auto &proc = pools[p_cfg->dcd.viewport][(int)p_proc];
DelayedRendererLine *inst = proc.lines.get(p_exp_time > 0);
@@ -494,7 +494,7 @@ void GeometryPool::add_or_update_line(const std::shared_ptr<DebugDraw3DScopeConf
inst->lines = std::move(p_lines);
inst->lines_count = p_line_count;
inst->color = p_col;
inst->bounds = MathUtils::calculate_vertex_bounds(inst->lines.get(), p_line_count);
inst->bounds = p_aabb;
inst->expiration_time = p_exp_time;
inst->is_used_one_time = false;
inst->is_visible = true;
2 changes: 1 addition & 1 deletion src/3d/render_instances.h
Original file line number Diff line number Diff line change
@@ -247,7 +247,7 @@ class GeometryPool {
void update_expiration_delta(const double &p_delta, const ProcessType &p_proc);
void add_or_update_instance(const std::shared_ptr<DebugDraw3DScopeConfig::Data> &p_cfg, ConvertableInstanceType p_type, const real_t &p_exp_time, const ProcessType &p_proc, const Transform3D &p_transform, const Color &p_col, const SphereBounds &p_bounds, const Color *p_custom_col = nullptr);
void add_or_update_instance(const std::shared_ptr<DebugDraw3DScopeConfig::Data> &p_cfg, InstanceType p_type, const real_t &p_exp_time, const ProcessType &p_proc, const Transform3D &p_transform, const Color &p_col, const SphereBounds &p_bounds, const Color *p_custom_col = nullptr);
void add_or_update_line(const std::shared_ptr<DebugDraw3DScopeConfig::Data> &p_cfg, const real_t &p_exp_time, const ProcessType &p_proc, std::unique_ptr<Vector3[]> p_lines, const size_t p_line_count, const Color &p_col);
void add_or_update_line(const std::shared_ptr<DebugDraw3DScopeConfig::Data> &p_cfg, const real_t &p_exp_time, const ProcessType &p_proc, std::unique_ptr<Vector3[]> p_lines, const size_t p_line_count, const Color &p_col, const AABB &p_aabb);
};

#endif

0 comments on commit 39b8310

Please sign in to comment.