Changeset View
Changeset View
Standalone View
Standalone View
source/gameengine/Ketsji/KX_CameraActuator.cpp
| Show First 20 Lines • Show All 284 Lines • ▼ Show 20 Lines | bool KX_CameraActuator::Update(double curtime, bool frame) | ||||
| fac = (-1.0f + inp) * m_damping; | fac = (-1.0f + inp) * m_damping; | ||||
| from[0] += fac * fp1[0]; | from[0] += fac * fp1[0]; | ||||
| from[1] += fac * fp1[1]; | from[1] += fac * fp1[1]; | ||||
| from[2] += fac * fp1[2]; | from[2] += fac * fp1[2]; | ||||
| /* only for it lies: cross test and perpendicular bites up */ | /* only for it lies: cross test and perpendicular bites up */ | ||||
| if (inp < 0.0f) { | if (inp < 0.0f) { | ||||
| if (fp1[0] * fp2[1] - fp1[1] * fp2[0] > 0.0f) { | /* Don't do anything if the cross product is too small. | ||||
| * The camera up-axis becomes unstable and starts to oscillate. | |||||
| * The 0.01f threshold is arbitrary but seems to work well in practice. */ | |||||
| float cross = fp1[0] * fp2[1] - fp1[1] * fp2[0]; | |||||
| if (cross > 0.01f) { | |||||
lordloki: As @Matpi says we can use:
```
if (cross > 0.0f && !MT_fuzzyzero(cross))
``` | |||||
| from[0] -= fac * fp1[1]; | from[0] -= fac * fp1[1]; | ||||
| from[1] += fac * fp1[0]; | from[1] += fac * fp1[0]; | ||||
| } | } | ||||
| else { | else if (cross < -0.01f) { | ||||
lordlokiUnsubmitted Not Done Inline Actionsand here: if (cross < 0.0f && !MT_fuzzyzero(cross)) lordloki: and here:
```
if (cross < 0.0f && !MT_fuzzyzero(cross))
``` | |||||
| from[0] += fac * fp1[1]; | from[0] += fac * fp1[1]; | ||||
| from[1] -= fac * fp1[0]; | from[1] -= fac * fp1[0]; | ||||
| } | } | ||||
| } | } | ||||
| /* CONSTRAINT 5: minimum / maximum distance */ | /* CONSTRAINT 5: minimum / maximum distance */ | ||||
| rc[0] = (lookat[0]-from[0]); | rc[0] = (lookat[0]-from[0]); | ||||
| ▲ Show 20 Lines • Show All 119 Lines • Show Last 20 Lines | |||||
As @Quentin Wenger (Matpi) says we can use: