[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [14737] trunk/blender/source/gameengine/ Ketsji/KX_CameraActuator.cpp: Fix BGE bug #6054: Camera actuator crashes Blender.

Benoit Bolsee benoit.bolsee at online.be
Thu May 8 00:32:47 CEST 2008


Revision: 14737
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=14737
Author:   ben2610
Date:     2008-05-08 00:32:45 +0200 (Thu, 08 May 2008)

Log Message:
-----------
Fix BGE bug #6054: Camera actuator crashes Blender.  The crash occurs when min,max << height (bad practice anyway).

Modified Paths:
--------------
    trunk/blender/source/gameengine/Ketsji/KX_CameraActuator.cpp

Modified: trunk/blender/source/gameengine/Ketsji/KX_CameraActuator.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_CameraActuator.cpp	2008-05-07 22:26:47 UTC (rev 14736)
+++ trunk/blender/source/gameengine/Ketsji/KX_CameraActuator.cpp	2008-05-07 22:32:45 UTC (rev 14737)
@@ -155,14 +155,25 @@
 	mat[coz][0]= vec[0];
 	mat[coz][1]= vec[1];
 	mat[coz][2]= vec[2];
-	Kx_Normalize((float *)mat[coz]);
+	if (Kx_Normalize((float *)mat[coz]) == 0.f) {
+		/* this is a very abnormal situation: the camera has reach the object center exactly
+		   We will choose a completely arbitrary direction */
+		mat[coz][0] = 1.0f;
+		mat[coz][1] = 0.0f;
+		mat[coz][2] = 0.0f;
+	}
 	
 	inp= mat[coz][2];
 	mat[coy][0]= - inp*mat[coz][0];
 	mat[coy][1]= - inp*mat[coz][1];
 	mat[coy][2]= 1.0 - inp*mat[coz][2];
 
-	Kx_Normalize((float *)mat[coy]);
+	if (Kx_Normalize((float *)mat[coy]) == 0.f) {
+		/* the camera is vertical, chose the y axis arbitrary */
+		mat[coy][0] = 0.f;
+		mat[coy][1] = 1.f;
+		mat[coy][2] = 0.f;
+	}
 	
 	Kx_Crossf(mat[cox], mat[coy], mat[coz]);
 	





More information about the Bf-blender-cvs mailing list