A CTextureFar is a set of texture used to map a whole patch when it is in far Mode. More...
#include <texture_far.h>
Inherits NL3D::ITexture.
Classes | |
| struct | CPatchIdent |
| struct | CVector2s |
Public Member Functions | |
| CTextureFar () | |
| Constructor. | |
| virtual | ~CTextureFar () |
| sint | tryAllocatePatch (CPatch *pPatch, uint farIndex) |
| Try to allocate a patch. | |
| void | allocatePatch (CPatch *pPatch, uint farIndex, float &farUScale, float &farVScale, float &farUBias, float &farVBias, bool &bRot) |
| Allocate a patch in the CTextureFar, according to its size. | |
| void | removePatch (CPatch *pPatch, uint farIndex) |
| Remove a patch in the CTexture Far. | |
| virtual void | doGenerate (bool async=false) |
| Generate the texture. | |
| uint | touchPatchULAndNext () |
| Touch a patch (call touchRect()) and iterate to next . | |
| void | startPatchULTouch () |
| bool | endPatchULTouch () const |
| void | linkBeforeUL (CTextureFar *textNext) |
| For lighting update, insert this before textNext (CiruclarList). textNext must be !NULL. | |
| void | unlinkUL () |
| For lighting update, unlink (CiruclarList). | |
| CTextureFar * | getNextUL () const |
| For lighting update, get Next (CiruclarList). If ==this, then list is empty. | |
Public Attributes | |
| CTileFarBank * | _Bank |
| A pointer on the far bank. | |
Private Types | |
| typedef std::map< CPatchIdent, CVector2s > | TPatchToPosMap |
| Map of Patchs stored in this texture Far. | |
| typedef std::map< CVector2s, CPatchIdent > | TPosToPatchMap |
Private Member Functions | |
| bool | getUpperSize (uint &width, uint &height) |
| uint | getFreeListId (uint width, uint height) |
| void | recursSplitNext (uint width, uint height) |
| void | rebuildPatch (const CVector2s texturePos, const CPatchIdent &pid) |
| Rebuild the patch passed in parameter. | |
| virtual void | serial (NLMISC::IStream &) throw (NLMISC::EStream) |
| From IStreamable. | |
| NLMISC_DECLARE_CLASS (CTextureFar) | |
Private Attributes | |
| TPatchToPosMap | _PatchToPosMap |
| TPosToPatchMap | _PosToPatchMap |
| std::list< CVector2s > | _FreeSpaces [NL_NUM_FAR_PATCH_EDGE_LEVEL *NL_NUM_FAR_RECTANGLE_RATIO] |
| Lists of empty Space. | |
| CTextureFar * | _ULPrec |
| UpdateLighting. CiruclarList. | |
| CTextureFar * | _ULNext |
| TPatchToPosMap::iterator | _ItULPatch |
Static Private Attributes | |
| static NLMISC::CRGBA | _LightmapExpanded [] |
| static uint8 | _LumelExpanded [] |
| static NLMISC::CRGBA | _TileTLIColors [] |
A CTextureFar is a set of texture used to map a whole patch when it is in far Mode.
(ie not in tile mode). A CTextureFar handle several patch texture.\
TODO: keeping the far texture level1 alive when the tile pass in level0 (tile mode), don't erase it. TODO: add an hysteresis to avoid swap of far texture on boundaries of levels TODO: set the upload format in rgba565
Definition at line 83 of file texture_far.h.
typedef std::map<CPatchIdent, CVector2s> NL3D::CTextureFar::TPatchToPosMap [private] |
Map of Patchs stored in this texture Far.
Should be == to _WidthPatches*_HeightPatches
Definition at line 174 of file texture_far.h.
typedef std::map<CVector2s, CPatchIdent> NL3D::CTextureFar::TPosToPatchMap [private] |
Definition at line 175 of file texture_far.h.
| NL3D::CTextureFar::CTextureFar | ( | ) |
Constructor.
Definition at line 46 of file texture_far.cpp.
References _FreeSpaces, _ItULPatch, _PatchToPosMap, _ULNext, _ULPrec, NL3D::ITexture::Clamp, getFreeListId(), NL3D::ITexture::Linear, NL3D::ITexture::LinearMipMapOff, NL_MAX_FAR_PATCH_EDGE, NL_MAX_TILES_BY_PATCH_EDGE, NL_NUM_FAR_BIGGEST_PATCH_PER_EDGE, nlctassert, NL3D::ITexture::RGB565, NL3D::ITexture::setFilterMode(), NL3D::ITexture::setReleasable(), NL3D::ITexture::setUploadFormat(), NL3D::ITexture::setWrapS(), NL3D::ITexture::setWrapT(), NL3D::CTextureFar::CVector2s::x, and NL3D::CTextureFar::CVector2s::y.
| NL3D::CTextureFar::~CTextureFar | ( | ) | [virtual] |
Definition at line 90 of file texture_far.cpp.
| void NL3D::CTextureFar::allocatePatch | ( | CPatch * | pPatch, | |
| uint | farIndex, | |||
| float & | farUScale, | |||
| float & | farVScale, | |||
| float & | farUBias, | |||
| float & | farVBias, | |||
| bool & | bRot | |||
| ) |
Allocate a patch in the CTextureFar, according to its size.
nlstop if fails. Must call before tryAllocate()
| pPatch | is the pointer to the patch to add in the landscape | |
| farUVScale | will receive the scale to use to compute the UV coordinates | |
| farUBias | will receive the U Bias to use to compute the UV coordinates | |
| farVBias | will receive the V Bias to use to compute the UV coordinates | |
| bRot | will receive true if the texture is rotated of 90deg to the left or false. You should take care of this value to compute UV coordinates. |
Definition at line 274 of file texture_far.cpp.
References _FreeSpaces, _PatchToPosMap, _PosToPatchMap, NL3D::CTextureFar::CPatchIdent::FarIndex, getFreeListId(), NL3D::CPatch::getOrderS(), NL3D::CPatch::getOrderT(), NL_FAR_TEXTURE_EDGE_SIZE, NL_NUM_PIXELS_ON_FAR_TILE_EDGE, nlassert, NL3D::CTextureFar::CPatchIdent::Patch, recursSplitNext(), NLMISC::CBitmap::swap(), NL3D::ITexture::touchRect(), NL3D::CTextureFar::CVector2s::x, and NL3D::CTextureFar::CVector2s::y.
Referenced by NL3D::CLandscape::getFarRenderPass().
| void NL3D::CTextureFar::doGenerate | ( | bool | async = false |
) | [virtual] |
Generate the texture.
Implements NL3D::ITexture.
Definition at line 418 of file texture_far.cpp.
References NL3D::ITexture::_ListInvalidRect, _PosToPatchMap, NL_FAR_TEXTURE_EDGE_SIZE, rebuildPatch(), NLMISC::CBitmap::resize(), and NLMISC::CBitmap::RGBA.
| bool NL3D::CTextureFar::endPatchULTouch | ( | ) | const |
Definition at line 409 of file texture_far.cpp.
References _ItULPatch, and _PatchToPosMap.
Referenced by NL3D::CLandscape::updateLightingTextureFar().
Definition at line 126 of file texture_far.cpp.
References NLMISC::getPowerOf2(), NLMISC::isPowerOf2(), NL_MAX_FAR_PATCH_EDGE, NL_NUM_FAR_PATCH_EDGE_LEVEL, NL_NUM_FAR_RECTANGLE_RATIO, and nlassert.
Referenced by allocatePatch(), CTextureFar(), recursSplitNext(), removePatch(), and tryAllocatePatch().
| CTextureFar* NL3D::CTextureFar::getNextUL | ( | ) | const [inline] |
For lighting update, get Next (CiruclarList). If ==this, then list is empty.
Definition at line 137 of file texture_far.h.
References _ULNext.
Referenced by NL3D::CLandscape::clearFarRenderPass(), and NL3D::CLandscape::updateLightingTextureFar().
Definition at line 146 of file texture_far.cpp.
References NLMISC::isPowerOf2(), NL_MAX_FAR_PATCH_EDGE, and nlassert.
Referenced by recursSplitNext(), and tryAllocatePatch().
| void NL3D::CTextureFar::linkBeforeUL | ( | CTextureFar * | textNext | ) |
For lighting update, insert this before textNext (CiruclarList). textNext must be !NULL.
Definition at line 98 of file texture_far.cpp.
References _ULNext, _ULPrec, and nlassert.
Referenced by NL3D::CLandscape::getFarRenderPass().
| NL3D::CTextureFar::NLMISC_DECLARE_CLASS | ( | CTextureFar | ) | [private] |
| void NL3D::CTextureFar::rebuildPatch | ( | const CVector2s | texturePos, | |
| const CPatchIdent & | pid | |||
| ) | [private] |
Rebuild the patch passed in parameter.
Definition at line 463 of file texture_far.cpp.
References _Bank, _LightmapExpanded, _LumelExpanded, _TileTLIColors, NLMISC::CBitmap::_Width, NL3D::CTileFarBank::additive, NL3D_CComputeTileFar::AsmMMX, NL3D_CExpandLightmap::ColorTile, NL3D::CPatch::computeCurrentTLILightmapDiv2(), NL3D::CTileFarBank::diffuse, NL3D_CComputeTileFar::DstDeltaX, NL3D_CComputeTileFar::DstDeltaY, NL3D_CComputeTileFar::DstPixels, NL3D_CExpandLightmap::DstPixels, NL3D::CTextureFar::CPatchIdent::FarIndex, NL3D::CZone::getLandscape(), NL3D::CPatch::getOrderS(), NL3D::CPatch::getOrderT(), NLMISC::CBitmap::getPixelFormat(), NL3D::CTileFarBank::CTileFar::getPixels(), NLMISC::CBitmap::getPixels(), NL3D::CLandscape::getStaticLight(), NL3D::CTileFarBank::getTile(), NL3D::CTileElement::getTile256Info(), NL3D::CTileElement::getTileOrient(), NL3D::CPatch::getZone(), NLMISC::CSystemInfo::hasMMX(), NL3D_CExpandLightmap::Height, NL3D::CTileFarBank::CTileFar::isFill(), NL3D_CExpandLightmap::LumelTile, NL3D_CExpandLightmap::MulFactor, NL3D_drawFarTileInFarTexture(), NL3D_drawFarTileInFarTextureAdditive(), NL3D_drawFarTileInFarTextureAdditiveAlpha(), NL3D_drawFarTileInFarTextureAlpha(), NL3D_expandLightmap(), NL_NUM_PIXELS_ON_FAR_TILE_EDGE, NL_TILE_ELM_LAYER_EMPTY, nlassert, nlwarning, NL3D::CTileFarBank::order0, NL3D::CTileFarBank::order1, NL3D::CTileFarBank::order2, NL3D::CTextureFar::CPatchIdent::Patch, NLMISC::CBitmap::RGBA, NL3D_CComputeTileFar::Size, NL3D_CComputeTileFar::SrcAdditivePixels, NL3D_CComputeTileFar::SrcDeltaX, NL3D_CComputeTileFar::SrcDeltaY, NL3D_CComputeTileFar::SrcDiffusePixels, NL3D_CComputeTileFar::SrcLightingDeltaY, NL3D_CComputeTileFar::SrcLightingPixels, NL3D_CExpandLightmap::StaticLightColor, NL3D::CTileElement::Tile, NL3D::CPatch::TileColors, NL3D::CPatch::Tiles, NL3D_CExpandLightmap::TLIColor, NL3D::CPatch::unpackShadowMap(), NL3D_CExpandLightmap::Width, NL3D::CTextureFar::CVector2s::x, and NL3D::CTextureFar::CVector2s::y.
Referenced by doGenerate().
Definition at line 210 of file texture_far.cpp.
References _FreeSpaces, getFreeListId(), getUpperSize(), nlassert, nlverify, NL3D::CTextureFar::CVector2s::x, and NL3D::CTextureFar::CVector2s::y.
Referenced by allocatePatch().
Remove a patch in the CTexture Far.
Definition at line 333 of file texture_far.cpp.
References _FreeSpaces, _ItULPatch, _PatchToPosMap, _PosToPatchMap, NL3D::CTextureFar::CPatchIdent::FarIndex, getFreeListId(), NL3D::CPatch::getOrderS(), NL3D::CPatch::getOrderT(), NL_NUM_PIXELS_ON_FAR_TILE_EDGE, nlassert, NL3D::CTextureFar::CPatchIdent::Patch, and NLMISC::CBitmap::swap().
Referenced by NL3D::CLandscape::freeFarRenderPass().
| virtual void NL3D::CTextureFar::serial | ( | NLMISC::IStream & | ) | throw (NLMISC::EStream) [inline, private, virtual] |
| void NL3D::CTextureFar::startPatchULTouch | ( | ) |
Definition at line 402 of file texture_far.cpp.
References _ItULPatch, and _PatchToPosMap.
Referenced by NL3D::CLandscape::updateLightingTextureFar().
| uint NL3D::CTextureFar::touchPatchULAndNext | ( | ) |
Touch a patch (call touchRect()) and iterate to next .
Definition at line 366 of file texture_far.cpp.
References _ItULPatch, _PatchToPosMap, NL3D::CPatch::getOrderS(), NL3D::CPatch::getOrderT(), NL_NUM_PIXELS_ON_FAR_TILE_EDGE, NLMISC::CBitmap::swap(), and NL3D::ITexture::touchRect().
Referenced by NL3D::CLandscape::updateLightingTextureFar().
Try to allocate a patch.
return -1 if error (not enough space) return 0 if OK, and success to allocate a place without splitting any square else return the size of the max space to split (eg if must a split a 32x32 to allocate a 16x8)
Definition at line 174 of file texture_far.cpp.
References _FreeSpaces, getFreeListId(), NL3D::CPatch::getOrderS(), NL3D::CPatch::getOrderT(), getUpperSize(), NL_NUM_PIXELS_ON_FAR_TILE_EDGE, and NLMISC::CBitmap::swap().
Referenced by NL3D::CLandscape::getFarRenderPass().
| void NL3D::CTextureFar::unlinkUL | ( | ) |
For lighting update, unlink (CiruclarList).
Definition at line 114 of file texture_far.cpp.
References _ULNext, and _ULPrec.
Referenced by NL3D::CLandscape::clearFarRenderPass().
A pointer on the far bank.
Definition at line 141 of file texture_far.h.
Referenced by NL3D::CLandscape::getFarRenderPass(), and rebuildPatch().
std::list<CVector2s> NL3D::CTextureFar::_FreeSpaces[NL_NUM_FAR_PATCH_EDGE_LEVEL *NL_NUM_FAR_RECTANGLE_RATIO] [private] |
Lists of empty Space.
One for each possible size (64x64, 64x8 etc, but not 64x4 since not possible...)
Definition at line 181 of file texture_far.h.
Referenced by allocatePatch(), CTextureFar(), recursSplitNext(), removePatch(), and tryAllocatePatch().
TPatchToPosMap::iterator NL3D::CTextureFar::_ItULPatch [private] |
Definition at line 208 of file texture_far.h.
Referenced by CTextureFar(), endPatchULTouch(), removePatch(), startPatchULTouch(), and touchPatchULAndNext().
CRGBA NL3D::CTextureFar::_LightmapExpanded [static, private] |
Definition at line 198 of file texture_far.h.
Referenced by rebuildPatch().
uint8 NL3D::CTextureFar::_LumelExpanded [static, private] |
Definition at line 199 of file texture_far.h.
Referenced by rebuildPatch().
Definition at line 176 of file texture_far.h.
Referenced by allocatePatch(), CTextureFar(), endPatchULTouch(), removePatch(), startPatchULTouch(), and touchPatchULAndNext().
Definition at line 177 of file texture_far.h.
Referenced by allocatePatch(), doGenerate(), and removePatch().
CRGBA NL3D::CTextureFar::_TileTLIColors [static, private] |
Definition at line 200 of file texture_far.h.
Referenced by rebuildPatch().
CTextureFar* NL3D::CTextureFar::_ULNext [private] |
Definition at line 206 of file texture_far.h.
Referenced by CTextureFar(), getNextUL(), linkBeforeUL(), unlinkUL(), and ~CTextureFar().
CTextureFar* NL3D::CTextureFar::_ULPrec [private] |
UpdateLighting. CiruclarList.
Definition at line 205 of file texture_far.h.
Referenced by CTextureFar(), linkBeforeUL(), unlinkUL(), and ~CTextureFar().
1.6.1