mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
expanding the gridSphere to account for the offset of the zoneLOD sphere from the center of the grid
This commit is contained in:
parent
d789e292ae
commit
26ea36a23b
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user