nape.phys.Compound

type
class
extends
Interactor
Compound represents a grouping of physics objects into a single object.

This compound owns its constituents and works in the callback system and with respect to adding/removing from a Space as a single object.
      ____Cmp1_____
     /    /    \   \
Body1 Body2--Joint Cmp2
  |     |        \  |
Shp1  Shp2        Body3
                    |
                   Shp3
For example if you have a complex car built with several bodies and constraints you might store this in a Compound providing an easy way of removing/adding/copying the Car as well as being able to get a single callback for when the car collides with something.

When you add a compound to a Space, all of it's constituents get added and furthermore, those constituents cannot be added seperately.

Constructor

function new()
Construct a new Compound.

Instance Properties hide inherited show inherited

readonly var bodies : BodyList = []

+ List of bodies directly owned by this Compound.

readonly var castBody : Null<Body>

inherited from nape.phys.Interactor
Fast equivalent to cast(interactor, Body)

readonly var castCompound : Null<Compound>

inherited from nape.phys.Interactor
Fast equivalent to cast(interactor, Compound)

readonly var castShape : Null<nape.shape.Shape>

inherited from nape.phys.Interactor
Fast equivalent to cast(interactor, Shape)

readonly var cbTypes : nape.callbacks.CbTypeList = []

inherited from nape.phys.Interactor
Set of CbType's assigned to this Interactor.

var compound : Null<Compound> = null

Compound that this compound belongs to.

readonly var compounds : CompoundList = []

+ List of compounds directly owned by this Compound.

readonly var constraints : nape.constraint.ConstraintList = []

+ List of constraints directly owned by this Compound.

var group : Null<nape.dynamics.InteractionGroup> = null

inherited from nape.phys.Interactor
InteractionGroup assigned to this Interactor.

readonly var id : Int

inherited from nape.phys.Interactor
Unique id of this Interactor.

var space : Null<nape.space.Space> = null

+ Space this compound belongs to.

readonly var userData : Dynamic<Dynamic> = {}

inherited from nape.phys.Interactor
+ Dynamic object for user to store additional data.

Instance Methods hide inherited show inherited

function COM(weak:Bool = false):nape.geom.Vec2

+ Compute centre of mass of Compound.

function breakApart():Void

+ Breaking compound apart in-place.

function copy():Compound

+ Produce an exact copy of this Compound.

isBody():Bool

inherited from nape.phys.Interactor
+ Fast equivalent to Std.is(interactor, Body)

isCompound():Bool

inherited from nape.phys.Interactor
+ Fast equivalent to Std.is(interactor, Compound)

isShape():Bool

inherited from nape.phys.Interactor
+ Fast equivalent to Std.is(interactor, Shape)

function rotate(centre:nape.geom.Vec2, angle:Float):Compound

+ Rotate entire compound about a point.

function translate(translation:nape.geom.Vec2):Compound

+ Translate entire compound.

function visitBodies(lambda:Body -> Void):Void

+ Method to iterate over all bodies contained directly or indirectly by

function visitCompounds(lambda:Compound -> Void):Void

+ Method to iterate over all compounds contained directly or indirectly by

function visitConstraints(lambda:nape.constraint.Constraint -> Void):Void

+ Method to iterate over all constraints contained directly or indirectly by