Moai SDK  1.5 revision 1 (MoaiEdition)
MOAIPartition Class Reference

Inherits MOAILuaObject.

List of all members.

Function List

  clear
  insertProp
  propForPoint
  propForRay
  propListForPoint
  propListForRay
  propListForRect
  removeProp
  reserveLevels
  setLevel
  setPlane

Function Documentation

Remove all props from the partition.


function clear ( MOAIPartition self )
Parameters:
self ( MOAIPartition )
Returns:
nil

Inserts a prop into the partition. A prop can only be in one partition at a time.


function insertProp ( MOAIPartition self, MOAIProp prop )
Parameters:
self ( MOAIPartition )
prop ( MOAIProp )
Returns:
nil

Returns the prop with the highest priority that contains the given world space point.


function propForPoint ( MOAIPartition self, number x, number y, number z [, number sortMode, number xScale, number yScale, number zScale, number priorityScale ] )
Parameters:
self ( MOAIPartition )
x ( number )
y ( number )
z ( number )
sortMode ( number ) Optional. One of the MOAILayer sort modes. Default value is SORT_PRIORITY_ASCENDING.
xScale ( number ) Optional. X scale for vector sort. Default value is 0.
yScale ( number ) Optional. Y scale for vector sort. Default value is 0.
zScale ( number ) Optional. Z scale for vector sort. Default value is 0.
priorityScale ( number ) Optional. Priority scale for vector sort. Default value is 1.
Returns:
prop ( MOAIProp )

Returns the prop closest to the camera that intersects the given ray.


function propForRay ( MOAIPartition self, number x, number y, number z, number xdirection, number ydirection, number zdirection )
Parameters:
self ( MOAIPartition )
x ( number )
y ( number )
z ( number )
xdirection ( number )
ydirection ( number )
zdirection ( number )
Returns:
prop ( MOAIProp )

Returns all props under a given world space point.


function propListForPoint ( MOAIPartition self, number x, number y, number z [, number sortMode, number xScale, number yScale, number zScale, number priorityScale ] )
Parameters:
self ( MOAIPartition )
x ( number )
y ( number )
z ( number )
sortMode ( number ) Optional. One of the MOAILayer sort modes. Default value is SORT_NONE.
xScale ( number ) Optional. X scale for vector sort. Default value is 0.
yScale ( number ) Optional. Y scale for vector sort. Default value is 0.
zScale ( number ) Optional. Z scale for vector sort. Default value is 0.
priorityScale ( number ) Optional. Priority scale for vector sort. Default value is 1.
Returns:
...

Returns all props under a given world space point.


function propListForRay ( MOAIPartition self, number x, number y, number z, number xdirection, number ydirection, number zdirection [, number sortMode, number xScale, number yScale, number zScale, number priorityScale ] )
Parameters:
self ( MOAIPartition )
x ( number )
y ( number )
z ( number )
xdirection ( number )
ydirection ( number )
zdirection ( number )
sortMode ( number ) Optional. One of the MOAILayer sort modes. Default value is SORT_KEY_ASCENDING.
xScale ( number ) Optional. X scale for vector sort. Default value is 0.
yScale ( number ) Optional. Y scale for vector sort. Default value is 0.
zScale ( number ) Optional. Z scale for vector sort. Default value is 0.
priorityScale ( number ) Optional. Priority scale for vector sort. Default value is 1.
Returns:
...

Returns all props under a given world space rect.


function propListForRect ( MOAIPartition self, number xMin, number yMin, number xMax, number yMax [, number sortMode, number xScale, number yScale, number zScale, number priorityScale ] )
Parameters:
self ( MOAIPartition )
xMin ( number )
yMin ( number )
xMax ( number )
yMax ( number )
sortMode ( number ) Optional. One of the MOAILayer sort modes. Default value is SORT_NONE.
xScale ( number ) Optional. X scale for vector sort. Default value is 0.
yScale ( number ) Optional. Y scale for vector sort. Default value is 0.
zScale ( number ) Optional. Z scale for vector sort. Default value is 0.
priorityScale ( number ) Optional. Priority scale for vector sort. Default value is 1.
Returns:
...

Removes a prop from the partition.


function removeProp ( MOAIPartition self, MOAIProp prop )
Parameters:
self ( MOAIPartition )
prop ( MOAIProp )
Returns:
nil

Reserves a stack of levels in the partition. Levels must be initialized with setLevel (). This will trigger a full rebuild of the partition if it contains any props.


function reserveLevels ( MOAIPartition self, number nLevels )
Parameters:
self ( MOAIPartition )
nLevels ( number )
Returns:
nil

Initializes a level previously created by reserveLevels (). This will trigger a full rebuild of the partition if it contains any props. Each level is a loose grid. Props of a given size may be placed by the system into any level with cells large enough to accommodate them. The dimensions of a level control how many cells the level contains. If an object goes off of the edge of a level, it will wrap around to the other side. It is possible to model a quad tree by initializing levels correctly, but for some simulations better structures may be possible.


function setLevel ( MOAIPartition self, number levelID, number cellSize, number xCells, number yCells )
Parameters:
self ( MOAIPartition )
levelID ( number )
cellSize ( number ) Dimensions of the layer's cells.
xCells ( number ) Width of layer in cells.
yCells ( number ) Height of layer in cells.
Returns:
nil

Selects the plane the partition will use. If this is different from the current plane then all non-global props will be redistributed. Redistribution works by moving all props to the 'empties' cell and then scheduling them all for a dep node update (which refreshes the prop's bounds and may also flag it as global).


function setPlane ( MOAIPartition self, number planeID )
Parameters:
self ( MOAIPartition )
planeID ( number ) One of MOAIPartition::PLANE_XY, MOAIPartition::PLANE_XZ, MOAIPartition::PLANE_YZ. Default value is MOAIPartition::PLANE_XY.
Returns:
nil