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