# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

NL3D::CShapeBank Class Reference

A CShapeBank handle all the instance of the shapes and the cache management system. More...

#include <shape_bank.h>

List of all members.

Shape/Instances.

typedef NLMISC::CSmartPtr<
IShape
PShape
typedef std::map< std::string,
PShape
TShapeMap
typedef std::map< std::string,
CWaitingShape
TWaitingShapesMap
bool processWSUploadTexture (CWaitingShape &rWS, uint32 &nTotalUploaded, ITexture *pText)
 return true if the texture is entirely uploaded. More...

TShapeMap ShapeMap
TWaitingShapesMap WaitingShapes
uint32 _MaxUploadPerFrame
IDriver_pDriver

Shape/Caches.

typedef std::map< std::string,
std::string > 
TShapeCacheNameMap
typedef std::map< std::string,
CShapeCache
TShapeCacheMap
typedef std::map< IShape *,
CShapeInfo
TShapeInfoMap
std::string * getShapeNameFromShapePtr (IShape *pShp)
IShapegetShapePtrFromShapeName (const std::string &pShpName)
CShapeCachegetShapeCachePtrFromShapePtr (IShape *pShp)
CShapeCachegetShapeCachePtrFromShapeCacheName (const std::string &shapeCacheName)
CShapeCachegetShapeCachePtrFromShapeName (const std::string &shapeName)
void checkShapeCache (CShapeCache *pShpCache)
TShapeCacheNameMap ShapeNameToShapeCacheName
TShapeCacheMap ShapeCacheNameToShapeCache
TShapeInfoMap ShapePtrToShapeInfo

Public Types

State of a shape
enum  TShapeState {
  NotPresent, Present, AsyncLoad_Error, AsyncLoad_Shape,
  AsyncLoad_Texture, AsyncLoad_Ready, AsyncLoad_Delete
}
 NotPresent : Not present in the bank Present : Present in the bank and ready to be used AsyncLoad_Error : Asynchronous loading failed AsyncLoad_Shape : Asynchronous loading is currently loading the .shape file, textures and lightmaps AsyncLoad_Texture : Asynchronous loading is currently uploading textures and lightmaps to VRAM. More...


Public Methods

 CShapeBank ()
 ~CShapeBank ()
Instance Management
IShapeaddRef (const std::string &shapeName)
 Add a reference to a shape and return the instance created. More...

void release (IShape *pShp)
 Release a reference to a shape by its instance. More...

TShapeState isPresent (const std::string &shapeName)
 Return TRUE if the shape is present in the bank. Process the waiting shapes. More...

void load (const std::string &shapeName)
 Load the corresponding file from disk and add it to the bank. More...

void loadAsync (const std::string &shapeName, IDriver *pDriver, bool *bSignal=NULL)
 Load the corresponding file from disk asynchronously and add it to the bank. More...

void cancelLoadAsync (const std::string &shapeName)
bool isShapeWaiting ()
void processWaitingShapes ()
 processWaitingShapes must be done one time per frame. More...

void setMaxBytesToUpload (uint32 MaxUploadPerFrame)
 Setup the maximum number of bytes to upload for a frame (texture upload from RAM to VRAM). More...

void add (const std::string &shapeName, IShape *shape)
 Add directly a shape to the bank. If the shape name is already used do nothing. More...

Shape cache management
void addShapeCache (const std::string &shapeCacheName)
 Add a new ShapeCache. If already exist do nothing. More...

void removeShapeCache (const std::string &shapeCacheName)
 Remove a ShapeCache. More...

bool isShapeCache (const std::string &shapeCacheName) const
 true if the shape cache exist. More...

void reset ()
 Remove all ShapeCache and suppress all links (even the link to the default cache are removed). More...

void setShapeCacheSize (const std::string &shapeCacheName, sint32 maxSize)
 Set the shapeCache shapeCacheName the new size.(delete shapes if maxsize<shapeCacheSize). More...

sint getShapeCacheFreeSpace (const std::string &shapeCacheName) const
 return free cache space (maxSize-nbCurrentInCache). More...

void linkShapeToShapeCache (const std::string &shapeName, const std::string &shapeCacheName)
 Link a shape to a ShapeCache. The ShapeCache must exist and must not contains the shape. More...

Tools
void preLoadShapes (const std::string &shapeCacheName, const std::vector< std::string > &listFile, const std::string &wildCardNotLwr)
 PreLoad all shapes (.shape, .ps, .skel...) files from a list of files Shapes are Loaded if not present, assigned to the given cache, and fit in the cache Size as max possible. More...


Detailed Description

A CShapeBank handle all the instance of the shapes and the cache management system.

There is a default cache. If the shape is not linked explicitly to any cache it is linked to the default cache. The comportement of this cache is to not do any cache. When the release is called on the last reference to a shape linked to this cache, the shape is removed instantly. This is the behavior of all newly created cache before we call the setShapeCacheSize method.

NB: ShapeCacheName is case-sensitive but shapeName are not (all entry are lwrcased)

Author:
Matthieu Besson , Nevrax France
Date:
2000

Definition at line 58 of file shape_bank.h.


Member Typedef Documentation

typedef NLMISC::CSmartPtr<IShape> NL3D::CShapeBank::PShape [private]
 

Definition at line 155 of file shape_bank.h.

typedef std::map<std::string,CShapeCache> NL3D::CShapeBank::TShapeCacheMap [private]
 

Definition at line 221 of file shape_bank.h.

typedef std::map<std::string,std::string> NL3D::CShapeBank::TShapeCacheNameMap [private]
 

Definition at line 220 of file shape_bank.h.

typedef std::map<IShape*,CShapeInfo> NL3D::CShapeBank::TShapeInfoMap [private]
 

Definition at line 222 of file shape_bank.h.

typedef std::map<std::string, PShape> NL3D::CShapeBank::TShapeMap [private]
 

Definition at line 156 of file shape_bank.h.

typedef std::map< std::string, CWaitingShape > NL3D::CShapeBank::TWaitingShapesMap [private]
 

Definition at line 181 of file shape_bank.h.


Member Enumeration Documentation

enum NL3D::CShapeBank::TShapeState
 

NotPresent : Not present in the bank Present : Present in the bank and ready to be used AsyncLoad_Error : Asynchronous loading failed AsyncLoad_Shape : Asynchronous loading is currently loading the .shape file, textures and lightmaps AsyncLoad_Texture : Asynchronous loading is currently uploading textures and lightmaps to VRAM.

Enumeration values:
NotPresent 
Present 
AsyncLoad_Error 
AsyncLoad_Shape 
AsyncLoad_Texture 
AsyncLoad_Ready 
AsyncLoad_Delete 

Definition at line 70 of file shape_bank.h.


Constructor & Destructor Documentation

NL3D::CShapeBank::CShapeBank  
 

Definition at line 43 of file shape_bank.cpp.

References _MaxUploadPerFrame, and addShapeCache.

NL3D::CShapeBank::~CShapeBank  
 

Definition at line 52 of file shape_bank.cpp.


Member Function Documentation

void NL3D::CShapeBank::add const std::string &    shapeName,
IShape   shape
 

Add directly a shape to the bank. If the shape name is already used do nothing.

Referenced by processWaitingShapes.

IShape* NL3D::CShapeBank::addRef const std::string &    shapeName
 

Add a reference to a shape and return the instance created.

Referenced by preLoadShapes.

void NL3D::CShapeBank::addShapeCache const std::string &    shapeCacheName
 

Add a new ShapeCache. If already exist do nothing.

Referenced by CShapeBank, and reset.

void NL3D::CShapeBank::cancelLoadAsync const std::string &    shapeName
 

Definition at line 451 of file shape_bank.cpp.

References WaitingShapes.

void NL3D::CShapeBank::checkShapeCache CShapeCache   pShpCache [private]
 

Definition at line 701 of file shape_bank.cpp.

References getShapeNameFromShapePtr, ShapeMap, and ShapePtrToShapeInfo.

Referenced by release, removeShapeCache, and reset.

sint NL3D::CShapeBank::getShapeCacheFreeSpace const std::string &    shapeCacheName const
 

return free cache space (maxSize-nbCurrentInCache).

Definition at line 587 of file shape_bank.cpp.

References ShapeCacheNameToShapeCache.

Referenced by preLoadShapes.

CShapeCache* NL3D::CShapeBank::getShapeCachePtrFromShapeCacheName const std::string &    shapeCacheName [private]
 

Referenced by getShapeCachePtrFromShapeName, removeShapeCache, and reset.

CShapeBank::CShapeCache * NL3D::CShapeBank::getShapeCachePtrFromShapeName const std::string &    shapeName [private]
 

Definition at line 689 of file shape_bank.cpp.

References getShapeCachePtrFromShapeCacheName, and ShapeNameToShapeCacheName.

CShapeBank::CShapeCache * NL3D::CShapeBank::getShapeCachePtrFromShapePtr IShape   pShp [private]
 

Definition at line 641 of file shape_bank.cpp.

References ShapePtrToShapeInfo.

Referenced by release.

string * NL3D::CShapeBank::getShapeNameFromShapePtr IShape   pShp [private]
 

Definition at line 677 of file shape_bank.cpp.

References ShapePtrToShapeInfo.

Referenced by checkShapeCache, and release.

IShape * NL3D::CShapeBank::getShapePtrFromShapeName const std::string &    pShpName [private]
 

Definition at line 653 of file shape_bank.cpp.

References ShapeMap.

TShapeState NL3D::CShapeBank::isPresent const std::string &    shapeName
 

Return TRUE if the shape is present in the bank. Process the waiting shapes.

Referenced by preLoadShapes.

bool NL3D::CShapeBank::isShapeCache const std::string &    shapeCacheName const
 

true if the shape cache exist.

Definition at line 719 of file shape_bank.cpp.

References ShapeCacheNameToShapeCache.

Referenced by preLoadShapes.

bool NL3D::CShapeBank::isShapeWaiting  
 

Definition at line 471 of file shape_bank.cpp.

References WaitingShapes.

void NL3D::CShapeBank::linkShapeToShapeCache const std::string &    shapeName,
const std::string &    shapeCacheName
 

Link a shape to a ShapeCache. The ShapeCache must exist and must not contains the shape.

Referenced by preLoadShapes.

void NL3D::CShapeBank::load const std::string &    shapeName
 

Load the corresponding file from disk and add it to the bank.

Referenced by preLoadShapes.

void NL3D::CShapeBank::loadAsync const std::string &    shapeName,
IDriver   pDriver,
bool *    bSignal = NULL
 

Load the corresponding file from disk asynchronously and add it to the bank.

The driver passed to this function is used to know if we have to load the textures.

Definition at line 429 of file shape_bank.cpp.

References _pDriver, ShapeMap, and WaitingShapes.

void NL3D::CShapeBank::preLoadShapes const std::string &    shapeCacheName,
const std::vector< std::string > &    listFile,
const std::string &    wildCardNotLwr
 

PreLoad all shapes (.shape, .ps, .skel...) files from a list of files Shapes are Loaded if not present, assigned to the given cache, and fit in the cache Size as max possible.

NB: crash if you try to load a non shape file (eg: a .dds etc...)

Parameters:
shapeCacheName  name of a shapeCache created with addShapeCache()/setShapeCacheSize(). no-op if don't exist
fileList  a list of file names. NB: CPath is used to load the shapes.
wildcard  a filter string like: "*.shape", "??_HOM*.shape". NB: strlwr-ed internally

Definition at line 725 of file shape_bank.cpp.

References addRef, getShapeCacheFreeSpace, isPresent, isShapeCache, linkShapeToShapeCache, load, release, and NLMISC::testWildCard.

void NL3D::CShapeBank::processWaitingShapes  
 

processWaitingShapes must be done one time per frame.

Definition at line 133 of file shape_bank.cpp.

References _MaxUploadPerFrame, _pDriver, add, AsyncLoad_Delete, AsyncLoad_Error, AsyncLoad_Ready, AsyncLoad_Shape, AsyncLoad_Texture, NL3D::IDRV_MAT_MAXTEXTURES, nlstop, processWSUploadTexture, and WaitingShapes.

bool NL3D::CShapeBank::processWSUploadTexture CWaitingShape   rWS,
uint32   nTotalUploaded,
ITexture   pText
[private]
 

return true if the texture is entirely uploaded.

Definition at line 290 of file shape_bank.cpp.

References _MaxUploadPerFrame, and _pDriver.

Referenced by processWaitingShapes.

void NL3D::CShapeBank::release IShape   pShp
 

Release a reference to a shape by its instance.

If the shape has no more reference it is added to its own shape cache. When the shape cache is full the last entry is deleted.

Definition at line 94 of file shape_bank.cpp.

References checkShapeCache, getShapeCachePtrFromShapePtr, getShapeNameFromShapePtr, nlassert, nlwarning, ShapeMap, and ShapePtrToShapeInfo.

Referenced by preLoadShapes.

void NL3D::CShapeBank::removeShapeCache const std::string &    shapeCacheName
 

Remove a ShapeCache.

All shapes in the shape cache are deleted. All links are redirected to the default ShapeCache

Definition at line 528 of file shape_bank.cpp.

References checkShapeCache, getShapeCachePtrFromShapeCacheName, ShapeCacheNameToShapeCache, and ShapeNameToShapeCacheName.

void NL3D::CShapeBank::reset  
 

Remove all ShapeCache and suppress all links (even the link to the default cache are removed).

Definition at line 555 of file shape_bank.cpp.

References addShapeCache, checkShapeCache, getShapeCachePtrFromShapeCacheName, nlstop, ShapeCacheNameToShapeCache, and ShapeNameToShapeCacheName.

void NL3D::CShapeBank::setMaxBytesToUpload uint32    MaxUploadPerFrame
 

Setup the maximum number of bytes to upload for a frame (texture upload from RAM to VRAM).

Definition at line 284 of file shape_bank.cpp.

References _MaxUploadPerFrame.

void NL3D::CShapeBank::setShapeCacheSize const std::string &    shapeCacheName,
sint32    maxSize
 

Set the shapeCache shapeCacheName the new size.(delete shapes if maxsize<shapeCacheSize).


Member Data Documentation

uint32 NL3D::CShapeBank::_MaxUploadPerFrame [private]
 

Definition at line 183 of file shape_bank.h.

Referenced by CShapeBank, processWaitingShapes, processWSUploadTexture, and setMaxBytesToUpload.

IDriver* NL3D::CShapeBank::_pDriver [private]
 

Definition at line 192 of file shape_bank.h.

Referenced by loadAsync, processWaitingShapes, and processWSUploadTexture.

TShapeCacheMap NL3D::CShapeBank::ShapeCacheNameToShapeCache [private]
 

Definition at line 224 of file shape_bank.h.

Referenced by getShapeCacheFreeSpace, isShapeCache, removeShapeCache, and reset.

TShapeMap NL3D::CShapeBank::ShapeMap [private]
 

Definition at line 157 of file shape_bank.h.

Referenced by checkShapeCache, getShapePtrFromShapeName, loadAsync, and release.

TShapeCacheNameMap NL3D::CShapeBank::ShapeNameToShapeCacheName [private]
 

Definition at line 223 of file shape_bank.h.

Referenced by getShapeCachePtrFromShapeName, removeShapeCache, and reset.

TShapeInfoMap NL3D::CShapeBank::ShapePtrToShapeInfo [private]
 

Definition at line 225 of file shape_bank.h.

Referenced by checkShapeCache, getShapeCachePtrFromShapePtr, getShapeNameFromShapePtr, and release.

TWaitingShapesMap NL3D::CShapeBank::WaitingShapes [private]
 

Definition at line 182 of file shape_bank.h.

Referenced by cancelLoadAsync, isShapeWaiting, loadAsync, and processWaitingShapes.


The documentation for this class was generated from the following files: