From 26ea36a23b6dd36a2ab7d8574844fde6e8599ec5 Mon Sep 17 00:00:00 2001 From: Josh Wilson Date: Fri, 13 Jun 2008 23:58:42 +0000 Subject: [PATCH] expanding the gridSphere to account for the offset of the zoneLOD sphere from the center of the grid --- direct/src/distributed/CartesianGridBase.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/direct/src/distributed/CartesianGridBase.py b/direct/src/distributed/CartesianGridBase.py index 3cb977b6be..8fc2d9dcce 100755 --- a/direct/src/distributed/CartesianGridBase.py +++ b/direct/src/distributed/CartesianGridBase.py @@ -1,4 +1,4 @@ - +from pandac.PandaModules import Vec3 # Utility functions that are useful to both AI and client CartesianGrid code class CartesianGridBase: @@ -42,6 +42,18 @@ class CartesianGridBase: sphereRadius = max(sphereRadius, gridRadius*cellWidth) return 2 * (sphereRadius // cellWidth) + def getGridSizeFromSphere(self, sphereRadius, spherePos, cellWidth, gridRadius): + # NOTE: This ensures that the grid is at least a "gridRadius" number + # of cells larger than the trigger sphere that loads the grid. This + # gives us some room to start setting interest to the grid before we + # expect to see any objects on it. + xMax = abs(spherePos[0])+sphereRadius + yMax = abs(spherePos[1])+sphereRadius + sphereRadius = Vec3(xMax,yMax,0).length() + + # sphereRadius = max(sphereRadius, gridRadius*cellWidth) + return 2 * (sphereRadius // cellWidth) + def getZoneCellOrigin(self, zoneId): # It returns the origin of the zoneCell # Origin is the top-left corner of zoneCell