From 324b3fbe747a6544b60be1eb8a0cb6b01db736de Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 27 Aug 2009 06:55:54 +0000 Subject: [PATCH] - BGE crash fix when casting a ray to the same location as the object from python. - Incorrect Mathutils vector docstrings. - last rayshade commit had an incomplete comment. --- source/blender/python/api2_2x/vector.c | 4 ++-- source/blender/render/intern/source/rayshade.c | 4 +++- source/gameengine/Ketsji/KX_GameObject.cpp | 8 +++----- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/source/blender/python/api2_2x/vector.c b/source/blender/python/api2_2x/vector.c index cb206363dbf..a7e00e2878a 100644 --- a/source/blender/python/api2_2x/vector.c +++ b/source/blender/python/api2_2x/vector.c @@ -58,8 +58,8 @@ struct PyMethodDef Vector_methods[] = { {"normalize", (PyCFunction) Vector_Normalize, METH_NOARGS, Vector_Normalize_doc}, {"negate", (PyCFunction) Vector_Negate, METH_NOARGS, Vector_Negate_doc}, {"resize2D", (PyCFunction) Vector_Resize2D, METH_NOARGS, Vector_Resize2D_doc}, - {"resize3D", (PyCFunction) Vector_Resize3D, METH_NOARGS, Vector_Resize2D_doc}, - {"resize4D", (PyCFunction) Vector_Resize4D, METH_NOARGS, Vector_Resize2D_doc}, + {"resize3D", (PyCFunction) Vector_Resize3D, METH_NOARGS, Vector_Resize3D_doc}, + {"resize4D", (PyCFunction) Vector_Resize4D, METH_NOARGS, Vector_Resize4D_doc}, {"toTrackQuat", ( PyCFunction ) Vector_ToTrackQuat, METH_VARARGS, Vector_ToTrackQuat_doc}, {"reflect", ( PyCFunction ) Vector_Reflect, METH_O, Vector_Reflect_doc}, {"cross", ( PyCFunction ) Vector_Cross, METH_O, Vector_Dot_doc}, diff --git a/source/blender/render/intern/source/rayshade.c b/source/blender/render/intern/source/rayshade.c index 182e60365a6..e683a499e17 100644 --- a/source/blender/render/intern/source/rayshade.c +++ b/source/blender/render/intern/source/rayshade.c @@ -1240,7 +1240,9 @@ void ray_trace(ShadeInput *shi, ShadeResult *shr) if(shi->combinedflag & SCE_PASS_REFLECT) { /* values in shr->spec can be greater then 1.0. - * in the case when it is 1.0 diff */ + * In this case the mircol uses a zero blending factor, so ignoring it is ok. + * Fixes bug #18837 - when the spec is higher then 1.0, + * diff can become a negative color - Campbell */ f1= 1.0f-i; diff --git a/source/gameengine/Ketsji/KX_GameObject.cpp b/source/gameengine/Ketsji/KX_GameObject.cpp index d04174a32aa..ba8905973d5 100644 --- a/source/gameengine/Ketsji/KX_GameObject.cpp +++ b/source/gameengine/Ketsji/KX_GameObject.cpp @@ -2597,12 +2597,10 @@ KX_PYMETHODDEF_DOC(KX_GameObject, rayCastTo, } } MT_Point3 fromPoint = NodeGetWorldPosition(); + if (dist != 0.0f) - { - MT_Vector3 toDir = toPoint-fromPoint; - toDir.normalize(); - toPoint = fromPoint + (dist) * toDir; - } + toPoint = fromPoint + dist * (toPoint-fromPoint).safe_normalized(); + PHY_IPhysicsEnvironment* pe = KX_GetActiveScene()->GetPhysicsEnvironment(); KX_IPhysicsController *spc = GetPhysicsController(); KX_GameObject *parent = GetParent();