PhysicsEntity QML Type
An Entity that participates in the Box2D physics world More...
Import Statement: | import Bacon2D 1.0 |
Inherits: |
Properties
- active : bool
- angularDamping : float
- angularVelocity : float
- awake : bool
- body : Body
- bodyType : enumeration
- bullet : bool
- fixedRotation : bool
- fixtures : list<Fixture>
- gravityScale : float
- linearDamping : float
- linearVelocity : QPointF
- sleepingAllowed : bool
- world : World
Signals
Methods
- applyAngularImpulse(impulse)
- applyForce(force, point)
- applyForceToCenter(force)
- applyLinearImpulse(impulse, point)
- applyTorque(torque)
- getInertia()
- getLinearVelocityFromLocalPoint(point)
- getLinearVelocityFromWorldPoint(point)
- getLocalCenter()
- getMass()
- getWorldCenter()
- resetMassData()
- toLocalPoint(worldPoint)
- toLocalVector(worldVector)
- toWorldPoint(localPoint)
- toWorldVector(localVector)
Detailed Description
Property Documentation
This property is used to reduce the angular velocity. The damping parameter can be larger than 1.0f but the damping effect becomes sensitive to the time step when the damping parameter is large.
Box2D Bodyin the physics world
This property holds the current body type.
PhysicsEntity::BodyType is an enumeration: | |
---|---|
Type | Description |
Body.Static (default) | A static body does not move under simulation and behaves as if it has infinite mass. Internally, Box2D stores zero for the mass and the inverse mass. Static bodies can be moved manually by the user. A static body has zero velocity. Static bodies do not collide with other static or kinematic bodies. |
Body.Kinematic | A kinematic body moves under simulation according to its velocity. Kinematic bodies do not respond to forces. They can be moved manually by the user, but normally a kinematic body is moved by setting its velocity. A kinematic body behaves as if it has infinite mass, however, Box2D stores zero for the mass and the inverse mass. Kinematic bodies do not collide with other kinematic or static bodies. |
Body.Dynamic | A dynamic body is fully simulated. They can be moved manually by the user, but normally they move according to forces. A dynamic body can collide with all body types. A dynamic body always has finite, non-zero mass. If you try to set the mass of a dynamic body to zero, it will automatically acquire a mass of one kilogram and it won’t rotate. |
Game simulation usually generates a sequence of images that are played at some frame rate. This is called discrete simulation. In discrete simulation, rigid bodies can move by a large amount in one time step. If a physics engine doesn't account for the large motion, you may see some objects incorrectly pass through each other. This effect is called tunneling.
By default, Box2D uses continuous collision detection (CCD) to prevent dynamic bodies from tunneling through static bodies. This is done by sweeping shapes from their old position to their new positions. The engine looks for new collisions during the sweep and computes the time of impact (TOI) for these collisions. Bodies are moved to their first TOI and then the solver performs a sub-step to complete the full time step. There may be additional TOI events within a sub-step.
Normally CCD is not used between dynamic bodies. This is done to keep performance reasonable. In some game scenarios you need dynamic bodies to use CCD. For example, you may want to shoot a high speed bullet at a stack of dynamic bricks. Without CCD, the bullet might tunnel through the bricks. Fast moving objects in Box2D can be labeled as bullets. Bullets will perform CCD with both static and dynamic bodies. You should decide what bodies should be bullets based on your game design.
property alias fixedRotation: itemBody.fixedRotation
You may want a rigid body, such as a character, to have a fixed rotation. Such a body should not rotate, even under load. You can use the fixedRotation property to achieve this.
fixtures : list<Fixture> |
This property holds a list of Box2D fixtures contained within the current Body.
This property is used to reduce the linear velocity. The damping parameter can be larger than 1.0f but the damping effect becomes sensitive to the time step when the damping parameter is large.
This property holds the linear velocity of the entity's origin in world co-ordinates.
What does sleep mean? Well it is expensive to simulate bodies, so the less we have to simulate the better. When a body comes to rest we would like to stop simulating it.
When Box2D determines that a body (or group of bodies) has come to rest, the body enters a sleep state which has very little CPU overhead. If a body is awake and collides with a sleeping body, then the sleeping body wakes up. Bodies will also wake up if a joint or contact attached to them is destroyed. You can also wake a body manually.
The sleepingAllowed property lets you specify whether a body can sleep and whether a body is created sleeping.
The world defines the physics world of the game, and all bodies found in the world can interact/react with other bodies in the world.
Signal Documentation
Emitted when the Box2D body has finished initialization