[Bf-committers] GameObject Python Distance function

Kester Maddock Christopher.Maddock.1 at uni.massey.ac.nz
Tue Jan 11 09:51:10 CET 2005


Hi Charlie,

Thanks for the patch.

I'll add a slightly modified version - note that in C++ the MT_ classes have 
operator overloads, so you don't have to muck around in component math, so 
you can do:

MT_Point3 a, b;
float dist = (b - a).length().  

There is also a distance method.  This type of function really belongs in a 
maths class, but as we don't have any of those we can put it in the game 
object.

Cheers,

Kester

On Tuesday 11 January 2005 10:53, charlie c wrote:
> Hey all, here is a small function. One that i think will be helpful
> as opposed to having to write a def() function every time you want to find
> the distance between
> two objects:
>
>  import GameLogic
>
>  objs = GameLogic.getCurrentScene().getObjectList()
>
>  Obj1 = objs['OBPosition1']
>  Obj2 = objs['OBPosition2']
>
>
>  print Obj1.getDistance(Obj2.getPosition())
>
>
>
>
>
> _______________________________________________
> Bf-committers mailing list
> Bf-committers at projects.blender.org
> http://projects.blender.org/mailman/listinfo/bf-committers

-- 
No evil can happen to a good man.
		-- Plato


More information about the Bf-committers mailing list