Skip to content

Commit

Permalink
fixed the radius of `draw_cylinder_ab'. fixes #40
Browse files Browse the repository at this point in the history
  • Loading branch information
DmitriySalnikov committed Mar 6, 2024
1 parent ba3056e commit 94c1390
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples_dd3d/DebugDrawDemoScene.gd
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func main_update(delta: float) -> void:
# Cylinders
DebugDraw3D.draw_cylinder($Cylinders/Cylinder1.global_transform, Color.CRIMSON)
DebugDraw3D.draw_cylinder(Transform3D(Basis.IDENTITY.scaled(Vector3(1,2,1)), $Cylinders/Cylinder2.global_position), Color.RED)
DebugDraw3D.draw_cylinder_ab($"Cylinders/Cylinder3/1".global_position, $"Cylinders/Cylinder3/2".global_position, 0.35)
DebugDraw3D.draw_cylinder_ab($"Cylinders/Cylinder3/1".global_position, $"Cylinders/Cylinder3/2".global_position, 0.7)

# Boxes
DebugDraw3D.draw_box_xf($Boxes/Box1.global_transform, Color.MEDIUM_PURPLE)
Expand Down
3 changes: 1 addition & 2 deletions src/3d/debug_draw_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -610,10 +610,9 @@ void DebugDraw3D::draw_cylinder_ab(const Vector3 &a, const Vector3 &b, const rea
// TODO maybe someone knows a better way to solve it?
Vector3 diff = b - a;
real_t len = diff.length();
real_t diameter = radius * 2;
Vector3 half_center = diff.normalized() * len * .5f;
Vector3 up = get_up_vector(half_center);
Transform3D t = Transform3D(Basis().looking_at(half_center, up).scaled_local(Vector3(diameter, diameter, len)), a + half_center);
Transform3D t = Transform3D(Basis().looking_at(half_center, up).scaled_local(Vector3(radius, radius, len)), a + half_center);

LOCK_GUARD(datalock);
auto scfg = scoped_config_for_current_thread();
Expand Down

0 comments on commit 94c1390

Please sign in to comment.