Moai SDK  2.0
MOAIPartition Class Reference

Inherits MOAILuaObject.

Inherited by MOAICollisionWorld [virtual].

Function List

clear
 
hullForPoint
 
hullForRay
 
hullList
 
hullListForPoint
 
hullListForRay
 
hullListForRect
 
reserveLevels
 
setLevel
 
setPlane
 

Detailed Description

Constants
MOAIPartition.PLANE_XY
MOAIPartition.PLANE_XZ
MOAIPartition.PLANE_YZ

Function Documentation

clear

Remove all props from the partition.


function clear ( MOAIPartition self )

Parameters
MOAIPartitionself
Returns
nil
hullForPoint

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


function hullForPoint ( MOAIPartition self, number x, number y, number z [, number sortMode, number xScale, number yScale, number zScale, number priorityScale, number interfaceMask, number queryMask ] )

Parameters
MOAIPartitionself
numberx
numbery
numberz
numbersortMode Optional. One of the MOAIPartitionViewLayer sort modes. Default value is SORT_PRIORITY_ASCENDING.
numberxScale Optional. X scale for vector sort. Default value is 0.
numberyScale Optional. Y scale for vector sort. Default value is 0.
numberzScale Optional. Z scale for vector sort. Default value is 0.
numberpriorityScale Optional. Priority scale for vector sort. Default value is 1.
numberinterfaceMask Optional.
numberqueryMask Optional.
Returns
MOAIPartitionHull hull
hullForRay

Returns the first hull that intersects the given ray.


function hullForRay ( MOAIPartition self, number x, number y, number z, number xdirection, number ydirection, number zdirection [, number interfaceMask, number queryMask ] )

Parameters
MOAIPartitionself
numberx
numbery
numberz
numberxdirection
numberydirection
numberzdirection
numberinterfaceMask Optional.
numberqueryMask Optional.
Returns
MOAIPartitionHull hull
hullList

Returns all props.


function hullList ( MOAIPartition self [, number sortMode, number xScale, number yScale, number zScale, number priorityScale, number interfaceMask, number queryMask ] )

Parameters
MOAIPartitionself
numbersortMode Optional. One of the MOAIPartitionViewLayer sort modes. Default value is SORT_NONE.
numberxScale Optional. X scale for vector sort. Default value is 0.
numberyScale Optional. Y scale for vector sort. Default value is 0.
numberzScale Optional. Z scale for vector sort. Default value is 0.
numberpriorityScale Optional. Priority scale for vector sort. Default value is 1.
numberinterfaceMask Optional.
numberqueryMask Optional.
Returns
...
hullListForPoint

Returns all props under a given world space point.


function hullListForPoint ( MOAIPartition self, number x, number y, number z [, number sortMode, number xScale, number yScale, number zScale, number priorityScale, number interfaceMask, number queryMask ] )

Parameters
MOAIPartitionself
numberx
numbery
numberz
numbersortMode Optional. One of the MOAIPartitionViewLayer sort modes. Default value is SORT_NONE.
numberxScale Optional. X scale for vector sort. Default value is 0.
numberyScale Optional. Y scale for vector sort. Default value is 0.
numberzScale Optional. Z scale for vector sort. Default value is 0.
numberpriorityScale Optional. Priority scale for vector sort. Default value is 1.
numberinterfaceMask Optional.
numberqueryMask Optional.
Returns
...
hullListForRay

Returns all props that intersect the given ray.


function hullListForRay ( MOAIPartition self, number x, number y, number z, number xdirection, number ydirection, number zdirection [, number sortMode, number xScale, number yScale, number zScale, number priorityScale, number interfaceMask, number queryMask ] )

Parameters
MOAIPartitionself
numberx
numbery
numberz
numberxdirection
numberydirection
numberzdirection
numbersortMode Optional. One of the MOAIPartitionViewLayer sort modes. Default value is SORT_KEY_ASCENDING.
numberxScale Optional. X scale for vector sort. Default value is 0.
numberyScale Optional. Y scale for vector sort. Default value is 0.
numberzScale Optional. Z scale for vector sort. Default value is 0.
numberpriorityScale Optional. Priority scale for vector sort. Default value is 1.
numberinterfaceMask Optional.
numberqueryMask Optional.
Returns
...
hullListForRect

Returns all props under a given world space rect.


function hullListForRect ( MOAIPartition self, number xMin, number yMin, number xMax, number yMax [, number sortMode, number xScale, number yScale, number zScale, number priorityScale, number interfaceMask, number queryMask ] )

Parameters
MOAIPartitionself
numberxMin
numberyMin
numberxMax
numberyMax
numbersortMode Optional. One of the MOAIPartitionViewLayer sort modes. Default value is SORT_NONE.
numberxScale Optional. X scale for vector sort. Default value is 0.
numberyScale Optional. Y scale for vector sort. Default value is 0.
numberzScale Optional. Z scale for vector sort. Default value is 0.
numberpriorityScale Optional. Priority scale for vector sort. Default value is 1.
numberinterfaceMask Optional.
numberqueryMask Optional.
Returns
...
reserveLevels

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


function insertHull ( MOAIPartition self, MOAIPartitionHull hull )

Parameters
MOAIPartitionself
MOAIPartitionHullhull
Returns
nilRemoves a hull from the partition.

function removeHull ( MOAIPartition self, MOAIPartitionHull hull )

Parameters
MOAIPartitionself
MOAIPartitionHullhull
Returns
nilReserves 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
MOAIPartitionself
numbernLevels
Returns
nil
setLevel

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
MOAIPartitionself
numberlevelID
numbercellSize Dimensions of the level's cells.
numberxCells Width of level in cells.
numberyCells Height of level in cells.
Returns
nil
setPlane

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
MOAIPartitionself
numberplaneID One of MOAIPartition::PLANE_XY, MOAIPartition::PLANE_XZ, MOAIPartition::PLANE_YZ. Default value is MOAIPartition::PLANE_XY.
Returns
nil