Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/physics/src/ogreode/OgreOdeUtility.cpp @ 1919

Last change on this file since 1919 was 1919, checked in by rgrieder, 16 years ago

Added OgreODE to our source repository because already we really need the newest version. And there is no hope to find any packages under linux.
The files included should compile and link with Ogre 1.4/1.6 and ODE 0.9/0.10. I was only able to test Ogre 1.4 and ODE 0.9/.10 under msvc until now.

  • Property svn:eol-style set to native
File size: 1.5 KB
Line 
1
2#include "OgreOdePrecompiledHeaders.h"
3
4#include "OgreOdeUtility.h"
5
6using namespace OgreOde;
7using namespace Ogre;
8
9const Ogre::Real Utility::Infinity = dInfinity;
10
11Real Utility::randomReal()
12{
13        return (Real)dRandReal();
14}
15
16/**
17According to the ODE docs;
18       
19By adjusting the values of ERP and CFM, you can achieve various effects.
20For example you can simulate springy constraints, where the two bodies oscillate
21as though connected by springs. Or you can simulate more spongy constraints, without
22the oscillation. In fact, ERP and CFM can be selected to have the same effect as any
23desired spring and damper constants. If you have a spring constant kp and damping constant kd,
24then the corresponding ODE constants are:
25       
26ERP = h kp / (h kp + kd)
27CFM = 1 / (h kp + kd)
28       
29where h is the stepsize. These values will give the same effect as a spring-and-damper
30system simulated with implicit first order integration.
31*/
32//-----------------------------------------------------------------------
33Real Utility::getCFM(Real spring, Real dampening, Real timeStep)
34{
35        return 1 / ((timeStep * spring) + dampening);
36}
37
38//-----------------------------------------------------------------------
39Real Utility::getERP(Real spring, Real dampening, Real timeStep)
40{
41        return  (timeStep * spring) / ((timeStep * spring) + dampening);
42}
43       
44//-----------------------------------------------------------------------
45void Utility::getSpringConstants(Real CFM, Real ERP, Real timeStep, Real &spring, Real &dampening)
46{
47        spring = (ERP / CFM) / timeStep;
48        dampening = (1 / CFM) - timeStep * spring;
49}
Note: See TracBrowser for help on using the repository browser.