[Bf-blender-cvs] [be07ab5] master: BGE Fix T45207: Camera actuator shakes with low height

Sybren A. Stüvel noreply at git.blender.org
Mon Jul 6 12:20:34 CEST 2015


Commit: be07ab58c66edf7368729c286d2dc6afaf76a4b8
Author: Sybren A. Stüvel
Date:   Mon Jul 6 12:20:29 2015 +0200
Branches: master
https://developer.blender.org/rBbe07ab58c66edf7368729c286d2dc6afaf76a4b8

BGE Fix T45207: Camera actuator shakes with low height

The camera-aiming code was using a near-zero-length cross product, which
caused oscillations. Thresholding on the cross product length seems to
fix this.

Reviewers: lucky3, Matpi, lordloki

Reviewed By: lordloki

Projects: #game_engine

Differential Revision: https://developer.blender.org/D1387

===================================================================

M	source/gameengine/Ketsji/KX_CameraActuator.cpp

===================================================================

diff --git a/source/gameengine/Ketsji/KX_CameraActuator.cpp b/source/gameengine/Ketsji/KX_CameraActuator.cpp
index 4dc30ae..3d1802b 100644
--- a/source/gameengine/Ketsji/KX_CameraActuator.cpp
+++ b/source/gameengine/Ketsji/KX_CameraActuator.cpp
@@ -290,11 +290,15 @@ bool KX_CameraActuator::Update(double curtime, bool frame)
 	
 	/* only for it lies: cross test and perpendicular bites up */
 	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) {
 			from[0] -= fac * fp1[1];
 			from[1] += fac * fp1[0];
 		}
-		else {
+		else if (cross < -0.01f) {
 			from[0] += fac * fp1[1];
 			from[1] -= fac * fp1[0];
 		}




More information about the Bf-blender-cvs mailing list