1 / 23

3 . 2 . Introduction to Real-time Physics

3 . 2 . Introduction to Real-time Physics. Overview of core principles behind real-time physics systems. The concepts in this section will be tied together in later lectures. Important Concepts. Important concepts and aspects of use within game physics engines. Physics Concepts.

alaric
Télécharger la présentation

3 . 2 . Introduction to Real-time Physics

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 3.2.Introduction to Real-time Physics Overview of core principles behind real-time physics systems

  2. The concepts in this section will be tied together in later lectures. Important Concepts Important concepts and aspects of use within game physics engines

  3. Physics Concepts Closing velocity, collision direction and contact normal, centre of mass, springs, coefficient of restitution

  4. Closing Velocity The closing velocity is the total speed at which two objects are moving together, calculated by finding the component of velocity in the direction of one object to the other. In game physics engines, by convention, it is more common to use separating velocity (i.e. opposite direction but same magnitude as closing velocity), given as:

  5. Collision Direction and Contact Normal The direction in which two objects are colliding is usually called the “collision normal” or “contact normal.” If two objects, body 1 and 2, are colliding then, by convention, the collision normal is given from the first object’s perspective, i.e. from the first body’s perspective the contact is incoming from the second body, i.e. the normal is

  6. Centre of Mass The centre of mass (or “centre of gravity”) is the balance point of an object. Any separating hyperplane passing through the centre of mass will result in two volumes of equal mass. The centre of mass of a sphere or cuboid of uniform density will be located at the geometric centre point. The centre of mass isn’t always contained within the object (e.g. a donut).

  7. Springs Springs have many uses within games, including obvious examples such as a car’s suspension, but also for representing soft and/or deformable bodies. Springs offer a good means of modelling cloth, rope, etc.

  8. Video not available in on-line slides

  9. Springs: Hook’s Law • Aside: Real springs are subject to Hook’s law constrained by their limits of elasticity. In game springs can be assumed to have arbitrary wide limits of elasticity. Hook’s law states that the force exerted by a spring is linearly dependent upon the spring extension or compression from its rest position, i.e. where l holds the spring length, and l0 the rest length, and k is the spring stiffness). More generally: Where d is a vector representing the current spring’s extension. The force exerted by the spring is equally applied at both ends of the spring, but in opposite directions, i.e. the spring acts to pull/push the objects together/apart in equal measure but in opposite directions.

  10. A problem with (stiff) springs The application of Hook’s Law can be problematic if applied within an engine that updates the world using discrete steps. A spring with a high stiffness factor combined with a large extension/compression will result in a large applied force. In reality, this force is instantaneous and decreases as soon as the spring moves towards its resting length. Using a discrete time step, there is a danger that the force applied over the whole step will be sufficient to provide a ‘correction’ that results in an even larger expansion/compression in the opposite direction, which in turn, will result in an even greater ‘correction’ in the opposite direction, etc.

  11. Coefficient of Restitution When two objects collide, they compress together, and the deformation of their surfaces causes forces to build up that bring the objects apart. From the game physics engine’s point of view this happens instantaneously. The vast majority of collisions behave in a dampened spring like manner as: v’sis the separating velocity and c is the coefficient of restitution. The coefficient of restitution depends on the materials in collision (different pairs of material will have different coefficients). If the coefficient is 1.0, then the objects will bounce apart with the incident speed. If zero, then the objects coalesce and travel together

  12. Important Simulation Aspects Resolve order and resting contacts

  13. Aside: Within the physics engine, impulses will not be accumulated, but rather will be instantaneously applied to update a velocity. Normal forces will be accumulated and applied at the end of the simulation step to produce an updated velocity, position, etc. • Impulses An accelerative force acts to change velocity over time. In some cases, e.g. a fast collision, a force is applied over a very short period of time (resulting in a change of velocity). This period of time is too brief to model within the physics engine, hence an ‘instantaneous’ change in velocity is known as an impulse. For forces: For impulses:

  14. Resolution Order If an object has two simultaneous contacts, and the engine uses an iterative approach, then resolving one contact may change the other contact. The order in which contacts are resolved is important. A physically plausible approach is to resolve the most severe contact first (i.e. the contact with the lowest separating velocity or highest interpenetration) – this also helps avoid unnecessary work as correcting one contact may entail that other points of contact become separated/separating (and do not need to be further considered). Contact 1 Contact 2

  15. Resolution Order A problem with this approach is when resolving one contact puts another (previously resolved) contact back into collision. For most systems, this can be managed by iterating over contacts until all have been resolved (or an iteration limit reached). The number of iterations should be at least the number of contacts (to give them all a chance of getting seen at least once) and can be greater. More iterations will be needed to resolve a complex, interconnected set of contact. Contact interpenetration increased

  16. Resolution Order Typically, contacts are resolved for closing velocity and interpretation in separate passes, thereby permitting a different ordering when selecting which contact is to be resolved (based on the separating velocity or interpenetration depth). If the stages are combined then no one single optimal ordering is likely possible. • Aside: The number of iterations used to resolve interpenetration might not necessarily be the same as the number used to resolving collisions

  17. Resting Contacts Consider the simulation of a particle resting on the ground and subject to gravity. In the first frame the particle accelerates downward, introducing a non-zero velocity. In the second frame the position is updated, and the velocity increases again. Now it has begun to interpenetrate with the ground. The collision detector picks up on the interpenetration and generates a collision. The contact resolver looks at the particle, corrects the interpenetration and applies a collision response from the contact with the ground (based on closing velocity, material restitutions, etc.). The generated upward velocity will be small, but it may be enough to be noticed given a long frame time.

  18. Resting Contacts One approach (using micro collisions) towards solving the problem is: Detecting the problem earlier (i.e. smaller velocity to correct) by returning contacts that are nearly, but not quite interpenetrating. If the particular object was stationary in the previous frame and the generated velocity is only due to gravity, then consider it to be a resting contact, and apply an impulse that will result in a zero separating velocity. In effect, the series of micro-collisions keep the objects apart.

  19. Resting Contacts A more physically realistic approach to handling resting contacts is to apply an upwards force from the ground, pushing the object back so that its total acceleration in the vertical direction becomes zero. Whilst more realistic, this approach is also considerably more complex as there may be multiple points of contact between the body and the ground (i.e. some means of deciding how the resting forces should be distributed across the various points of contact is needed).

  20. Additional Reading Consult the recommended course text book for: Development of a range of force generators, including one for gravity and another for a drag force generator Development of spring based force generators – including basic spring, anchored spring, elastic bungee generator, buoyancy force generator, Development of a cable and rod constraint class Development of a simple particle physics engine (based on implementation of Netwon’s first and second laws) and a mass-aggregate physics engine

  21. Directed reading Directed Reading Directed physics reading

  22. Directed reading Read Chapter 5 of Game Physics Engine Development (pp69-79) on adding forces. Read Chapter 6 of Game Physics Engine Development (pp81-101) on modelling springs. Directed reading

  23. Summary Today we explored: • Range of important physical concepts. • Range of important modelling concepts. To do: • Read the directed reading. • Consider if you might wish to develop your own physics engine as your project.

More Related