Physics Engine Boundaries and Viewable Regions (Compact 2013)
3/26/2014
The physics engine uses the concepts of boundary and viewable region. The boundary is a logical rectangle that represents the whole control. The viewable region is the part of the control that is visible at any time.
Animations have a velocity and a direction that determine how the viewable region moves relative to the boundary. An animation can cause the viewable region to move outside the boundary. When this occurs, the physics engine creates a boundary animation, depending on the type of boundary that the application specifies in the call to CreatePhysicsEngine. For instance, a rubber band boundary allows the viewable region to move outside the boundary temporarily and then snap back to the boundary.
You set the boundary animation type in the PHYSICSENGINEINIT structure when you create the engine instance with the CreatePhysicsEngine function. The following table shows the three boundary animation possibilities.
Boundary animation type |
Description |
---|---|
None |
The animation stops at the boundary. |
Bounce |
The animation comes to a stop by bouncing within the boundary and coming to a stop on the boundary. |
Rubber band |
The animation moves outside the boundary temporarily and snaps back to the boundary. |
You can specify that the animation movement gradually decelerate. The x and y axes have their own settings for boundary animation type and deceleration that can be different. At the end of an animation, items in a control may appear truncated depending on where the animation stops.
If the items in a control are same size, you can specify the item size in the PHYSICSENGINEINIT structure when you create the physics engine. The physics engine calculates stopping points for an animation based on the fixed size of the items, so that the viewable region aligns with the item edges when the animation stops.
For the constants you use to specify deceleration and the animation types, see Physics Engine Constants.