ForestData
Engine/source/forest/forestDataFile.h
This is the data file for Forests.
Protected Static Attributes
Set the bucket dimensions to 2km x 2km.
The next free item id.
Protected Attributes
The top level cell buckets which allows us to have virtually unbounded range.
bool
Set to true if the file is dirty and needs to be saved before being destroyed.
Protected Static Functions
_getBucketKey(const Point3F & pos)
Converts a ForestItem's Point3F 'KeyPosition' to a Point2I key we index into BucketTable with.
Protected Functions
_findBucket(const Point2I & key)
Finds the bucket with the given Point2I key or returns NULL.
_findBucket(const Point3F & pos)
Finds the best top level bucket for the ForestItem 'key' position or returns NULL.
_findOrCreateBucket(const Point3F & pos)
Find the best top level bucket for the given position or returns a new one.
Public Functions
addItem(ForestItemKey key, ForestItemData * data, const MatrixF & xfm, F32 scale)
buildPhysicsRep(Forest * forest)
clearPhysicsRep(Forest * forest)
findItem(ForestItemKey key)
Does an exhaustive search thru all cells looking for the item.
findItem(ForestItemKey key, const Point3F & keyPosition)
Performs a search using the position to limit tested cells.
getCells(const Frustum & frustum, Vector< ForestCell * > * outCells)
Returns all the top level cells which intersect the frustum.
getCells(Vector< ForestCell * > * outCells)
Returns all top level cells.
getDatablocks(Vector< ForestItemData * > * outVector)
Gathers all the datablocks used and returns the count.
getItems(const Box3F & box, Vector< ForestItem > * outItems)
Returns a copy of all the items that intersect the box.
getItems(const ForestItemData * data, Vector< ForestItem > * outItems)
Returns a copy of all the items that share the input item datablock.
getItems(Vector< ForestItem > * outItems)
Fills a vector with a copy of all the items in the data set.
bool
isDirty()
Helper for debugging cell generation.
bool
removeItem(ForestItemKey key, const Point3F & keyPosition)
updateItem(ForestItem & item)
updateItem(ForestItemKey key, const Point3F & keyPosition, ForestItemData * newData, const MatrixF & newXfm, F32 newscale)
Detailed Description
This is the data file for Forests.
Protected Types
@81
Enumerator
- FILE_VERSION = 1
typedef HashTable< Point2I, ForestCell * > BucketTable
Protected Static Attributes
const U32 BUCKET_DIM
Set the bucket dimensions to 2km x 2km.
U32 smNextItemId
The next free item id.
Protected Attributes
BucketTable mBuckets
The top level cell buckets which allows us to have virtually unbounded range.
bool mIsDirty
Set to true if the file is dirty and needs to be saved before being destroyed.
Protected Static Functions
_getBucketKey(const Point3F & pos)
Converts a ForestItem's Point3F 'KeyPosition' to a Point2I key we index into BucketTable with.
Protected Functions
_findBucket(const Point2I & key)
Finds the bucket with the given Point2I key or returns NULL.
_findBucket(const Point3F & pos)
Finds the best top level bucket for the ForestItem 'key' position or returns NULL.
_findOrCreateBucket(const Point3F & pos)
Find the best top level bucket for the given position or returns a new one.
_onItemReload()
Public Functions
ForestData()
~ForestData()
addItem(ForestItemData * data, const Point3F & position, F32 rotation, F32 scale)
addItem(ForestItemKey key, ForestItemData * data, const MatrixF & xfm, F32 scale)
buildPhysicsRep(Forest * forest)
castRay(const Point3F & start, const Point3F & end, RayInfo * outInfo, bool rendered)
clear()
Deletes all the data and resets the file to an empty state.
clearPhysicsRep(Forest * forest)
findItem(ForestItemKey key)
Does an exhaustive search thru all cells looking for the item.
This method is slow and should be avoided.
findItem(ForestItemKey key, const Point3F & keyPosition)
Performs a search using the position to limit tested cells.
getCells(const Frustum & frustum, Vector< ForestCell * > * outCells)
Returns all the top level cells which intersect the frustum.
getCells(Vector< ForestCell * > * outCells)
Returns all top level cells.
getDatablocks(Vector< ForestItemData * > * outVector)
Gathers all the datablocks used and returns the count.
getItems(const Box3F & box, Vector< ForestItem > * outItems)
Returns a copy of all the items that intersect the box.
If the output vector is NULL then it will early out on the first found item returning 1.
Parameters:
box | The search box. |
outItems | The output vector of items or NULL. |
The count of items found.
getItems(const ForestItemData * data, Vector< ForestItem > * outItems)
Returns a copy of all the items that share the input item datablock.
Parameters:
data | The datablock to search for. |
outItems | The output vector of items. |
The count of items found.
getItems(const Frustum & culler, Vector< ForestItem > * outItems)
Fills a vector with a copy of all items in the Frustum.
Note that this IS expensive and this is not how Forest internally collects items for rendering. This is here for ForestSelectionTool.
Parameters:
The | Frustum to cull with. |
outItems | The output vector of items. |
The count of items found.
getItems(const Point2F & point, F32 radius, Vector< ForestItem > * outItems)
Returns a copy of all the items that intersect the 2D circle ignoring the z component.
If the output vector is NULL then it will early out on the first found item returning 1.
Parameters:
point | The center point of the search circle. |
radius | The radius of the search circle. |
outItems | The output vector of items or NULL. |
The count of items found.
getItems(const Point3F & point, F32 radius, Vector< ForestItem > * outItems)
Returns a copy of all the items that intersect the sphere.
If the output vector is NULL then it will early out on the first found item returning 1.
Parameters:
point | The center of the search sphere. |
radius | The radius of the search sphere. |
outItems | The output vector of items or NULL. |
The count of items found.
getItems(Vector< ForestItem > * outItems)
Fills a vector with a copy of all the items in the data set.
Parameters:
outItems | The output vector of items. |
The count of items found.
isDirty()
read(Stream & stream)
regenCells()
Helper for debugging cell generation.
removeItem(ForestItemKey key, const Point3F & keyPosition)
updateItem(ForestItem & item)
updateItem(ForestItemKey key, const Point3F & keyPosition, ForestItemData * newData, const MatrixF & newXfm, F32 newscale)
write(const char * path)