[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [58894] trunk/blender/source/gameengine/ Ketsji/KX_ObstacleSimulation.cpp: fix read outside buffer range KX_ObstacleSimulationTOI_rays::sampleRVO,
Campbell Barton
ideasman42 at gmail.com
Sun Aug 4 06:07:29 CEST 2013
Revision: 58894
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58894
Author: campbellbarton
Date: 2013-08-04 04:07:29 +0000 (Sun, 04 Aug 2013)
Log Message:
-----------
fix read outside buffer range KX_ObstacleSimulationTOI_rays::sampleRVO,
Was using 3d vectors for 2d operations, passing float[2] to args that use MT_Vector3 was reading the 3rd value of a 2d array
Modified Paths:
--------------
trunk/blender/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp
Modified: trunk/blender/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp
===================================================================
--- trunk/blender/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp 2013-08-04 03:51:24 UTC (rev 58893)
+++ trunk/blender/source/gameengine/Ketsji/KX_ObstacleSimulation.cpp 2013-08-04 04:07:29 UTC (rev 58894)
@@ -42,9 +42,13 @@
inline void vset(float v[2], float x, float y) { v[0] = x; v[1] = y; }
}
-static int sweepCircleCircle(const MT_Vector3& pos0, const MT_Scalar r0, const MT_Vector2& v,
- const MT_Vector3& pos1, const MT_Scalar r1,
- float& tmin, float& tmax)
+/* grr, seems moto provides no nice way to do this */
+#define MT_3D_AS_2D(v) MT_Vector2((v)[0], (v)[1])
+
+static int sweepCircleCircle(
+ const MT_Vector2 &pos0, const MT_Scalar r0, const MT_Vector2 &v,
+ const MT_Vector2 &pos1, const MT_Scalar r1,
+ float& tmin, float& tmax)
{
static const float EPS = 0.0001f;
MT_Vector2 c0(pos0.x(), pos0.y());
@@ -64,9 +68,10 @@
return 1;
}
-static int sweepCircleSegment(const MT_Vector3& pos0, const MT_Scalar r0, const MT_Vector2& v,
- const MT_Vector3& pa, const MT_Vector3& pb, const MT_Scalar sr,
- float& tmin, float &tmax)
+static int sweepCircleSegment(
+ const MT_Vector2 &pos0, const MT_Scalar r0, const MT_Vector2 &v,
+ const MT_Vector2& pa, const MT_Vector2 &pb, const MT_Scalar sr,
+ float& tmin, float &tmax)
{
// equation parameters
MT_Vector2 c0(pos0.x(), pos0.y());
@@ -484,9 +489,11 @@
vab = 2*svel - vel - ob->vel;
}
- if (!sweepCircleCircle(activeObst->m_pos, activeObst->m_rad,
- vab, ob->m_pos, ob->m_rad, htmin, htmax))
+ if (!sweepCircleCircle(MT_3D_AS_2D(activeObst->m_pos), activeObst->m_rad,
+ vab, MT_3D_AS_2D(ob->m_pos), ob->m_rad, htmin, htmax))
+ {
continue;
+ }
}
else if (ob->m_shape == KX_OBSTACLE_SEGMENT)
{
@@ -499,9 +506,12 @@
p1 = navmeshobj->TransformToWorldCoords(p1);
p2 = navmeshobj->TransformToWorldCoords(p2);
}
- if (!sweepCircleSegment(activeObst->m_pos, activeObst->m_rad, svel,
- p1, p2, ob->m_rad, htmin, htmax))
+
+ if (!sweepCircleSegment(MT_3D_AS_2D(activeObst->m_pos), activeObst->m_rad, svel,
+ MT_3D_AS_2D(p1), MT_3D_AS_2D(p2), ob->m_rad, htmin, htmax))
+ {
continue;
+ }
}
else {
continue;
@@ -644,9 +654,11 @@
dot_v2v2(np, vab)) * 2.0f, 0.0f, 1.0f);
nside++;
- if (!sweepCircleCircle(activeObst->m_pos, activeObst->m_rad, vab, ob->m_pos, ob->m_rad,
- htmin, htmax))
+ if (!sweepCircleCircle(MT_3D_AS_2D(activeObst->m_pos), activeObst->m_rad,
+ vab, MT_3D_AS_2D(ob->m_pos), ob->m_rad, htmin, htmax))
+ {
continue;
+ }
// Handle overlapping obstacles.
if (htmin < 0.0f && htmax > 0.0f)
More information about the Bf-blender-cvs
mailing list