expanding the gridSphere to account for the offset of the zoneLOD sphere from the center of the grid

This commit is contained in:
Josh Wilson 2008-06-13 23:58:42 +00:00
parent d789e292ae
commit 26ea36a23b

View File

@ -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