From 5c84c3e9e50bc331d911fde8dcd5ad8ecd99886a Mon Sep 17 00:00:00 2001 From: Itms Date: Wed, 15 Apr 2015 12:19:47 +0000 Subject: [PATCH] Some entities (like birds) can have negative positions without being marked as out-of-world. Refs #2430 This was SVN commit r16544. --- source/simulation2/helpers/Spatial.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/simulation2/helpers/Spatial.h b/source/simulation2/helpers/Spatial.h index 09ef222603..2e674293fd 100644 --- a/source/simulation2/helpers/Spatial.h +++ b/source/simulation2/helpers/Spatial.h @@ -374,7 +374,7 @@ private: inline size_t Index(fixed position) { - return (position / SUBDIVISION_SIZE).ToInt_RoundToZero(); + return Clamp((position / SUBDIVISION_SIZE).ToInt_RoundToZero(), 0, (int)m_ArrayWidth-1); } inline size_t SubdivisionIdx(CFixedVector2D position)