Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKester Maddock <Christopher.Maddock.1@uni.massey.ac.nz>2004-04-09 07:48:17 +0400
committerKester Maddock <Christopher.Maddock.1@uni.massey.ac.nz>2004-04-09 07:48:17 +0400
commit0e9e6bdc7242b4cfd5016f9ad99227784bb41d2f (patch)
tree40d5be719e50217b95e0b570ba60f2f7d619eb93 /source/gameengine/Ketsji/KX_RaySensor.cpp
parent10eebdbd786b02459565e97a0e3a42276690d1b5 (diff)
Fix bug #1126: Ray sensor detects a near sensor attached to the same object and then goes into an endless loop trying to ignore it.
Diffstat (limited to 'source/gameengine/Ketsji/KX_RaySensor.cpp')
-rw-r--r--source/gameengine/Ketsji/KX_RaySensor.cpp17
1 files changed, 15 insertions, 2 deletions
diff --git a/source/gameengine/Ketsji/KX_RaySensor.cpp b/source/gameengine/Ketsji/KX_RaySensor.cpp
index c53651712a8..3db65783661 100644
--- a/source/gameengine/Ketsji/KX_RaySensor.cpp
+++ b/source/gameengine/Ketsji/KX_RaySensor.cpp
@@ -207,9 +207,22 @@ bool KX_RaySensor::Evaluate(CValue* event)
KX_SumoPhysicsController *hitspc = dynamic_cast<KX_SumoPhysicsController *> (static_cast<KX_GameObject*> (hitgameobj) ->GetPhysicsController());
if (hitspc)
{
- MT_Scalar marg = hitspc->GetSumoObject()->getMargin();
+ /* We add 0.01 of fudge, so that if the margin && radius == 0., we don't endless loop. */
+ MT_Scalar marg = 0.01 + hitspc->GetSumoObject()->getMargin();
if (hitspc->GetSumoObject()->getShapeProps())
- marg += hitspc->GetSumoObject()->getShapeProps()->m_radius;
+ {
+ marg += 2*hitspc->GetSumoObject()->getShapeProps()->m_radius;
+ }
+
+ /* Calculate the other side of this object */
+ MT_Point3 hitObjPos;
+ hitspc->GetWorldPosition(hitObjPos);
+ MT_Vector3 hitvector = hitObjPos - resultpoint;
+ if (hitvector.dot(hitvector) > MT_EPSILON)
+ {
+ hitvector.normalize();
+ marg *= 2.*todir.dot(hitvector);
+ }
frompoint = resultpoint + marg * todir;
} else {
ready = true;