Debug class providing general utilities

Also serves as the base type for Debug draws.

Static methods

staticclearObjectPools():Void

Force clear all object pools, both internal and public.

@:has_untypedstaticcreateGraphic(body:Body):Shape

Create a flash/openflnme Shape representing the given Body.

Parameters:

body

The body to create display Shape for.

Returns:

A flash/openflnme.display.Shape representing Body.

Throws:

#

If body is null.

staticversion():String

Query Nape version

Constructor

new()

@private

Variables

bgColour:Int

Background colour for debug draw display.

This value does not have much use for ShapeDebug, or for a transparent BitmapDebug but will still be used in tinting object colours to better fit an idealised background colour.

@:value(null)colour:Null<Int ‑> Int> = null

User defined colour picking.

When not null, this method will be called to decide which colour to use for an object with argument being the id of that object.

The return value should be an RGB value.

@:value(false)cullingEnabled:Bool = false

When true, objects outside the debug draw screen will not be drawn.

The debug draw screen is defined as the rectangle (0,0) -> (width,height). To 'move' the debug draw screen in your world, you should modify the transform property.

This culling has a cost, so is not worth enabling if everything is always on screen anyways.

read onlydisplay:DisplayObject

The flash/openflnme native display object representing debug draw.



When using debug drawer, you should add this to your display list.

@:value(false)drawBodies:Bool = false

If true, then all bodies in the space (whether active or not) will be drawn.

@:value(false)drawBodyDetail:Bool = false

If true, then things like the body centre of mass, and bouncing box will be drawn.

This will only have an effect if drawBodies is true.

@:value(false)drawCollisionArbiters:Bool = false

If true, a representation of contact patches will be drawn.

Only active arbiters are drawn.

@:value(false)drawConstraints:Bool = false

If true, then representations of the active constraints will be drawn.

@:value(false)drawFluidArbiters:Bool = false

If true, a representation of centres of buoyancy and overlap will be drawn.

Only active arbiters are drawn.

@:value(false)drawSensorArbiters:Bool = false

If true, a representation of sensor interactions will be drawn.

Only active arbiters are drawn.

@:value(false)drawShapeAngleIndicators:Bool = false

If true, then indicators of the shapes rotation will be drawn.

This will only have an effect if drawBodies is true.

@:value(false)drawShapeDetail:Bool = false

If true, then things like shape centre of mass and bounding box will be drawn.

This will only have an effect if drawBodies is true.

transform:Mat23

Transformation to apply to all debug draw operations.

This transform can be used to 'move' the debug draw screen through your world as well as rotating and zooming in etc.

This transform effects 'all' debug draw operations and optimisation is in place to not perform any transformation if matrix is the identity matrix.

@:value(null)zpp_inner:ZPP_Debug = null

@private

Methods

clear():Void

Clear the debug view.

draw(object:Dynamic):Void

Draw a Nape object to debug draw.

Possible argument types are: Space, Compound, Body, Shape, Constraint

To draw a Shape it must be part of a Body.

Debug draw settings like 'drawBodies' are overriden by a direct call to draw with a Body or Shape. Equally even if drawConstraints is false, should you call draw with a Constraint object directly it will be drawn regardless.

Parameters:

object

The object to draw.

Throws:

#

If object is null or not of the expected Type.

drawAABB(aabb:AABB, colour:Int):Void

Draw AABB.

This AABB will be drawn with no thickness or fill.

Parameters:

aabb

The AABB to draw.

colour

The colour to draw AABB with in RGB.

Throws:

#

If AABB is null.

drawCircle(position:Vec2, radius:Float, colour:Int):Void

Draw circle.

This circle will be drawn with no thickness or fill.

Parameters:

position

The position of circle centre.

radius

The radius of the circle.

colour

The colour of circle in RGB.

Throws:

#

If position is null or disposed of.

#

If radius is negative.

#

If transform is not equiorthogonal.

drawCurve(start:Vec2, control:Vec2, end:Vec2, colour:Int):Void

Draw quadratic bezier curve.

This curve will be drawn with no thickness.

Parameters:

start

The start point of curve.

control

The control point for curve.

end

The end point of curve.

colour

The colour of curve in RGB.

Throws:

#

If any Vec2 argument is null or disposed of.

drawFilledCircle(position:Vec2, radius:Float, colour:Int):Void

Draw filled circle.

This circle will be drawn with no edges, only a solid fill.

Parameters:

position

The position of centre of circle.

radius

The radius of circle.

colour

The colour to draw circle with in RGB.

Throws:

#

If position is null or disposed of.

#

If radius is negative.

#

If transform is not equiorthogonal.

drawFilledPolygon(polygon:Dynamic, colour:Int):Void

Draw filled polygon.

This polygon will be drawn no edges, only a solid fill.

The polygon argument is typed Dynamic and may be one of: Array<Vec2>, flash.Vector<Vec2>, Vec2List, GeomPoly

Parameters:

polygon

The polygon to draw.

colour

The colour to draw polygon with in RGB.

Throws:

#

If polygon is null, or not of expected type.

#

If polygon contains disposed Vec2.

drawFilledTriangle(p0:Vec2, p1:Vec2, p2:Vec2, colour:Int):Void

Draw filled triangle.

This triangle will be drawn with no edges, only a solid fill.

Parameters:

p0

The first point in triangle.

p1

The second point in triangle.

p2

The third point in triangle.

colour

The colour to draw triangle with in RGB.

Throws:

#

If any point argument is null or disposed of.

drawLine(start:Vec2, end:Vec2, colour:Int):Void

Draw a line segment.

This line will be drawn with no thickness.

Parameters:

start

The start point of line segment.

end

The end point of line segment.

colour

The colour of line in RGB.

Throws:

#

If either start or end are null or disposed of.

drawPolygon(polygon:Dynamic, colour:Int):Void

Draw polygon.

This polygon will be drawn with no thickness or fill.

The polygon argument is typed Dynamic and may be one of: Array<Vec2>, flash.Vector<Vec2>, Vec2List, GeomPoly

Parameters:

polygon

The polygon to draw.

colour

The colour to draw polygon with in RGB.

Throws:

#

If polygon is null, or not of expected type.

#

If polygon contains disposed Vec2.

@:value({ radius : 3.0, coils : 3 })drawSpring(start:Vec2, end:Vec2, colour:Int, coils:Int = 3, radius:Float = 3.0):Void

Draw linear spring.

This spring will be drawn with no thickness.

Parameters:

start

The start point of spring.

end

The end point of spring.

colour

The colour of spring in RGB.

coils

The number of coils in spring. (default 3)

radius

The radius of spring. (default 3.0)

Throws:

#

If start or end are either null or disposed of.

#

If number of coils is negative.

flush():Void

Flush any pending draw operations to debug view.

This operation is not needed for ShapeDebug at present.