mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
center function for cartesian grid
This commit is contained in:
parent
7b1d16480f
commit
36aba2fd7e
@ -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)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user