Class: Bullet3::DebugDraw
- Inherits:
-
Object
- Object
- Bullet3::DebugDraw
- Defined in:
- lib/bullet3/debug_draw.rb
Constant Summary collapse
- NO_DEBUG =
0- DRAW_WIREFRAME =
1- DRAW_AABB =
2- DRAW_CONTACT_POINTS =
8- DRAW_CONSTRAINTS =
1 << 11
- DRAW_CONSTRAINT_LIMITS =
1 << 12
- DRAW_FRAMES =
1 << 15
Instance Attribute Summary collapse
-
#contact_points ⇒ Object
readonly
Returns the value of attribute contact_points.
-
#debug_mode ⇒ Object
Returns the value of attribute debug_mode.
-
#lines ⇒ Object
readonly
Returns the value of attribute lines.
-
#texts ⇒ Object
readonly
Returns the value of attribute texts.
-
#warnings ⇒ Object
readonly
Returns the value of attribute warnings.
Instance Method Summary collapse
- #clear ⇒ Object
- #draw_3d_text(location, text) ⇒ Object
- #draw_contact_point(point, normal, distance = nil, life_time = nil, color = nil, **options) ⇒ Object
- #draw_line(from, to, color) ⇒ Object
-
#initialize(target = nil) ⇒ DebugDraw
constructor
A new instance of DebugDraw.
- #report_error_warning(message) ⇒ Object
Constructor Details
#initialize(target = nil) ⇒ DebugDraw
Returns a new instance of DebugDraw.
16 17 18 19 20 |
# File 'lib/bullet3/debug_draw.rb', line 16 def initialize(target = nil) @target = target @debug_mode = DRAW_WIREFRAME | DRAW_AABB | DRAW_CONSTRAINTS | DRAW_CONSTRAINT_LIMITS clear end |
Instance Attribute Details
#contact_points ⇒ Object (readonly)
Returns the value of attribute contact_points.
14 15 16 |
# File 'lib/bullet3/debug_draw.rb', line 14 def contact_points @contact_points end |
#debug_mode ⇒ Object
Returns the value of attribute debug_mode.
13 14 15 |
# File 'lib/bullet3/debug_draw.rb', line 13 def debug_mode @debug_mode end |
#lines ⇒ Object (readonly)
Returns the value of attribute lines.
14 15 16 |
# File 'lib/bullet3/debug_draw.rb', line 14 def lines @lines end |
#texts ⇒ Object (readonly)
Returns the value of attribute texts.
14 15 16 |
# File 'lib/bullet3/debug_draw.rb', line 14 def texts @texts end |
#warnings ⇒ Object (readonly)
Returns the value of attribute warnings.
14 15 16 |
# File 'lib/bullet3/debug_draw.rb', line 14 def warnings @warnings end |
Instance Method Details
#clear ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/bullet3/debug_draw.rb', line 22 def clear @lines = [] @contact_points = [] @warnings = [] @texts = [] nil end |
#draw_3d_text(location, text) ⇒ Object
60 61 62 63 64 65 |
# File 'lib/bullet3/debug_draw.rb', line 60 def draw_3d_text(location, text) entry = { location: vector_array(location), text: text.to_s } texts << entry @target.draw_3d_text(entry[:location], entry[:text]) if @target&.respond_to?(:draw_3d_text) nil end |
#draw_contact_point(point, normal, distance = nil, life_time = nil, color = nil, **options) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/bullet3/debug_draw.rb', line 37 def draw_contact_point(point, normal, distance = nil, life_time = nil, color = nil, **) distance = .fetch(:distance, distance) life_time = .fetch(:life_time, life_time) color = .fetch(:color, color) entry = { point: vector_array(point), normal: vector_array(normal), distance: Float(distance), life_time: Integer(life_time), color: vector_array(color) } contact_points << entry @target.draw_contact_point(entry) if @target&.respond_to?(:draw_contact_point) nil end |
#draw_line(from, to, color) ⇒ Object
30 31 32 33 34 35 |
# File 'lib/bullet3/debug_draw.rb', line 30 def draw_line(from, to, color) entry = { from: vector_array(from), to: vector_array(to), color: vector_array(color) } lines << entry @target.draw_line(entry[:from], entry[:to], entry[:color]) if @target&.respond_to?(:draw_line) nil end |
#report_error_warning(message) ⇒ Object
53 54 55 56 57 58 |
# File 'lib/bullet3/debug_draw.rb', line 53 def report_error_warning() warning = .to_s warnings << warning @target.report_error_warning(warning) if @target&.respond_to?(:report_error_warning) nil end |