jorrit | 1 Nov 2006 19:46
Picon

SF.net SVN: cel: [2367] cel/trunk

Revision: 2367
          http://svn.sourceforge.net/cel/?rev=2367&view=rev
Author:   jorrit
Date:     2006-11-01 10:46:39 -0800 (Wed, 01 Nov 2006)

Log Message:
-----------
	- Jorrit extended sqdist in blxml so that it also works for
	  2D vectors.

Modified Paths:
--------------
    cel/trunk/docs/history.txt
    cel/trunk/plugins/behaviourlayer/xml/xmlscript.cpp

Modified: cel/trunk/docs/history.txt
===================================================================
--- cel/trunk/docs/history.txt	2006-11-01 02:26:25 UTC (rev 2366)
+++ cel/trunk/docs/history.txt	2006-11-01 18:46:39 UTC (rev 2367)
 <at>  <at>  -3,11 +3,14  <at>  <at> 

 The history order is reversed so that new features are at the top.

-01-Nov-2006
-  - Andrew Dai added a very old declaration for
-    iPcLinearMovement::UpdateDR() which seems to have been
-    forgotten about but which is important for correct
-    extrapolation.
+1-Nov-2006
+	- Jorrit extended sqdist in blxml so that it also works for
+	  2D vectors.
+1-Nov-2006
+	- Andrew Dai added a very old declaration for
+	  iPcLinearMovement::UpdateDR() which seems to have been
+	  forgotten about but which is important for correct
+	  extrapolation.
 31-Oct-2006
 	- Jorrit added some better error reporting to blxml.
 	- Jorrit added some protection to crashes to blxml in case of

Modified: cel/trunk/plugins/behaviourlayer/xml/xmlscript.cpp
===================================================================
--- cel/trunk/plugins/behaviourlayer/xml/xmlscript.cpp	2006-11-01 02:26:25 UTC (rev 2366)
+++ cel/trunk/plugins/behaviourlayer/xml/xmlscript.cpp	2006-11-01 18:46:39 UTC (rev 2367)
 <at>  <at>  -2001,10 +2001,21  <at>  <at> 
 	  celXmlArg p2 = stack.Pop ();
 	  celXmlArg& top = stack.Top ();
           DUMP_EXEC ((":%04d: sqdist p1=%s p2=%s\n", i-1, A2S (top), A2S (p2)));
-	  csVector3 v1 = ArgToVector3 (top);
-	  csVector3 v2 = ArgToVector3 (p2);
-	  float sqdist = csSquaredDist::PointPoint (v1, v2);
-	  top.SetFloat (sqdist);
+	  if (top.type == CEL_DATA_VECTOR2)
+	  {
+	    csVector2 v1 = ArgToVector2 (top);
+	    csVector2 v2 = ArgToVector2 (p2);
+	    csVector2 d = v1-v2;
+	    float sqdist = d * d;
+	    top.SetFloat (sqdist);
+	  }
+	  else
+	  {
+	    csVector3 v1 = ArgToVector3 (top);
+	    csVector3 v2 = ArgToVector3 (p2);
+	    float sqdist = csSquaredDist::PointPoint (v1, v2);
+	    top.SetFloat (sqdist);
+	  }
 	}
 	break;
       case CEL_OPERATION_ABS:

This was sent by the SourceForge.net collaborative development platform, the world's largest Open
Source development site.


Gmane