diff --git a/direct/src/distributed/CartesianGridBase.py b/direct/src/distributed/CartesianGridBase.py index ead277aad3..0567d24c0d 100755 --- a/direct/src/distributed/CartesianGridBase.py +++ b/direct/src/distributed/CartesianGridBase.py @@ -40,6 +40,8 @@ class CartesianGridBase: return 2 * (sphereRadius // cellWidth) def getZoneCellOrigin(self, zoneId): + # It returns the origin of the zoneCell + # Origin is the top-left corner of zoneCell dx = self.cellWidth * self.gridSize * .5 zone = zoneId - self.startingZone row = zone // self.gridSize @@ -49,3 +51,16 @@ class CartesianGridBase: return (x,y,0) + def getZoneCellOriginCenter(self, zoneId): + # Variant of the getZoneCellOrigin. It + # returns the center of the zoneCell + dx = self.cellWidth * self.gridSize * .5 + center = self.cellWidth * 0.5 + zone = zoneId - self.startingZone + row = zone // self.gridSize + col = zone % self.gridSize + x = col * self.cellWidth - dx + center + y = row * self.cellWidth - dx + center + + return (x,y,0) +