From 0ea5fc66924303d1bf73ba283a383e2aadee02f2 Mon Sep 17 00:00:00 2001 From: neodarz Date: Sat, 11 Aug 2018 20:21:34 +0200 Subject: Initial commit --- docs/doxygen/nel/a03057.html | 16077 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 16077 insertions(+) create mode 100644 docs/doxygen/nel/a03057.html (limited to 'docs/doxygen/nel/a03057.html') diff --git a/docs/doxygen/nel/a03057.html b/docs/doxygen/nel/a03057.html new file mode 100644 index 00000000..5ec5a37e --- /dev/null +++ b/docs/doxygen/nel/a03057.html @@ -0,0 +1,16077 @@ + + +NeL: NL3D::CPatch class Reference + + + +
+

NL3D::CPatch Class Reference

#include <patch.h> +

+


Detailed Description

+A landscape patch. QuadPatch layout (same notations as 3ds Max SDK).

+A---> ad ---- da <---D | | | | v v ab ia id dc

+| | | |

+ba ib ic cd ^ ^ | | | | B---> bc ---- cb <---C

+NB: Patch 1x1 or 1xX are illegal: lot of problem: rectangular geomoprh, Son0 and Son1 must be setup as tile at beginning ...

+NB: Edges number are:

+

+

Author:
Lionel Berenguier

+Nevrax France

+
Date:
2000
+ +

+ +

+Definition at line 302 of file patch.h. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Lumels methods

void copyTileFlagsFromPatch (const CPatch *src)
void packShadowMap (const uint8 *pLumel)
void resetCompressedLumels ()
void setupColorsFromTileFlags (const NLMISC::CRGBA colors[4])
 debug coloring

void unpackShadowMap (uint8 *pShadow)
uint evalLumelBlock (const uint8 *original, const uint8 *unCompressed, uint width, uint height)
void packLumelBlock (uint8 *dest, const uint8 *source, uint8 alpha0, uint8 alpha1)
void unpackLumelBlock (uint8 *dest, const uint8 *src)

[NOHEADER]

bool getCornerSmoothFlag (uint corner) const
void setCornerSmoothFlag (uint corner, bool smooth)
uint8 NoiseRotation
 The orientation of the NoiseMap. 0,1,2,3. This represent a CCW rotation of the NoiseMap.

uint8 _CornerSmoothFlag
 Put here for packing with NoiseRotation.


RenderList mgt.

enum  TFarVertType { FVMasterBlock = 0, +FVTessBlock, +FVTessBlockEdge + }
void addRefTessBlocks ()
void appendFaceToRenderList (CTessFace *face)
void appendFaceToTileRenderList (CTessFace *face)
void appendFarVertexToRenderList (CTessFarVertex *fv)
void appendNearVertexToRenderList (CTileMaterial *tileMat, CTessNearVertex *nv)
void appendTileMaterialToRenderList (CTileMaterial *tm)
void clearTessBlocks ()
void decRefTessBlocks ()
void dirtTessBlockFaceVector (CTessBlock &block)
void extendTessBlockWithEndPos (CTessFace *face)
void getNumTessBlock (CParamCoord pc, TFarVertType &type, uint &numtb)
uint getNumTessBlock (CTessFace *face)
void removeFaceFromRenderList (CTessFace *face)
void removeFaceFromTileRenderList (CTessFace *face)
void removeFarVertexFromRenderList (CTessFarVertex *fv)
void removeNearVertexFromRenderList (CTileMaterial *tileMat, CTessNearVertex *nv)
void removeTileMaterialFromRenderList (CTileMaterial *tm)
void resetMasterBlock ()

Dynamic Lighting Management

void addRefDLMContext ()
 Add a ref count to the DLMContext, creating it if necessary.

void decRefDLMContext (uint count=1)
 Dec a ref count to the DLMContext, deleting it if refCount== 0.

CPatchDLMContext_DLMContext
sint _DLMContextRefCount

[NOHEADER]

CTessFacelinkTessFaceWithEdge (const NLMISC::CVector2f &uv0, const NLMISC::CVector2f &uv1, CTessFace *linkTo)
CZone_BindZoneNeighbor [4]
 The 4 neighbors zone of this patch (setuped at bind() time). NB: NULL if zone not loaded, or if no patch near us.


Public Member Functions

void averageTesselationVertices ()
void bind (CBindInfo Edges[4], bool rebind)
CAABBox buildBBox () const
 Build the bbox of the patch, according to ctrl points, and displacement map max value.

void compile (CZone *z, uint patchId, uint8 orderS, uint8 orderT, CTessVertex *baseVertices[4], float errorSize=0)
CVector computeContinousVertex (float s, float t) const
CVector computeVertex (float s, float t) const
 CPatch ()
 Constructor.

void deleteTileUvs ()
void forceMergeAtTileLevel ()
 For changing TileMaxSubdivision. force tesselation to be under tile.

void getBindNeighbor (uint edge, CBindInfo &neighborEdge) const
 return neighborhood information.

const CTessVertexgetCornerVertex (uint corner)
float getErrorSize () const
sint getFar0 () const
sint getFar1 () const
CLandscapegetLandscape () const
 Get the landscape in which is placed this patch.

uint8 getOrderForEdge (sint8 edge) const
uint8 getOrderS () const
uint8 getOrderT () const
uint16 getPatchId () const
uint getTileMaterialRefCount () const
 Get number of TileMaterial created in this Patch.

CZonegetZone () const
bool isRenderClipped () const
void recreateTileUvs ()
void refineAll ()
 Refine this patch. Even if clipped. Refine all nodes.

void refreshTesselationGeometry ()
void release ()
 Un-compile a patch. Tesselation is deleted. if patch is not compiled, no - op.

void resetRenderFar ()
void serial (NLMISC::IStream &f)
void unbind ()
void unpack (CBezierPatch &p) const
CBezierPatchunpackIntoCache () const
 ~CPatch ()
 dtor

Subdivision / ForCollision.
void addPatchBlocksInBBox (CPatchIdent paId, const CAABBox &bbox, std::vector< CPatchBlockIdent > &paBlockIds) const
void addTrianglesInBBox (CPatchIdent paId, const CAABBox &bbox, std::vector< CTrianglePatch > &triangles, uint8 tileTessLevel) const
void appendTessellationLeaves (std::vector< const CTessFace * > &leaves) const
void fillPatchQuadBlock (CPatchQuadBlock &quadBlock) const
CVector getTesselatedPos (CUV uv) const
VB Allocator mgt.
void allocateVBAndFaceVector ()
void allocateVBAndFaceVectorFar1Only ()
void debugAllocationMarkIndices (uint marker)
void deleteVBAndFaceVector ()
void deleteVBAndFaceVectorFar1Only ()
void fillFar0DLMUvOnlyVertexListVB (CTessList< CTessFarVertex > &vertList)
void fillFar1DLMUvOnlyVertexListVB (CTessList< CTessFarVertex > &vertList)
void fillVB ()
void fillVBFar0Only ()
void fillVBFar1Only ()
void fillVBFarsDLMUvOnly ()
void fillVBIfVisible ()
void recreateTessBlockFaceVector (CTessBlock &block)
Lightmap get interface.
void appendTileLightInfluences (const CUV &uv, std::vector< CPointLightInfluence > &pointLightList) const
void computeCurrentTLILightmapDiv2 (NLMISC::CRGBA *array) const
uint8 getLumel (const CUV &uv) const
 Get the lumel under the position.

Dynamic Lighting Management
void beginDLMLighting ()
void endDLMLighting ()
void processDLMLight (CPatchDLMPointLight &pl)
Render
void computeSoftwareGeomorphAndAlpha ()
CPatchgetNextFar0ToRdr () const
CPatchgetNextFar1ToRdr () const
void preRender (const NLMISC::CBSphere &patchSphere)
 preRender this patch. Build Max faces / pass etc...

void renderFar0 ()
 Render this patch, if not clipped. Call PatchCurrentDriver->renderSimpleTriangles().

void renderFar1 ()
void updateClipPatchVB (bool renderClipped)
void updateTextureFarOnly (const NLMISC::CBSphere &patchSphere)
MicroVegetation
void deleteAllVegetableIgs ()
 Delete any vegetable Ig still existing in this patch.

void recreateAllVegetableIgs ()
 Recreate any vegetable block (as possible) in this patch. (usefull for edition).

UpdateLighting Management
CPatchgetNextNearUL () const
 For lighting update, get Next (CiruclarList). If ==this, then list is empty.

uint getNumNearTessBlocks () const
 get the number of Near TessBlocks. Actually OrderS/2*OrderT/2.

void linkBeforeNearUL (CPatch *patchNext)
 For lighting update, insert this before patchNext (CiruclarList). textNext must be !NULL.

void unlinkNearUL ()
 For lighting update, unlink (CiruclarList).

uint updateTessBlockLighting (uint numTb)
Smooth flags methods
bool getSmoothFlag (uint edge) const
void setSmoothFlag (uint edge, bool flag)
Tiles get interface.
CTileElementgetTileElement (const CUV &uv)
 Get the lumel under the position.

TileLightInfluences
void resetTileLightInfluences ()

Data Fields

std::vector< uint8CompressedLumels
CVector3s Interiors [4]
CVector3s Tangents [8]
std::vector< CTileColorTileColors
std::vector< CTileLightInfluenceTileLightInfluences
std::vector< CTileElementTiles
CVector3s Vertices [4]
 The patch coordinates (see CBezierPatch).


Private Types


Private Member Functions

void changeEdgeNeighbor (sint edge, CTessFace *to)
void checkCreateVertexVBFar (CTessFarVertex *pVert)
void checkCreateVertexVBNear (CTessNearVertex *pVert)
void checkDeleteVertexVBFar (CTessFarVertex *pVert)
void checkDeleteVertexVBNear (CTessNearVertex *pVert)
void checkFillVertexVBFar (CTessFarVertex *pVert)
void checkFillVertexVBNear (CTessNearVertex *pVert)
void computeDefaultErrorSize ()
void computeGeomorphAlphaFar1VertexListVB (CTessList< CTessFarVertex > &vertList)
void computeGeomorphFar0VertexListVB (CTessList< CTessFarVertex > &vertList)
void computeGeomorphTileVertexListVB (CTessList< CTessNearVertex > &vertList)
void computeGeomorphVertexList (CTessList< CTessFarVertex > &vertList)
void computeNewFar (const NLMISC::CBSphere &patchSphere, sint &newFar0, sint &newFar1)
void computeTbTm (uint &numtb, uint &numtm, uint ts, uint tt)
void createFaceVectorFar0OrTile ()
void createFaceVectorFar1 ()
void debugAllocationMarkIndicesFarList (CTessList< CTessFarVertex > &vertList, uint marker)
void debugAllocationMarkIndicesNearList (CTessList< CTessNearVertex > &vertList, uint marker)
void deleteFaceVectorFar0OrTile ()
void deleteFaceVectorFar1 ()
void fillFar0VertexListVB (CTessList< CTessFarVertex > &vertList)
void fillFar0VertexVB (CTessFarVertex *pVert)
void fillFar1VertexListVB (CTessList< CTessFarVertex > &vertList)
void fillFar1VertexVB (CTessFarVertex *pVert)
void fillTileVertexListVB (CTessList< CTessNearVertex > &vertList)
void fillTileVertexVB (CTessNearVertex *pVert)
CTessFacegetRootFaceForEdge (sint edge) const
CTessVertexgetRootVertexForEdge (sint edge) const
void makeRoots ()
void updateFar0VBAlloc (CTessList< CTessFarVertex > &vertList, bool alloc)
void updateFar1VBAlloc (CTessList< CTessFarVertex > &vertList, bool alloc)
void updateTileVBAlloc (CTessList< CTessNearVertex > &vertList, bool alloc)
void updateVBAlloc (bool alloc)
Subdivision private.
void addPatchBlocksInBBoxRecurs (CPatchIdent paId, const CAABBox &bbox, std::vector< CPatchBlockIdent > &paBlockIds, const CBezierPatch &pa, uint8 s0, uint8 s1, uint8 t0, uint8 t1) const
void addTileTrianglesInBBox (CPatchIdent paId, const CAABBox &bbox, std::vector< CTrianglePatch > &triangles, uint8 tessLevel, uint8 s0, uint8 t0) const
void addTrianglesInBBoxRecurs (CPatchIdent paId, const CAABBox &bbox, std::vector< CTrianglePatch > &triangles, uint8 tessLevel, const CBezierPatch &pa, uint8 s0, uint8 s1, uint8 t0, uint8 t1) const
void buildBBoxFromBezierPatch (const CBezierPatch &p, CAABBox &ret) const
 build a bbox from the convex hull of a bezier patch, enlarged with noise.

CVector computeVertexButCorner (float s, float t, bool &onCorner) const
 Used by computeContinousVertex().

void addTileLightmapEdgeWithTLI (uint ts, uint tt, uint edge, NLMISC::CRGBA *dest, uint stride, bool inverse)
void addTileLightmapPixelWithTLI (uint ts, uint tt, uint s, uint t, NLMISC::CRGBA *dest)
void addTileLightmapWithTLI (uint ts, uint tt, NLMISC::CRGBA *dest, uint stride)
void computeNearBlockLightmap (uint ts, uint tt, NLMISC::CRGBA *lightText)
void computeTileLightmap (uint ts, uint tt, NLMISC::CRGBA *dest, uint stride)
void computeTileLightmapAutomatic (uint ts, uint tt, NLMISC::CRGBA *dest, uint stride)
void computeTileLightmapEdge (uint ts, uint tt, uint edge, NLMISC::CRGBA *dest, uint stride, bool inverse)
void computeTileLightmapEdgeAutomatic (uint ts, uint tt, uint edge, NLMISC::CRGBA *dest, uint stride, bool inverse)
void computeTileLightmapEdgePrecomputed (uint ts, uint tt, uint edge, NLMISC::CRGBA *dest, uint stride, bool inverse)
void computeTileLightmapPixel (uint ts, uint tt, uint s, uint t, NLMISC::CRGBA *dest)
void computeTileLightmapPixelAroundCorner (const NLMISC::CVector2f &stIn, NLMISC::CRGBA *dest, bool lookAround)
void computeTileLightmapPixelAutomatic (uint ts, uint tt, uint s, uint t, NLMISC::CRGBA *dest)
void computeTileLightmapPixelPrecomputed (uint ts, uint tt, uint s, uint t, NLMISC::CRGBA *dest)
void computeTileLightmapPrecomputed (uint ts, uint tt, NLMISC::CRGBA *dest, uint stride)
CRGBA CPatch::getCurrentTLIColor (uint x, uint y) const
void getCurrentTileTLIColors (uint ts, uint tt, NLMISC::CRGBA corners[4])
void getTileLightMap (uint ts, uint tt, CPatchRdrPass *&rdrpass)
void getTileLightMapUvInfo (uint ts, uint tt, CVector &uvScaleBias)
void getTileTileColors (uint ts, uint tt, NLMISC::CRGBA corners[4])
void modulateTileLightmapEdgeWithTileColors (uint ts, uint tt, uint edge, NLMISC::CRGBA *dest, uint stride, bool inverse)
void modulateTileLightmapPixelWithTileColors (uint ts, uint tt, uint s, uint t, NLMISC::CRGBA *dest)
void modulateTileLightmapWithTileColors (uint ts, uint tt, NLMISC::CRGBA *dest, uint stride)
void releaseTileLightMap (uint ts, uint tt)
float computeDisplaceCornerSmooth (float s, float t, sint8 smoothBorderX, sint8 smoothBorderY) const
float computeDisplaceEdgeSmooth (float s, float t, sint8 smoothBorderX, sint8 smoothBorderY) const
float computeDisplaceInteriorSmooth (float s, float t) const
float computeDisplaceRaw (float sTile, float tTile, float s, float t) const
void computeDisplaceRawCoordinates (float sTile, float tTile, float s, float t, sint &ts, sint &tt, sint &ms, sint &mt) const
float computeDisplaceRawInteger (sint ts, sint tt, sint ms, sint mt) const
float computeDisplaceRawOnNeighbor (float sTile, float tTile, float s, float t) const
void computeNoise (float s, float t, CVector &displace) const
CVector computeNormalCornerSmooth (float s, float t, sint8 smoothBorderX, sint8 smoothBorderY) const
CVector computeNormalEdgeSmooth (float s, float t, sint8 smoothBorderX, sint8 smoothBorderY) const
CVector computeNormalOnNeighbor (float s, float t, uint edgeExclude) const
void createVegetableBlock (uint numTb, uint ts, uint tt)
 Create / init the vegetableBlock in the corresponding TessBlock. TessBlocks must exist.

void generateTileVegetable (CVegetableInstanceGroup *vegetIg, uint distType, uint ts, uint tt, CLandscapeVegetableBlockCreateContext &vbCreateCtx)
 Create / init the vegetableBlock in the corresponding TessBlock. TessBlocks must exist.

void getTileLumelmapPixelPrecomputed (uint ts, uint tt, uint s, uint t, uint8 &dest) const
void getTileLumelmapPrecomputed (uint ts, uint tt, uint8 *dest, uint stride)
 Create / init the vegetableBlock in the corresponding TessBlock. TessBlocks must exist.

void releaseVegetableBlock (uint numTb)
 release the vegetableBlock in the corresponding TessBlock. TessBlocks must exist

Texture mgt.
CPatchRdrPassgetTileRenderPass (sint tileId, sint pass)
void getTileUvInfo (sint tileId, sint pass, bool alpha, uint8 &orient, CVector &uvScaleBias, bool &is256x256, uint8 &uvOff)

Private Attributes

CPatch_NextRdrFar0
CPatch_NextRdrFar1
CPatchRdrPass_PatchRdrPassFar0
CPatchRdrPass_PatchRdrPassFar1
CTessFarVertex BaseFarVertices [4]
CTessVertexBaseVertices [4]
float ErrorSize
bool ExcludeFromRefineAll
sint Far0
float Far0UBias
float Far0UScale
float Far0VBias
float Far0VScale
sint Far1
float Far1UBias
float Far1UScale
float Far1VBias
float Far1VScale
uint8 Flags
float OOTransitionSqrDelta
uint8 OrderS
uint8 OrderT
uint16 PatchId
CTessFaceSon0
CTessFaceSon1
sint SquareLimitLevel
sint TessBlockLimitLevel
sint TileLimitLevel
float TransitionSqrMin
CZoneZone
UpdateLighting Management
CPatch_ULNearNext
CPatch_ULNearPrec
Block renders.
CTessBlock MasterBlock
sint NumRenderableFaces
sint TessBlockRefCount
NLMISC::CObjectVector< CTessBlockTessBlocks
Vegetables.
std::vector< CVegetableClipBlock * > VegetableClipBlocks
 list of vegetable clipBlocks, created/destroyed at same time as TessBlocks.


Static Private Attributes

uint32 _Version = 7
CBezierPatch CachePatch
const CPatchLastPatch = NULL

Friends

class CLandscapeVegetableBlock
class CPatchRdrPass
class CTessFace
class CZone
+


Member Enumeration Documentation

+

+ + + + +
+ + +
enum NL3D::CPatch::TFarVertType [private] +
+
+ + + + + +
+   + + +

+

Enumeration values:
+ + + + +
FVMasterBlock  +
FVTessBlock  +
FVTessBlockEdge  +
+
+ +

+Definition at line 931 of file patch.h. +

+Referenced by appendFarVertexToRenderList(), and removeFarVertexFromRenderList(). +

+

+


Constructor & Destructor Documentation

+

+ + + + +
+ + + + + + + + + +
NL3D::CPatch::CPatch  ) 
+
+ + + + + +
+   + + +

+Constructor. +

+ +

+Definition at line 61 of file patch.cpp. +

+References _BindZoneNeighbor, _CornerSmoothFlag, _DLMContext, _DLMContextRefCount, _NextRdrFar0, _NextRdrFar1, _PatchRdrPassFar0, _PatchRdrPassFar1, _ULNearNext, _ULNearPrec, ExcludeFromRefineAll, MasterBlock, NoiseRotation, NumRenderableFaces, NL3D::CTessBlock::resetClip(), Son0, Son1, and TessBlockRefCount. +

+

00062 {
+00063         Zone= NULL;
+00064         OrderS=0;
+00065         OrderT=0;
+00066         Son0=NULL;
+00067         Son1=NULL;
+00068         TessBlockRefCount=0;
+00069         NumRenderableFaces= 0;
+00070 
+00071         // for Pacs process. By default, false.
+00072         ExcludeFromRefineAll= false;
+00073 
+00074         // Init Passes.
+00075         // DO NOT FILL Patch here, because of operator= problem. do it in compile().
+00076         // By default, RdrPasses are NULL.
+00077 
+00078         // To force computation of texture info on next preRender().
+00079         Far0= -1;
+00080         Far1= -1;
+00081 
+00082         // Default: not binded.
+00083         _BindZoneNeighbor[0]= NULL;
+00084         _BindZoneNeighbor[1]= NULL;
+00085         _BindZoneNeighbor[2]= NULL;
+00086         _BindZoneNeighbor[3]= NULL;
+00087         NoiseRotation= 0;
+00088         // No smooth by default.
+00089         _CornerSmoothFlag= 0;
+00090 
+00091         // MasterBlock never clipped.
+00092         MasterBlock.resetClip();
+00093 
+00094         // Init UL circular list to NULL (not compiled)
+00095         _ULNearPrec= NULL;
+00096         _ULNearNext= NULL;
+00097 
+00098         // Dynamic LightMap
+00099         _DLMContext= NULL;
+00100         _DLMContextRefCount= 0;
+00101 
+00102         // Render Passes
+00103         _PatchRdrPassFar0= NULL;
+00104         _NextRdrFar0= NULL;
+00105         _PatchRdrPassFar1= NULL;
+00106         _NextRdrFar1= NULL;
+00107 }
+
+

+ + + + +
+ + + + + + + + + +
NL3D::CPatch::~CPatch  ) 
+
+ + + + + +
+   + + +

+dtor +

+ +

+Definition at line 109 of file patch.cpp. +

+References release(). +

+

00110 {
+00111         release();
+00112 }
+
+


Member Function Documentation

+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::addPatchBlocksInBBox CPatchIdent  paId,
const CAABBox bbox,
std::vector< CPatchBlockIdent > &  paBlockIds
const
+
+ + + + + +
+   + + +

+Add CPatchBlockIdent to CPatchBlockIdent array which intersect the bbox. NB: this method use a convex hull subdivion to search in O(logn) what part of the patch to insert.

Parameters:
+ + + + +
patchId the id of this patch, used to fill PatchBlockIdent.
bbox the bbox to test against.
paBlockIds array to be filled (no clear performed, elements added).
+
+ +

+Definition at line 504 of file patch.cpp. +

+References addPatchBlocksInBBoxRecurs(), and unpackIntoCache(). +

+Referenced by NL3D::CLandscape::addPatchBlocksInBBox(). +

+

00505 {
+00506         CBezierPatch    &bpatch= *unpackIntoCache();
+00507 
+00508         // call with the whole root patch.
+00509         addPatchBlocksInBBoxRecurs(paId, bbox, paBlockIds, bpatch, 0, OrderS, 0, OrderT);
+00510 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::addPatchBlocksInBBoxRecurs CPatchIdent  paId,
const CAABBox bbox,
std::vector< CPatchBlockIdent > &  paBlockIds,
const CBezierPatch pa,
uint8  s0,
uint8  s1,
uint8  t0,
uint8  t1
const [private]
+
+ + + + + +
+   + + +

+recurse method of addPatchBlocksInBBox. +

+Definition at line 514 of file patch.cpp. +

+References buildBBoxFromBezierPatch(), NLMISC::CAABBox::intersect(), NL_PATCH_BLOCK_MAX_QUAD, nlassert, NL3D::CPatchBlockIdent::OrderS, NL3D::CPatchBlockIdent::OrderT, NL3D::CPatchBlockIdent::PatchId, NL3D::CPatchBlockIdent::S0, NL3D::CPatchBlockIdent::S1, NL3D::CBezierPatch::subdivideS(), NL3D::CBezierPatch::subdivideT(), NL3D::CPatchBlockIdent::T0, NL3D::CPatchBlockIdent::T1, uint, and uint8. +

+Referenced by addPatchBlocksInBBox(). +

+

00516 {
+00517         uint8   lenS=s1-s0, lenT=t1-t0;
+00518         nlassert(lenS>0);
+00519         nlassert(lenT>0);
+00520 
+00521         // compute and compare bbox of the subdivision patch against request bbox.
+00522         //========================
+00523         // NB: this compute includes possible noise.
+00524         CAABBox         paBBox;
+00525         buildBBoxFromBezierPatch(pa, paBBox);
+00526         // if do not intersect, stop here.
+00527         if( !paBBox.intersect(bbox) )
+00528                 return;
+00529         // else if at CPatchQuadBlock tile level, then just add this Id.
+00530         //========================
+00531         else if( lenS<=NL_PATCH_BLOCK_MAX_QUAD && lenT<=NL_PATCH_BLOCK_MAX_QUAD )
+00532         {
+00533                 // Add this PatchBlock desctiptor to the list.
+00534                 CPatchBlockIdent        pbId;
+00535                 // Fill struct from this and result of recursion.
+00536                 pbId.PatchId= paId;
+00537                 pbId.OrderS= OrderS;
+00538                 pbId.OrderT= OrderT;
+00539                 pbId.S0= s0;
+00540                 pbId.S1= s1;
+00541                 pbId.T0= t0;
+00542                 pbId.T1= t1;
+00543                 // Add to list.
+00544                 paBlockIds.push_back(pbId);
+00545         }
+00546         // else subdiv and reccurs.
+00547         //========================
+00548         else
+00549         {
+00550                 // Subdivide along the bigger side.
+00551                 if(lenS>lenT)
+00552                 {
+00553                         // subdivide.
+00554                         CBezierPatch    left, right;
+00555                         pa.subdivideS(left, right);
+00556                         uint8   sMiddle= (uint8)( ((uint)s0+(uint)s1) /2 );
+00557                         // recurs left.
+00558                         addPatchBlocksInBBoxRecurs(paId, bbox, paBlockIds, left, s0, sMiddle, t0, t1);
+00559                         // recurs right.
+00560                         addPatchBlocksInBBoxRecurs(paId, bbox, paBlockIds, right, sMiddle, s1, t0, t1);
+00561                 }
+00562                 else
+00563                 {
+00564                         // subdivide.
+00565                         CBezierPatch    top, bottom;
+00566                         pa.subdivideT(top, bottom);
+00567                         uint8   tMiddle= (uint8)( ((uint)t0+(uint)t1) /2 );
+00568                         // recurs top.
+00569                         addPatchBlocksInBBoxRecurs(paId, bbox, paBlockIds, top, s0, s1, t0, tMiddle);
+00570                         // recurs bottom.
+00571                         addPatchBlocksInBBoxRecurs(paId, bbox, paBlockIds, bottom, s0, s1, tMiddle, t1);
+00572                 }
+00573         }
+00574 
+00575 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CPatch::addRefDLMContext  )  [private]
+
+ + + + + +
+   + + +

+Add a ref count to the DLMContext, creating it if necessary. +

+ +

+Definition at line 1950 of file patch_lightmap.cpp. +

+References _DLMContext, _DLMContextRefCount, fillVBFarsDLMUvOnly(), NL3D::CPatchDLMContext::generate(), getLandscape(), isRenderClipped(), and nlassert. +

+Referenced by appendTileMaterialToRenderList(), and processDLMLight(). +

+

01951 {
+01952         // the patch must be compiled.
+01953         nlassert(Zone);
+01954 
+01955         // if 0, create the context.
+01956         if(_DLMContextRefCount==0)
+01957         {
+01958                 nlassert(_DLMContext==NULL);
+01959                 _DLMContext= new CPatchDLMContext;
+01960                 // init now the context.
+01961                 _DLMContext->generate(this, getLandscape()->getTextureDLM(), getLandscape()->getPatchDLMContextList());
+01962 
+01963                 // If the patch is visible, it may have Far Vertices created, 
+01964                 // hence, we must refill them with good DLM Uvs.
+01965                 if(!isRenderClipped())
+01966                 {
+01967                         // setup DLM Uv with new _DLMContext
+01968                         fillVBFarsDLMUvOnly();
+01969                 }
+01970         }
+01971 
+01972         // incRef.
+01973         _DLMContextRefCount++;
+01974 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CPatch::addRefTessBlocks  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 611 of file patch.cpp. +

+References NL3D::CLandscape::_VegetableManager, NL3D::CVegetableManager::createClipBlock(), getLandscape(), NL3D::CLandscape::linkPatchToNearUL(), NL3D_PATCH_VEGETABLE_NUM_TESSBLOCK_PER_CLIPBLOCK, NL3D_PATCH_VEGETABLE_NUM_TESSBLOCK_PER_CLIPBLOCK_SHIFT, NL3D_TESSBLOCK_TILESIZE, nlassert, NLMISC::CObjectVector< CTessBlock >::resize(), sint, NLMISC::CObjectVector< CTessBlock >::size(), TessBlockRefCount, TessBlocks, uint, and VegetableClipBlocks. +

+Referenced by appendFaceToRenderList(), appendFarVertexToRenderList(), appendNearVertexToRenderList(), and appendTileMaterialToRenderList(). +

+

00612 {
+00613         uint    i;
+00614 
+00615         TessBlockRefCount++;
+00616         if(TessBlocks.size()==0)
+00617         {
+00618                 // Allocate the tessblocks.
+00619                 //==========
+00620 
+00621                 nlassert(NL3D_TESSBLOCK_TILESIZE==4);
+00622                 // A tessblock is 2*2 tiles.
+00623                 sint os= OrderS>>1;
+00624                 sint ot= OrderT>>1;
+00625                 nlassert(os>0);
+00626                 nlassert(ot>0);
+00627                 TessBlocks.resize(os*ot);
+00628                 // init all tessBlocks with the Patch ptr.
+00629                 for(i=0; i<TessBlocks.size(); i++)
+00630                         TessBlocks[i].init(this);
+00631 
+00632 
+00633                 // Vegetable management
+00634                 //==========
+00635                 CVegetableManager       *vegetableManager= getLandscape()->_VegetableManager;
+00636 
+00637                 // Create ClipBlocks.
+00638                 uint    nTbPerCb= NL3D_PATCH_VEGETABLE_NUM_TESSBLOCK_PER_CLIPBLOCK;
+00639                 uint    wCB= (os + nTbPerCb-1) >> NL3D_PATCH_VEGETABLE_NUM_TESSBLOCK_PER_CLIPBLOCK_SHIFT;
+00640                 uint    hCB= (ot + nTbPerCb-1) >> NL3D_PATCH_VEGETABLE_NUM_TESSBLOCK_PER_CLIPBLOCK_SHIFT;
+00641                 VegetableClipBlocks.resize(wCB * hCB);
+00642                 // allocate ClipBlocks
+00643                 for(i=0; i<VegetableClipBlocks.size(); i++)
+00644                 {
+00645                         VegetableClipBlocks[i]= vegetableManager->createClipBlock();
+00646                 }
+00647 
+00648 
+00649                 // updateLighting management.
+00650                 //==========
+00651                 // append patch for Near updateLighting, since TessBlock lightmap may/will exist.
+00652                 getLandscape()->linkPatchToNearUL(this);
+00653 
+00654         }
+00655 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::addTileLightmapEdgeWithTLI uint  ts,
uint  tt,
uint  edge,
NLMISC::CRGBA dest,
uint  stride,
bool  inverse
[private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1758 of file patch_lightmap.cpp. +

+References NL3D::bilinearColorDiv2AndAdd(), getCurrentTileTLIColors(), NL_LUMEL_BY_TILE, stride, uint, x, and y. +

+Referenced by computeTileLightmapEdge(). +

+

01759 {
+01760         // compute colors ar corners of the tile.
+01761         CRGBA   corners[4];
+01762         getCurrentTileTLIColors(ts, tt, corners);
+01763 
+01764         // get coordinate according to edge.
+01765         uint    x=0,y=0;
+01766         switch(edge)
+01767         {
+01768         case 0: x= 0; break;
+01769         case 1: y= NL_LUMEL_BY_TILE-1; break;
+01770         case 2: x= NL_LUMEL_BY_TILE-1; break;
+01771         case 3: y= 0; break;
+01772         };
+01773 
+01774         // For all lumel of the edge, bilinear.
+01775         uint    i;
+01776         for(i=0; i<NL_LUMEL_BY_TILE; i++)
+01777         {
+01778                 // if vertical edge
+01779                 if( (edge&1)==0 )       y= i;
+01780                 // else horizontal edge
+01781                 else                            x= i;
+01782 
+01783                 // manage inverse.
+01784                 uint    where;
+01785                 if(inverse)             where= (NL_LUMEL_BY_TILE-1)-i;
+01786                 else                    where= i;
+01787                 // compute this pixel, and modulate
+01788                 bilinearColorDiv2AndAdd(corners, x, y, dest[where*stride]);
+01789         }
+01790 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::addTileLightmapPixelWithTLI uint  ts,
uint  tt,
uint  s,
uint  t,
NLMISC::CRGBA dest
[private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1793 of file patch_lightmap.cpp. +

+References NL3D::bilinearColorDiv2AndAdd(), getCurrentTileTLIColors(), s, t, and uint. +

+Referenced by computeTileLightmapPixel(). +

+

01794 {
+01795         // compute colors ar corners of the tile.
+01796         CRGBA   corners[4];
+01797         getCurrentTileTLIColors(ts, tt, corners);
+01798 
+01799         // compute this pixel, and modulate
+01800         bilinearColorDiv2AndAdd(corners, s, t, *dest);
+01801 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::addTileLightmapWithTLI uint  ts,
uint  tt,
NLMISC::CRGBA dest,
uint  stride
[private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1739 of file patch_lightmap.cpp. +

+References NL3D::bilinearColorDiv2AndAdd(), getCurrentTileTLIColors(), NL_LUMEL_BY_TILE, stride, uint, x, and y. +

+Referenced by computeTileLightmap(). +

+

01740 {
+01741         // compute colors ar corners of the tile.
+01742         CRGBA   corners[4];
+01743         getCurrentTileTLIColors(ts, tt, corners);
+01744 
+01745         // Bilinear accross the tile, and add to dest.
+01746         uint    x, y;
+01747         for(y=0; y<NL_LUMEL_BY_TILE; y++)
+01748         {
+01749                 for(x=0; x<NL_LUMEL_BY_TILE; x++)
+01750                 {
+01751                         // compute this pixel, and add
+01752                         bilinearColorDiv2AndAdd(corners, x, y, dest[y*stride + x]);
+01753                 }
+01754         }
+01755 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::addTileTrianglesInBBox CPatchIdent  paId,
const CAABBox bbox,
std::vector< CTrianglePatch > &  triangles,
uint8  tessLevel,
uint8  s0,
uint8  t0
const [private]
+
+ + + + + +
+   + + +

+called by addTrianglesInBBoxRecurs(). effective fill the array of triangles from 1 tile at tile coordinates s0,t0. depending of tessLevel (0,1,2), 2, 8 or 32 triangles are added. (2*2m, 1*1*m or 0.5*0.5m). NB: only triangles of quad included in the bbox are added. +

+Definition at line 335 of file patch.cpp. +

+References computeVertex(), NLMISC::CAABBox::extend(), NLMISC::CAABBox::intersect(), nlassert, NL3D::CTrianglePatch::PatchId, NLMISC::CAABBox::setCenter(), NLMISC::CUV::U, uint, uint8, NLMISC::CTriangleUV::Uv0, NLMISC::CTriangleUV::Uv1, NLMISC::CTriangleUV::Uv2, NLMISC::CUV::V, NLMISC::CTriangle::V0, NLMISC::CTriangle::V1, and NLMISC::CTriangle::V2. +

+Referenced by addTrianglesInBBoxRecurs(). +

+

00336 {
+00337         nlassert(s0<OrderS);
+00338         nlassert(t0<OrderT);
+00339         nlassert(tessLevel<=2);
+00340         uint    tessLen= 1<<tessLevel;
+00341 
+00342         // some preca.
+00343         float   startS0= (float)s0 / (float)(OrderS);
+00344         float   startT0= (float)t0 / (float)(OrderT);
+00345         float   ds= 1.0f/(float)(OrderS*tessLen);
+00346         float   dt= 1.0f/(float)(OrderT*tessLen);
+00347 
+00348         // Parse all quads.
+00349         uint    sl,tl;
+00350         for(tl=0; tl<tessLen; tl++)
+00351         {
+00352                 float   fs0, fs1, ft0, ft1;
+00353                 // compute t patch coordinates.
+00354                 ft0= startT0 + (float)tl * dt ;
+00355                 ft1= ft0 + dt;
+00356                 for(sl=0; sl<tessLen; sl++)
+00357                 {
+00358                         // compute s patch coordinates.
+00359                         fs0= startS0 + (float)sl * ds ;
+00360                         fs1= fs0 + ds;
+00361 
+00362                         // Compute Quad vectors (in CCW).
+00363                         CVector         p0, p1, p2, p3;
+00364                         CUV                     uv0, uv1, uv2, uv3;
+00365                         uv0.U= fs0; uv0.V= ft0;
+00366                         uv1.U= fs0; uv1.V= ft1;
+00367                         uv2.U= fs1; uv2.V= ft1;
+00368                         uv3.U= fs1; uv3.V= ft0;
+00369                         // evaluate patch (with noise). (NB: because of cache, patch decompression cost nothing).
+00370                         p0= computeVertex(uv0.U, uv0.V);
+00371                         p1= computeVertex(uv1.U, uv1.V);
+00372                         p2= computeVertex(uv2.U, uv2.V);
+00373                         p3= computeVertex(uv3.U, uv3.V);
+00374 
+00375                         // build the bbox of this quad, and test with request bbox.
+00376                         CAABBox         quadBBox;
+00377                         quadBBox.setCenter(p0);
+00378                         quadBBox.extend(p1);
+00379                         quadBBox.extend(p2);
+00380                         quadBBox.extend(p3);
+00381 
+00382                         // insert only if intersect with the bbox.
+00383                         if(quadBBox.intersect(bbox))
+00384                         {
+00385                                 // build triangles (in CCW).
+00386                                 CTrianglePatch  tri;
+00387                                 tri.PatchId= paId;
+00388 
+00389                                 // first tri.
+00390                                 tri.V0= p0; tri.V1= p1; tri.V2= p2;
+00391                                 tri.Uv0= uv0; tri.Uv1= uv1; tri.Uv2= uv2;
+00392                                 triangles.push_back(tri);
+00393 
+00394                                 // second tri.
+00395                                 tri.V0= p2; tri.V1= p3; tri.V2= p0;
+00396                                 tri.Uv0= uv2; tri.Uv1= uv3; tri.Uv2= uv0;
+00397                                 triangles.push_back(tri);
+00398 
+00399                                 // NB: this is not the same tesselation than in tesselation.cpp.
+00400                                 // But this looks like Ben's NLPACS::CLocalRetriever tesselation.
+00401                         }
+00402                 }
+00403         }
+00404 
+00405 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::addTrianglesInBBox CPatchIdent  paId,
const CAABBox bbox,
std::vector< CTrianglePatch > &  triangles,
uint8  tileTessLevel
const
+
+ + + + + +
+   + + +

+Add triangles to triangles array which intersect the bbox. NB: this method use a convex hull subdivion to search in O(logn) what part of the patch to insert.

Parameters:
+ + + + + +
patchId the id of this patch, used to fill triangles.
bbox the bbox to test against.
triangles array to be filled (no clear performed, elements added).
tileTessLevel 0,1 or 2 size of the triangles (2*2m, 1*1m or 0.5*0.5m). Level of subdivision of a tile.
+
+ +

+Definition at line 270 of file patch.cpp. +

+References addTrianglesInBBoxRecurs(), uint8, and unpackIntoCache(). +

+Referenced by NL3D::CLandscape::addTrianglesInBBox(). +

+

00271 {
+00272         CBezierPatch    &bpatch= *unpackIntoCache();
+00273 
+00274         // call with the whole root patch.
+00275         addTrianglesInBBoxRecurs(paId, bbox, triangles, tileTessLevel, bpatch, 0, OrderS, 0, OrderT);
+00276 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::addTrianglesInBBoxRecurs CPatchIdent  paId,
const CAABBox bbox,
std::vector< CTrianglePatch > &  triangles,
uint8  tessLevel,
const CBezierPatch pa,
uint8  s0,
uint8  s1,
uint8  t0,
uint8  t1
const [private]
+
+ + + + + +
+   + + +

+recurse subdivide of the bezierPatch. 3 1st parameters are the parameter of addTrianglesInBBox().
+ pa is the bezier patch for this subdivision of this patch.
+ s0, s1, t0, t1 represent the part of the bezier patch subdivided. At start, s0=0, s1=OrderS, t0=0, t1=OrderT. +

+Definition at line 280 of file patch.cpp. +

+References addTileTrianglesInBBox(), buildBBoxFromBezierPatch(), NLMISC::CAABBox::intersect(), nlassert, NL3D::CBezierPatch::subdivideS(), NL3D::CBezierPatch::subdivideT(), uint, and uint8. +

+Referenced by addTrianglesInBBox(). +

+

00282 {
+00283         uint8   lenS=s1-s0, lenT=t1-t0;
+00284         nlassert(lenS>0);
+00285         nlassert(lenT>0);
+00286 
+00287         // compute and compare bbox of the subdivision patch against request bbox.
+00288         //========================
+00289         // NB: this compute includes possible noise.
+00290         CAABBox         paBBox;
+00291         buildBBoxFromBezierPatch(pa, paBBox);
+00292         // if do not intersect, stop here.
+00293         if( !paBBox.intersect(bbox) )
+00294                 return;
+00295         // else if at tile level, then just computeTriangles.
+00296         //========================
+00297         else if( lenS==1 && lenT==1 )
+00298         {
+00299                 addTileTrianglesInBBox(paId, bbox, triangles, tessLevel, s0, t0);
+00300         }
+00301         // else subdiv and reccurs.
+00302         //========================
+00303         else
+00304         {
+00305                 // Subdivide along the bigger side.
+00306                 if(lenS>lenT)
+00307                 {
+00308                         // subdivide.
+00309                         CBezierPatch    left, right;
+00310                         pa.subdivideS(left, right);
+00311                         uint8   sMiddle= (uint8)( ((uint)s0+(uint)s1) /2 );
+00312                         // recurs left.
+00313                         addTrianglesInBBoxRecurs(paId, bbox, triangles, tessLevel, left, s0, sMiddle, t0, t1);
+00314                         // recurs right.
+00315                         addTrianglesInBBoxRecurs(paId, bbox, triangles, tessLevel, right, sMiddle, s1, t0, t1);
+00316                 }
+00317                 else
+00318                 {
+00319                         // subdivide.
+00320                         CBezierPatch    top, bottom;
+00321                         pa.subdivideT(top, bottom);
+00322                         uint8   tMiddle= (uint8)( ((uint)t0+(uint)t1) /2 );
+00323                         // recurs top.
+00324                         addTrianglesInBBoxRecurs(paId, bbox, triangles, tessLevel, top, s0, s1, t0, tMiddle);
+00325                         // recurs bottom.
+00326                         addTrianglesInBBoxRecurs(paId, bbox, triangles, tessLevel, bottom, s0, s1, tMiddle, t1);
+00327                 }
+00328         }
+00329 
+00330 
+00331 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CPatch::allocateVBAndFaceVector  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 845 of file patch_render.cpp. +

+References createFaceVectorFar0OrTile(), createFaceVectorFar1(), and updateVBAlloc(). +

+Referenced by preRender(), and updateClipPatchVB(). +

+

00846 {
+00847         updateVBAlloc(true);
+00848         createFaceVectorFar1();
+00849         createFaceVectorFar0OrTile();
+00850 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CPatch::allocateVBAndFaceVectorFar1Only  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 873 of file patch_render.cpp. +

+References createFaceVectorFar1(), NL3D::CTessBlock::FarVertexList, MasterBlock, sint, NLMISC::CObjectVector< CTessBlock >::size(), TessBlocks, updateFar1VBAlloc(), and NL3D::CTessBlock::visibleFar1(). +

+Referenced by preRender(). +

+

00874 {
+00875         if(Far1>0)
+00876         {
+00877                 // alloc VB.
+00878                 updateFar1VBAlloc(MasterBlock.FarVertexList, true);
+00879                 for(sint i=0; i<(sint)TessBlocks.size(); i++)
+00880                 {
+00881                         CTessBlock      &tblock= TessBlocks[i];
+00882                         // need update VB only if tessBlock is visible.
+00883                         if( tblock.visibleFar1() )
+00884                                 updateFar1VBAlloc(tblock.FarVertexList, true);
+00885                 }
+00886         }
+00887 
+00888         createFaceVectorFar1();
+00889 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::appendFaceToRenderList CTessFace face  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 800 of file patch.cpp. +

+References addRefTessBlocks(), NL3D::CTessList< CTessFace >::append(), appendFaceToTileRenderList(), dirtTessBlockFaceVector(), NL3D::CTessVertex::EndPos, NL3D::CTessBlock::FaceTileMaterialRefCount, NL3D::CTessBlock::FarFaceList, getNumTessBlock(), NL3D::CTessFace::Level, MasterBlock, NumRenderableFaces, NL3D::CTessVertex::StartPos, TessBlockLimitLevel, TessBlocks, uint, NL3D::CTessFace::VBase, NL3D::CTessFace::VLeft, and NL3D::CTessFace::VRight. +

+Referenced by NL3D::CTessFace::doMerge(), makeRoots(), NL3D::CTessFace::split(), and NL3D::CTessFace::splitRectangular(). +

+

00801 {
+00802         // Update the number of renderable Faces
+00803         NumRenderableFaces++;
+00804 
+00805         // Update Gnal render.
+00806         //====================
+00807         if(face->Level<TessBlockLimitLevel)
+00808         {
+00809                 MasterBlock.FarFaceList.append(face);
+00810                 MasterBlock.FaceTileMaterialRefCount++;
+00811 
+00812                 // The facelist is modified, so we must update the faceVector, if visible.
+00813                 dirtTessBlockFaceVector(MasterBlock);
+00814         }
+00815         else
+00816         {
+00817                 // Alloc if necessary the TessBlocks.
+00818                 addRefTessBlocks();
+00819 
+00820                 // link the face to the good tessblock.
+00821                 uint    numtb= getNumTessBlock(face);
+00822                 TessBlocks[numtb].FarFaceList.append(face);
+00823                 TessBlocks[numtb].FaceTileMaterialRefCount++;
+00824 
+00825                 // The facelist is modified, so we must update the faceVector, if visible.
+00826                 dirtTessBlockFaceVector(TessBlocks[numtb]);
+00827 
+00828                 // Must enlarge the BSphere of the tesblock!!
+00829                 // We must do it on a per-face approach, because of tessblocks 's corners which are outside of tessblocks.
+00830                 TessBlocks[numtb].extendSphereFirst(face->VBase->EndPos);
+00831                 TessBlocks[numtb].extendSphereAdd(face->VLeft->EndPos);
+00832                 TessBlocks[numtb].extendSphereAdd(face->VRight->EndPos);
+00833                 // I think this should be done too on StartPos, for geomorph (rare??...) problems.
+00834                 // \todo yoyo: is this necessary???
+00835                 TessBlocks[numtb].extendSphereAdd(face->VBase->StartPos);
+00836                 TessBlocks[numtb].extendSphereAdd(face->VLeft->StartPos);
+00837                 TessBlocks[numtb].extendSphereAdd(face->VRight->StartPos);
+00838                 TessBlocks[numtb].extendSphereCompile();
+00839 
+00840 
+00841                 // Update Tile render (no need to do it if face not at least at tessblock level).
+00842                 appendFaceToTileRenderList(face);
+00843         }
+00844 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::appendFaceToTileRenderList CTessFace face  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 884 of file patch.cpp. +

+References NL3D::CTessList< CTileFace >::append(), NL3D::CLandscape::appendToShadowPolyReceiver(), dirtTessBlockFaceVector(), getLandscape(), getNumTessBlock(), NL3D_MAX_TILE_FACE, nlassert, NL3D::CTileMaterial::Pass, NL3D::CRdrTileId::PatchRdrPass, sint, TessBlocks, NL3D::CTileMaterial::TileFaceList, NL3D::CTessFace::TileFaces, NL3D::CTessFace::TileMaterial, and uint. +

+Referenced by appendFaceToRenderList(), and NL3D::CTessFace::recreateTileUvs(). +

+

00885 {
+00886         if(face->TileMaterial)
+00887         {
+00888                 // For all valid faces, update their links.
+00889                 // Do not do this for lightmap, since it use same face from RGB0 pass.
+00890                 for(sint i=0;i<NL3D_MAX_TILE_FACE;i++)
+00891                 {
+00892                         CPatchRdrPass   *tilePass= face->TileMaterial->Pass[i].PatchRdrPass;
+00893                         // If tile i enabled.
+00894                         if(tilePass)
+00895                         {
+00896                                 // a face should have created for this pass.
+00897                                 nlassert(face->TileFaces[i]);
+00898                                 face->TileMaterial->TileFaceList[i].append(face->TileFaces[i]);
+00899                         }
+00900                 }
+00901 
+00902                 // The facelist is modified, so we must update the faceVector, if visible.
+00903                 uint    numtb= getNumTessBlock(face);
+00904                 dirtTessBlockFaceVector(TessBlocks[numtb]);
+00905 
+00906                 // Shadow: append it to the Shadow Triangles.
+00907                 getLandscape()->appendToShadowPolyReceiver(face);
+00908         }
+00909 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::appendFarVertexToRenderList CTessFarVertex fv  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1040 of file patch.cpp. +

+References addRefTessBlocks(), NL3D::CTessList< CTessFarVertex >::append(), NL3D::CTessBlock::FarVertexList, FVMasterBlock, FVTessBlockEdge, getNumTessBlock(), MasterBlock, NL3D::CTessFarVertex::OwnerBlock, NL3D::CTessFarVertex::PCoord, TessBlocks, TFarVertType, type, and uint. +

+Referenced by makeRoots(), NL3D::CTessFace::split(), and NL3D::CTessFace::splitRectangular(). +

+

01041 {
+01042         TFarVertType    type;
+01043         uint                    numtb;
+01044         getNumTessBlock(fv->PCoord, type, numtb);
+01045         
+01046         
+01047         if(type==FVMasterBlock || type==FVTessBlockEdge)
+01048         {
+01049                 fv->OwnerBlock= &MasterBlock;
+01050                 MasterBlock.FarVertexList.append(fv);
+01051         }
+01052         else 
+01053         {
+01054                 // Alloc if necessary the TessBlocks.
+01055                 addRefTessBlocks();
+01056 
+01057                 fv->OwnerBlock= &TessBlocks[numtb];
+01058                 TessBlocks[numtb].FarVertexList.append(fv);
+01059         }
+01060 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::appendNearVertexToRenderList CTileMaterial tileMat,
CTessNearVertex nv
[private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1086 of file patch.cpp. +

+References addRefTessBlocks(), computeTbTm(), nlassert, NL3D::CTessNearVertex::OwnerBlock, TessBlocks, NL3D::CTileMaterial::TileS, NL3D::CTileMaterial::TileT, and uint. +

+Referenced by NL3D::CTessFace::allocTileUv(). +

+

01087 {
+01088         nlassert(tileMat);
+01089 
+01090         // Alloc if necessary the TessBlocks.
+01091         addRefTessBlocks();
+01092 
+01093         uint    numtb, numtm;
+01094         computeTbTm(numtb, numtm, tileMat->TileS, tileMat->TileT);
+01095         nv->OwnerBlock= &TessBlocks[numtb];
+01096         TessBlocks[numtb].NearVertexList.append(nv);
+01097 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::appendTessellationLeaves std::vector< const CTessFace * > &  leaves  )  const
+
+ + + + + +
+   + + +

+From the current tesselation of this patch, append to the list of leaves faces. +

+Definition at line 2176 of file patch.cpp. +

+References NL3D::CTessFace::appendTessellationLeaves(), nlassert, Son0, and Son1. +

+Referenced by NL3D::CLandscape::getTessellationLeaves(). +

+

02177 {
+02178         nlassert(Son0);
+02179         nlassert(Son1);
+02180         Son0->appendTessellationLeaves(leaves);
+02181         Son1->appendTessellationLeaves(leaves);
+02182 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::appendTileLightInfluences const CUV uv,
std::vector< CPointLightInfluence > &  pointLightList
const
+
+ + + + + +
+   + + +

+Append lights under the position to pointLightList. Notice that the PointLight are ensured to be actually CPointLightNamed. +

+Definition at line 1543 of file patch_lightmap.cpp. +

+References NL3D::CZone::_PointLightArray, NLMISC::clamp(), NL3D::CLightInfluenceInterpolator::Corners, NL3D::CPointLightNamedArray::getPointLights(), getZone(), NL3D::CLightInfluenceInterpolator::interpolate(), NL3D::CTileLightInfluence::Light, NL3D::CLightInfluenceInterpolator::CCorner::Lights, nlassert, NLMISC::OptFastFloor(), sint, TileLightInfluences, NLMISC::CUV::U, uint, NLMISC::CUV::V, w, x, and y. +

+Referenced by NL3D::CLandscape::appendTileLightInfluences(), and generateTileVegetable(). +

+

01545 {
+01546         /*
+01547                 WARNING !! only CPointLightNamed must be added here (used for convenience by CPatch::generateTileVegetable() )
+01548         */
+01549 
+01550         // Compute TLI coord for BiLinear.
+01551         sint    x,y;
+01552         // There is (OrderS/2+1) * (OrderT/2+1) tileLightInfluences (TLI).
+01553         sint    w= (OrderS>>1);
+01554         sint    h= (OrderT>>1);
+01555         sint    wTLI= w+1;
+01556         // fastFloor: use a precision of 256 to avoid doing OptFastFloorBegin.
+01557         x= NLMISC::OptFastFloor(uv.U * (w<<8));
+01558         y= NLMISC::OptFastFloor(uv.V * (h<<8));
+01559         clamp(x, 0, w<<8);
+01560         clamp(y, 0, h<<8);
+01561         // compute the TLI coord, and the subCoord for bilinear.
+01562         sint    xTLI,yTLI, xSub, ySub;
+01563         xTLI= x>>8; clamp(xTLI, 0, w-1);
+01564         yTLI= y>>8; clamp(yTLI, 0, h-1);
+01565         // Hence, xSub and ySub range is [0, 256].
+01566         xSub= x - (xTLI<<8);
+01567         ySub= y - (yTLI<<8);
+01568 
+01569 
+01570         // Use a CLightInfluenceInterpolator to biLinear light influence
+01571         CLightInfluenceInterpolator             interp;
+01572         // Must support only 2 light per TLI.
+01573         nlassert(CTileLightInfluence::NumLightPerCorner==2);
+01574         nlassert(CLightInfluenceInterpolator::NumLightPerCorner==2);
+01575         // Get ref on array of PointLightNamed.
+01576         CPointLightNamed        *zonePointLights= NULL;
+01577         if( getZone()->_PointLightArray.getPointLights().size() >0 )
+01578         {
+01579                 // const_cast, because will only change _IdInfluence, and 
+01580                 // also because CLightingManager will call appendLightedModel()
+01581                 zonePointLights= const_cast<CPointLightNamed*>(&(getZone()->_PointLightArray.getPointLights()[0]));
+01582         }
+01583         // For 4 corners.
+01584         for(y=0;y<2;y++)
+01585         {
+01586                 for(x=0;x<2;x++)
+01587                 {
+01588                         // get ref on TLI, and on corner.
+01589                         const CTileLightInfluence                               &tli= TileLightInfluences[ (yTLI+y)*wTLI + xTLI+x ];
+01590                         CLightInfluenceInterpolator::CCorner    &corner= interp.Corners[y*2 + x];
+01591                         // For all lights
+01592                         uint lid;
+01593                         for(lid= 0; lid<CTileLightInfluence::NumLightPerCorner; lid++)
+01594                         {
+01595                                 // get the id of the light in the zone
+01596                                 uint    tliLightId= tli.Light[lid];
+01597                                 // If empty id, stop
+01598                                 if(tliLightId==0xFF)
+01599                                         break;
+01600                                 else
+01601                                 {
+01602                                         // Set pointer of the light in the corner
+01603                                         corner.Lights[lid]= zonePointLights + tliLightId;
+01604                                 }
+01605                         }
+01606                         // Reset Empty slots.
+01607                         for(; lid<CTileLightInfluence::NumLightPerCorner; lid++)
+01608                         {
+01609                                 // set to NULL
+01610                                 corner.Lights[lid]= NULL;
+01611                         }
+01612                 }
+01613         }
+01614         // interpolate.
+01615         interp.interpolate(pointLightList, xSub/256.f, ySub/256.f);
+01616 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::appendTileMaterialToRenderList CTileMaterial tm  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 955 of file patch.cpp. +

+References addRefDLMContext(), addRefTessBlocks(), NL3D::CTileAddedInfo::Center, computeTbTm(), NL3D::CTileAddedInfo::Corners, createVegetableBlock(), NL3D::CBezierPatch::eval(), NL3D::CBezierPatch::evalNormal(), getLandscape(), NL3D::CLandscape::getTileCallback(), NL3D::CLandscape::isVegetableActive(), MasterBlock, nlassert, NL3D::CTileAddedInfo::Normal, TessBlocks, NL3D::ULandscapeTileCallback::tileAdded(), NL3D::CTileAddedInfo::TileID, NL3D::CTessBlock::TileMaterialRefCount, NL3D::CTileMaterial::TileS, NL3D::CTileMaterial::TileT, uint, uint64, and unpackIntoCache(). +

+

00956 {
+00957         nlassert(tm);
+00958 
+00959         // Alloc if necessary the TessBlocks.
+00960         addRefTessBlocks();
+00961 
+00962         uint    numtb, numtm;
+00963         computeTbTm(numtb, numtm, tm->TileS, tm->TileT);
+00964         TessBlocks[numtb].RdrTileRoot[numtm]= tm;
+00965         TessBlocks[numtb].FaceTileMaterialRefCount++;
+00966         TessBlocks[numtb].TileMaterialRefCount++;
+00967         // The master block contains the whole patch TileMaterialRefCount
+00968         MasterBlock.TileMaterialRefCount++;
+00969 
+00970         // DynamicLighting. When in near, must compute the context, to have good UVs.
+00971         //==========
+00972         // inc ref to the context, creating it if needed.
+00973         addRefDLMContext();
+00974         // NB: do it before creating the vegetableBlock, because vegetables use DLM Uvs.
+00975 
+00976         // if was no tiles before in this tessBlock, create a Vegetable block.
+00977         //==========
+00978         // one Tile <=> was 0 before
+00979         if( TessBlocks[numtb].TileMaterialRefCount == 1 && getLandscape()->isVegetableActive() )
+00980         {
+00981                 createVegetableBlock(numtb, tm->TileS, tm->TileT);
+00982         }
+00983         ULandscapeTileCallback *tileCallback = getLandscape()->getTileCallback();
+00984         if (tileCallback)
+00985         {
+00986                 CBezierPatch    *bpatch= unpackIntoCache();
+00987                 CTileAddedInfo tai;
+00988                 //              
+00989                 tai.Corners[0] = bpatch->eval((float) tm->TileS / OrderS, (float) tm->TileT / OrderT);
+00990                 tai.Corners[1] = bpatch->eval((tm-> TileS + 1.f) / OrderS, (float) tm->TileT / OrderT);
+00991                 tai.Corners[2] = bpatch->eval( (tm-> TileS + 1.f) / OrderS, (tm->TileT + 1.f) / OrderT);
+00992                 tai.Corners[3] = bpatch->eval( (float) tm-> TileS / OrderS, (tm->TileT + 1.f) / OrderT);
+00993                 tai.Center = bpatch->eval( (tm-> TileS + 0.5f) / OrderS, (tm->TileT + 0.5f) / OrderT);
+00994                 //
+00995                 tai.Normal = bpatch->evalNormal( (tm-> TileS + 0.5f) / OrderS, (tm->TileT + 0.5f) / OrderT);
+00996                 tai.TileID = (uint64) tm; // pointer to tile material serves as a unique identifier
+00997                 //
+00998                 tileCallback->tileAdded(tai);
+00999         }
+01000 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CPatch::averageTesselationVertices  ) 
+
+ + + + + +
+   + + +

+This is especially for Pacs. see CLandscape desc. +

+Definition at line 1505 of file patch.cpp. +

+References NL3D::CTessFace::averageTesselationVertices(), BaseVertices, computeVertex(), NL3D::CTessVertex::EndPos, nlassert, NL3D::CTessVertex::Pos, Son0, Son1, and NL3D::CTessVertex::StartPos. +

+Referenced by NL3D::CZone::averageTesselationVertices(). +

+

01506 {
+01507         nlassert(Son0);
+01508         nlassert(Son1);
+01509 
+01510         // Recompute the BaseVertices. This is usefull for Pacs.
+01511         // Because CLandscape::averageTesselationVertices() is made on a strict order for patchs (map of zones, then 
+01512         // array of patchs), we are sure to overwrite BaseVertices in this order.
+01513         CTessVertex *a= BaseVertices[0];
+01514         CTessVertex *b= BaseVertices[1];
+01515         CTessVertex *c= BaseVertices[2];
+01516         CTessVertex *d= BaseVertices[3];
+01517         // Set positions.
+01518         a->Pos= a->StartPos= a->EndPos= computeVertex(0,0);
+01519         b->Pos= b->StartPos= b->EndPos= computeVertex(0,1);
+01520         c->Pos= c->StartPos= c->EndPos= computeVertex(1,1);
+01521         d->Pos= d->StartPos= d->EndPos= computeVertex(1,0);
+01522 
+01523 
+01524         // Average the tesselation of sons.
+01525         Son0->averageTesselationVertices();
+01526         Son1->averageTesselationVertices();
+01527 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CPatch::beginDLMLighting  ) 
+
+ + + + + +
+   + + +

+begin Dynamic light Process. reset texture To Black (if needed) Called by CLandscape. _DLMContext must exist +

+Definition at line 2005 of file patch_lightmap.cpp. +

+References _DLMContext, NL3D::CPatchDLMContext::clearLighting(), NL3D::CPatchDLMContext::CurPointLightCount, isRenderClipped(), nlassert, and NL3D::CPatchDLMContext::OldPointLightCount. +

+Referenced by NL3D::CLandscape::computeDynamicLighting(). +

+

02006 {
+02007         nlassert(_DLMContext);
+02008 
+02009         // Must bkup prec pointLightCount in OldPointLightCount, and reset CurPointLightCount
+02010         _DLMContext->OldPointLightCount= _DLMContext->CurPointLightCount;
+02011         _DLMContext->CurPointLightCount= 0;
+02012 
+02013         // clear lighting, only if patch is visible
+02014         if(!isRenderClipped())
+02015                 // NB: no-op if src is already full black.
+02016                 _DLMContext->clearLighting();
+02017 
+02018 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::bind CBindInfo  Edges[4],
bool  rebind
+
+ + + + + +
+   + + +

+bind the patch to 4 neighbors, given in this patch edge order (0,1,2,3). Tesselation is reseted (patch unbound first). NB: this patch and his neighborood must be compiled... NB: neighbor patchs must not be NULL (but according to NPatchs). +

+Definition at line 1847 of file patch.cpp. +

+References _BindZoneNeighbor, BaseVertices, bind(), NL3D::CPatchUVLocator::build(), changeEdgeNeighbor(), checkFillVertexVBFar(), NL3D::CTessFace::computeSplitPoint(), computeVertex(), NL3D::CPatch::CBindInfo::Edge, NL3D::CTessVertex::EndPos, NL3D::CTessFace::FBase, NL3D::CTessFace::FLeft, NL3D::CTessFace::FRight, NL3D::CTessFace::FVBase, NL3D::CTessFace::FVLeft, NL3D::CTessFace::FVRight, getBindNeighbor(), getRootFaceForEdge(), getRootVertexForEdge(), NL3D::CTessFace::isLeaf(), linkTessFaceWithEdge(), NL3D::CPatchUVLocator::locateUV(), NL3D::CPatch::CBindInfo::Next, nlassert, NL3D::CPatch::CBindInfo::NPatchs, OrderS, OrderT, NL3D::CTessVertex::Pos, NL3D::CPatchUVLocator::selectPatch(), NLMISC::CVector2f::set(), sint, Son0, Son1, NL3D::CTessFace::SonLeft, NL3D::CTessFace::SonRight, NL3D::CTessVertex::StartPos, uint, NL3D::CTessFace::updateBind(), NL3D::CTessFace::VBase, NLMISC::CVector2f::x, NLMISC::CVector2f::y, and NL3D::CPatch::CBindInfo::Zone. +

+Referenced by bind(), and NL3D::CZone::bindPatch(). +

+

01848 {
+01849         // The multiple Patch Face.
+01850         // By default, Patch==NULL, FLeft, FRight and FBase==NULL so ok!
+01851         static  CTessFace       bind1_2[4];
+01852         static  CTessFace       bind1_4[8];
+01853 
+01854 
+01855         // THIS PATCH MUST BE UNBOUND FIRST!!!!!
+01856         nlassert(Son0 && Son1);
+01857         nlassert(Son0->isLeaf() && Son1->isLeaf());
+01858         nlassert(Son0->FLeft == NULL);
+01859         nlassert(Son0->FRight == NULL);
+01860         nlassert(Son1->FLeft == NULL);
+01861         nlassert(Son1->FRight == NULL);
+01862 
+01863 
+01864         // bind the Realtime bind info here (before any computeVertex, and before bind too).
+01865         sint    i;
+01866         for(i=0;i<4;i++)
+01867         {
+01868                 // just Copy zone (if not NULL).
+01869                 _BindZoneNeighbor[i]= Edges[i].Zone;
+01870         }
+01871 
+01872 
+01873         if(!rebind)
+01874         {
+01875                 // Just recompute base vertices.
+01876                 CTessVertex *a= BaseVertices[0];
+01877                 CTessVertex *b= BaseVertices[1];
+01878                 CTessVertex *c= BaseVertices[2];
+01879                 CTessVertex *d= BaseVertices[3];
+01880                 // Set positions.
+01881                 a->Pos= a->StartPos= a->EndPos= computeVertex(0,0);
+01882                 b->Pos= b->StartPos= b->EndPos= computeVertex(0,1);
+01883                 c->Pos= c->StartPos= c->EndPos= computeVertex(1,1);
+01884                 d->Pos= d->StartPos= d->EndPos= computeVertex(1,0);
+01885                 // NB: no propagation problem, since the patch has root only (since has to be unbound!!!)
+01886                 // Recompute centers.
+01887                 Son0->computeSplitPoint();
+01888                 Son1->computeSplitPoint();
+01889         }
+01890         else
+01891         {
+01892                 // Keep old Vertices as computed from neighbors, but reFill the 4 FarVertices.
+01893                 // NB: don't do it on NearVertices because suppose that Near is Off when a bind occurs (often far away).
+01894                 checkFillVertexVBFar(Son0->FVBase);
+01895                 checkFillVertexVBFar(Son0->FVLeft);
+01896                 checkFillVertexVBFar(Son0->FVRight);
+01897                 checkFillVertexVBFar(Son1->FVBase);
+01898         }
+01899 
+01900 
+01901         // Bind the roots.
+01902         for(i=0;i<4;i++)
+01903         {
+01904                 CBindInfo       &bind= Edges[i];
+01905 
+01906                 nlassert(bind.NPatchs==0 || bind.NPatchs==1 || bind.NPatchs==2 || bind.NPatchs==4 || bind.NPatchs==5);
+01907                 if(bind.NPatchs==1)
+01908                 {
+01909                         // Bind me on Next.
+01910                         this->changeEdgeNeighbor(i, bind.Next[0]->getRootFaceForEdge(bind.Edge[0]));
+01911                         // Bind Next on me.
+01912                         bind.Next[0]->changeEdgeNeighbor(bind.Edge[0], this->getRootFaceForEdge(i));
+01913                 }
+01914                 else if(bind.NPatchs==2)
+01915                 {
+01916                         // Setup multiple bind.
+01917                         this->changeEdgeNeighbor(i, bind1_2+i);
+01918                         bind1_2[i].FBase= this->getRootFaceForEdge(i);
+01919                         // Setup the multiple face.
+01920                         // Follow the conventions! Make a draw for understand. Small Patchs are numbered in CCW.
+01921                         bind1_2[i].SonRight= bind.Next[0]->getRootFaceForEdge(bind.Edge[0]);
+01922                         bind1_2[i].SonLeft= bind.Next[1]->getRootFaceForEdge(bind.Edge[1]);
+01923                         bind1_2[i].VBase= bind.Next[0]->getRootVertexForEdge(bind.Edge[0]);
+01924                         // Set a "flag" to neighbors, so they know what edge is to be bind on me.
+01925                         bind.Next[0]->changeEdgeNeighbor(bind.Edge[0], &CTessFace::MultipleBindFace);
+01926                         bind.Next[1]->changeEdgeNeighbor(bind.Edge[1], &CTessFace::MultipleBindFace);
+01927                 }
+01928                 else if(bind.NPatchs==4)
+01929                 {
+01930                         // Setup multiple bind level 0.
+01931                         this->changeEdgeNeighbor(i, bind1_2+i);
+01932                         bind1_2[i].FBase= this->getRootFaceForEdge(i);
+01933 
+01934                         // Setup multiple bind level 1.
+01935                         // Follow the conventions! Make a draw for understand. Small Patchs are numbered in CCW.
+01936                         bind1_2[i].SonRight= bind1_4 + 2*i+0;
+01937                         bind1_2[i].SonLeft= bind1_4 + 2*i+1;
+01938                         bind1_2[i].VBase= bind.Next[1]->getRootVertexForEdge(bind.Edge[1]);
+01939                         // Make first multiple face bind level1.
+01940                         bind1_4[2*i+0].FBase= &CTessFace::MultipleBindFace;     // to link correctly when the root face will be splitted.
+01941                         bind1_4[2*i+0].SonRight= bind.Next[0]->getRootFaceForEdge(bind.Edge[0]);
+01942                         bind1_4[2*i+0].SonLeft= bind.Next[1]->getRootFaceForEdge(bind.Edge[1]);
+01943                         bind1_4[2*i+0].VBase= bind.Next[0]->getRootVertexForEdge(bind.Edge[0]);
+01944                         // Make second multiple face bind level1.
+01945                         bind1_4[2*i+1].FBase= &CTessFace::MultipleBindFace;     // to link correctly when the root face will be splitted.
+01946                         bind1_4[2*i+1].SonRight= bind.Next[2]->getRootFaceForEdge(bind.Edge[2]);
+01947                         bind1_4[2*i+1].SonLeft= bind.Next[3]->getRootFaceForEdge(bind.Edge[3]);
+01948                         bind1_4[2*i+1].VBase= bind.Next[2]->getRootVertexForEdge(bind.Edge[2]);
+01949 
+01950                         // Set a "flag" to neighbors, so they know what edge is to be bind on me.
+01951                         bind.Next[0]->changeEdgeNeighbor(bind.Edge[0], &CTessFace::MultipleBindFace);
+01952                         bind.Next[1]->changeEdgeNeighbor(bind.Edge[1], &CTessFace::MultipleBindFace);
+01953                         bind.Next[2]->changeEdgeNeighbor(bind.Edge[2], &CTessFace::MultipleBindFace);
+01954                         bind.Next[3]->changeEdgeNeighbor(bind.Edge[3], &CTessFace::MultipleBindFace);
+01955                 }
+01956                 else if(bind.NPatchs==5)
+01957                 {
+01958                         /* I am binded to a bigger patch and this one has already done the binding on me => 
+01959                                 It must be correclty tesselated. Note also that bind 1/X are only possible on interior of zone.
+01960                         */
+01961 
+01962                         // First, make the link with the face to which I must connect.
+01963                         // -----------------
+01964 
+01965                         // Get the coordinate of the current edge of this patch
+01966                         CVector2f       uvi0, uvi1;
+01967                         switch(i)
+01968                         {
+01969                         case 0: uvi0.set(0,0); uvi1.set(0,1);  break;
+01970                         case 1: uvi0.set(0,1); uvi1.set(1,1);  break;
+01971                         case 2: uvi0.set(1,1); uvi1.set(1,0);  break;
+01972                         case 3: uvi0.set(1,0); uvi1.set(0,0);  break;
+01973                         };
+01974                         // mul by OrderS/OrderT for CPatchUVLocator
+01975                         uvi0.x*= OrderS;
+01976                         uvi0.y*= OrderT;
+01977                         uvi1.x*= OrderS;
+01978                         uvi1.y*= OrderT;
+01979                         // build a CPatchUVLocator to transpose coorindate ot this edge in coordinate on the bigger Neighbor patch.
+01980                         CBindInfo       bindInfo;
+01981                         getBindNeighbor(i, bindInfo);
+01982                         nlassert(bindInfo.Zone!=NULL && bindInfo.NPatchs==1);
+01983                         CPatchUVLocator         puvloc;
+01984                         puvloc.build(this, i, bindInfo);
+01985 
+01986                         // transpose from this patch coord in neighbor patch coord.
+01987                         CVector2f       uvo0, uvo1;
+01988                         uint    pid;
+01989                         CPatch  *patchNeighbor;
+01990                         // Do it for uvi0
+01991                         pid= puvloc.selectPatch(uvi0);
+01992                         puvloc.locateUV(uvi0, pid, patchNeighbor, uvo0);
+01993                         nlassert(patchNeighbor == bindInfo.Next[0]);
+01994                         // Do it for uvi1
+01995                         pid= puvloc.selectPatch(uvi1);
+01996                         puvloc.locateUV(uvi1, pid, patchNeighbor, uvo1);
+01997                         nlassert(patchNeighbor == bindInfo.Next[0]);
+01998                         // Rescale to have uv in 0,1 basis.
+01999                         uvo0.x/= patchNeighbor->OrderS;
+02000                         uvo0.y/= patchNeighbor->OrderT;
+02001                         uvo1.x/= patchNeighbor->OrderS;
+02002                         uvo1.y/= patchNeighbor->OrderT;
+02003 
+02004                         // Now, traverse the tesselation and find the first CTessFace which use this edge.
+02005                         CTessFace       *faceNeighbor;
+02006                         faceNeighbor= patchNeighbor->linkTessFaceWithEdge(uvo0, uvo1, this->getRootFaceForEdge(i));
+02007                         nlassert(faceNeighbor);
+02008                         // Bind me on Next.
+02009                         this->changeEdgeNeighbor(i, faceNeighbor);
+02010                 }
+02011 
+02012         }
+02013 
+02014         // Propagate the binds to sons.
+02015         Son0->updateBind();
+02016         Son1->updateBind();
+02017 
+02018 }
+
+

+ + + + +
+ + + + + + + + + +
CAABBox NL3D::CPatch::buildBBox  )  const
+
+ + + + + +
+   + + +

+Build the bbox of the patch, according to ctrl points, and displacement map max value. +

+ +

+Definition at line 257 of file patch.cpp. +

+References buildBBoxFromBezierPatch(), and unpackIntoCache(). +

+Referenced by NL3D::CLandscape::addZone(), and NL3D::CZone::compile(). +

+

00258 {
+00259         CBezierPatch    &p= *unpackIntoCache();
+00260 
+00261         // Compute Bounding Box. (easiest way...)
+00262         CAABBox         ret;
+00263         buildBBoxFromBezierPatch(p, ret);
+00264 
+00265         return ret;
+00266 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::buildBBoxFromBezierPatch const CBezierPatch p,
CAABBox ret
const [private]
+
+ + + + + +
+   + + +

+build a bbox from the convex hull of a bezier patch, enlarged with noise. +

+ +

+Definition at line 221 of file patch.cpp. +

+References NL3D::CBezierPatch::Interiors, NLMISC::CVector::maxof(), NLMISC::CVector::minof(), NL3D_NOISE_MAX, NLMISC::CAABBox::setMinMax(), sint, NL3D::CBezierPatch::Tangents, and NL3D::CBezierPatch::Vertices. +

+Referenced by addPatchBlocksInBBoxRecurs(), addTrianglesInBBoxRecurs(), and buildBBox(). +

+

00222 {
+00223         // Because of the structure of CAABBox, extend() is not fast enough for us. first compute bmin, bmax,
+00224         // then compute the bbox.
+00225         CVector         bmin= p.Vertices[0];
+00226         CVector         bmax= bmin; 
+00227 
+00228         sint                    i;
+00229         for(i=0;i<4;i++)
+00230         {
+00231                 bmin.minof(bmin, p.Vertices[i]);
+00232                 bmax.maxof(bmax, p.Vertices[i]);
+00233         }
+00234         for(i=0;i<8;i++)
+00235         {
+00236                 bmin.minof(bmin, p.Tangents[i]);
+00237                 bmax.maxof(bmax, p.Tangents[i]);
+00238         }
+00239         for(i=0;i<4;i++)
+00240         {
+00241                 bmin.minof(bmin, p.Interiors[i]);
+00242                 bmax.maxof(bmax, p.Interiors[i]);
+00243         }
+00244 
+00245         // Modulate with the maximum displacement map (usefull for patch clipping).
+00246         static  CVector         vectorNoiseMax(NL3D_NOISE_MAX, NL3D_NOISE_MAX, NL3D_NOISE_MAX);
+00247         bmin-= vectorNoiseMax;
+00248         bmax+= vectorNoiseMax;
+00249         // NB: this is not very optimal, since the BBox may be very too big. eg: patch 16mx16m => bbox 18mx18m.
+00250         // But remind that tessblocks do not use this BBox, and are computed with the real geometry.
+00251 
+00252         ret.setMinMax(bmin, bmax);
+00253 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::changeEdgeNeighbor sint  edge,
CTessFace to
[private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1805 of file patch.cpp. +

+References NL3D::CTessFace::FLeft, NL3D::CTessFace::FRight, nlassert, sint, Son0, and Son1. +

+Referenced by bind(). +

+

01806 {
+01807         nlassert(edge>=0 && edge<=3);
+01808 
+01809         // See tessellation rules.
+01810         if(OrderS>=OrderT)
+01811         {
+01812                 switch(edge)
+01813                 {
+01814                         case 0: Son0->FRight= to; break;
+01815                         case 1: Son0->FLeft= to; break;
+01816                         case 2: Son1->FRight= to; break;
+01817                         case 3: Son1->FLeft= to; break;
+01818                 }
+01819         }
+01820         else
+01821         {
+01822                 switch(edge)
+01823                 {
+01824                         case 0: Son0->FLeft= to; break;
+01825                         case 1: Son1->FRight= to; break;
+01826                         case 2: Son1->FLeft= to; break;
+01827                         case 3: Son0->FRight= to; break;
+01828                 }
+01829         }
+01830 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::checkCreateVertexVBFar CTessFarVertex pVert  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1502 of file patch_render.cpp. +

+References NL3D::CTessFarVertex::Index0, NL3D::CTessFarVertex::Index1, isRenderClipped(), nlassert, NL3D::CTessFarVertex::OwnerBlock, NL3D::CTessBlock::visibleFar0(), and NL3D::CTessBlock::visibleFar1(). +

+Referenced by NL3D::CTessFace::split(), and NL3D::CTessFace::splitRectangular(). +

+

01503 {
+01504         nlassert(pVert);
+01505         // If visible, and Far0 in !Tile Mode, allocate.
+01506         // NB: must test Far0>0 because vertices are reallocated in preRender() if a change of Far occurs.
+01507         if(!isRenderClipped() && Far0>0 && pVert->OwnerBlock->visibleFar0() )
+01508         {
+01509                 pVert->Index0= CLandscapeGlobals::CurrentFar0VBAllocator->allocateVertex();
+01510         }
+01511 
+01512         // Idem for Far1
+01513         if(!isRenderClipped() && Far1>0 && pVert->OwnerBlock->visibleFar1())
+01514         {
+01515                 pVert->Index1= CLandscapeGlobals::CurrentFar1VBAllocator->allocateVertex();
+01516         }
+01517 
+01518 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::checkCreateVertexVBNear CTessNearVertex pVert  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1543 of file patch_render.cpp. +

+References NL3D::CTessNearVertex::Index, isRenderClipped(), nlassert, NL3D::CTessNearVertex::OwnerBlock, and NL3D::CTessBlock::visibleTile(). +

+Referenced by NL3D::CTessFace::checkCreateFillTileVB(). +

+

01544 {
+01545         nlassert(pVert);
+01546         // If visible, and Far0 in Tile Mode, allocate.
+01547         // NB: must test Far0==0 because vertices are reallocated in preRender() if a change of Far occurs.
+01548         if(!isRenderClipped() && Far0==0 && pVert->OwnerBlock->visibleTile())
+01549         {
+01550                 pVert->Index= CLandscapeGlobals::CurrentTileVBAllocator->allocateVertex();
+01551         }
+01552 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::checkDeleteVertexVBFar CTessFarVertex pVert  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1571 of file patch_render.cpp. +

+References NL3D::CTessFarVertex::Index0, NL3D::CTessFarVertex::Index1, isRenderClipped(), nlassert, NL3D::CTessFarVertex::OwnerBlock, NL3D::CTessBlock::visibleFar0(), and NL3D::CTessBlock::visibleFar1(). +

+Referenced by NL3D::CTessFace::doMerge(). +

+

01572 {
+01573         nlassert(pVert);
+01574         // If visible, and Far0 in !Tile Mode, ok, the vertex exist in VB, so delete.
+01575         // NB: must test Far0>0 because vertices are deleted in preRender() if a change of Far occurs.
+01576         if(!isRenderClipped() && Far0>0 && pVert->OwnerBlock->visibleFar0() )
+01577         {
+01578                 CLandscapeGlobals::CurrentFar0VBAllocator->deleteVertex(pVert->Index0);
+01579         }
+01580 
+01581         // Idem for Far1
+01582         if(!isRenderClipped() && Far1>0  && pVert->OwnerBlock->visibleFar1() )
+01583         {
+01584                 CLandscapeGlobals::CurrentFar1VBAllocator->deleteVertex(pVert->Index1);
+01585         }
+01586 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::checkDeleteVertexVBNear CTessNearVertex pVert  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1589 of file patch_render.cpp. +

+References NL3D::CTessNearVertex::Index, isRenderClipped(), nlassert, NL3D::CTessNearVertex::OwnerBlock, and NL3D::CTessBlock::visibleTile(). +

+Referenced by NL3D::CTessFace::deleteTileUv(). +

+

01590 {
+01591         nlassert(pVert);
+01592         // If visible, and Far0 in Tile Mode, ok, the vertex exist in VB, so delete.
+01593         // NB: must test Far0==0 because vertices are deleted in preRender() if a change of Far occurs.
+01594         if(!isRenderClipped() && Far0==0 && pVert->OwnerBlock->visibleTile() )
+01595         {
+01596                 CLandscapeGlobals::CurrentTileVBAllocator->deleteVertex(pVert->Index);
+01597         }
+01598 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::checkFillVertexVBFar CTessFarVertex pVert  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1522 of file patch_render.cpp. +

+References fillFar0VertexVB(), fillFar1VertexVB(), isRenderClipped(), nlassert, NL3D::CTessFarVertex::OwnerBlock, NL3D::CTessBlock::visibleFar0(), and NL3D::CTessBlock::visibleFar1(). +

+Referenced by bind(), NL3D::CTessFace::split(), NL3D::CTessFace::splitRectangular(), and NL3D::CTessFace::updateNearFarVertices(). +

+

01523 {
+01524         nlassert(pVert);
+01525         // If visible, and Far0 in !Tile Mode, try to fill.
+01526         // NB: must test Far0>0 because vertices are reallocated in preRender() if a change of Far occurs.
+01527         if(!isRenderClipped() && Far0>0 && pVert->OwnerBlock->visibleFar0())
+01528         {
+01529                 if( !CLandscapeGlobals::CurrentFar0VBAllocator->reallocationOccurs() )
+01530                         fillFar0VertexVB(pVert);
+01531         }
+01532 
+01533         // Idem for Far1
+01534         if(!isRenderClipped() && Far1>0 && pVert->OwnerBlock->visibleFar1())
+01535         {
+01536                 if( !CLandscapeGlobals::CurrentFar1VBAllocator->reallocationOccurs() )
+01537                         fillFar1VertexVB(pVert);
+01538         }
+01539 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::checkFillVertexVBNear CTessNearVertex pVert  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1556 of file patch_render.cpp. +

+References fillTileVertexVB(), isRenderClipped(), nlassert, NL3D::CTessNearVertex::OwnerBlock, and NL3D::CTessBlock::visibleTile(). +

+Referenced by NL3D::CTessFace::checkCreateFillTileVB(), NL3D::CTessFace::checkFillTileVB(), and NL3D::CTessFace::updateNearFarVertices(). +

+

01557 {
+01558         nlassert(pVert);
+01559         // If visible, and Far0 in Tile Mode, try to fill.
+01560         // NB: must test Far0==0 because vertices are reallocated in preRender() if a change of Far occurs.
+01561         if(!isRenderClipped()&& Far0==0 && pVert->OwnerBlock->visibleTile() )
+01562         {
+01563                 // try to fill.
+01564                 if( !CLandscapeGlobals::CurrentTileVBAllocator->reallocationOccurs() )
+01565                         fillTileVertexVB(pVert);
+01566         }
+01567 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CPatch::clearTessBlocks  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 669 of file patch.cpp. +

+References NL3D::CLandscape::_VegetableManager, deleteAllVegetableIgs(), NL3D::CVegetableManager::deleteClipBlock(), getLandscape(), TessBlockRefCount, TessBlocks, uint, NL3D::CLandscape::unlinkPatchFromNearUL(), and VegetableClipBlocks. +

+Referenced by decRefTessBlocks(), makeRoots(), and release(). +

+

00670 {
+00671         uint    i;
+00672 
+00673         // Vegetable management
+00674         //==========
+00675         // if compiled.
+00676         if(Zone)
+00677         {
+00678                 CVegetableManager       *vegetableManager= getLandscape()->_VegetableManager;
+00679 
+00680                 // delete still existing vegetable Igs.
+00681                 deleteAllVegetableIgs();
+00682 
+00683                 // delete ClipBlocks.
+00684                 for(i=0; i<VegetableClipBlocks.size(); i++)
+00685                 {
+00686                         vegetableManager->deleteClipBlock(VegetableClipBlocks[i]);
+00687                 }
+00688                 contReset(VegetableClipBlocks);
+00689         }
+00690 
+00691 
+00692         // updateLighting management.
+00693         //==========
+00694         if(Zone)
+00695         {
+00696                 // remove patch from Near updateLighting, since no more TessBlock lightmap can exist.
+00697                 getLandscape()->unlinkPatchFromNearUL(this);
+00698         }
+00699 
+00700 
+00701         // Delete TessBlocks
+00702         //==========
+00703         TessBlockRefCount=0;
+00704         contReset(TessBlocks);
+00705 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::compile CZone z,
uint  patchId,
uint8  orderS,
uint8  orderT,
CTessVertex baseVertices[4],
float  errorSize = 0
+
+ + + + + +
+   + + +

+compile a valid patch. (init) Call this method before any other. Zone and Control points must be valid before calling compile().
+ This is an ERROR to call compile() two times.
+

Parameters:
+ + + + + +
z zone where the patch must be binded.
orderS the Tile order in S direction: 2,4,8,16.
orderT the Tile order in T direction: 2,4,8,16.
errorSize if 0, setup() compute himself the errormetric of the patch. May be setup to surface of patch, modulated by tangents and displacement map.
+
+ +

+Definition at line 1283 of file patch.cpp. +

+References _ULNearNext, _ULNearPrec, BaseVertices, computeDefaultErrorSize(), ErrorSize, NLMISC::getPowerOf2(), NL3D::CTessBlock::init(), makeRoots(), MasterBlock, min, nlassert, sint, SquareLimitLevel, TessBlockLimitLevel, TileLimitLevel, uint, uint16, uint8, and z. +

+Referenced by NL3D::CZone::compile(). +

+

01284 {
+01285         nlassert(z);
+01286         Zone= z;
+01287 
+01288         // For updateLighting, get the correct pointer now.
+01289         // Init UL circular list to me
+01290         _ULNearPrec= this;
+01291         _ULNearNext= this;
+01292 
+01293 
+01294         // Once the patch is inserted and compiled in a zone, it is ready to be rendered.
+01295         // init the MasterBlock.
+01296         MasterBlock.init(this);
+01297 
+01298         // only 65536 patch per zone allowed.
+01299         nlassert(patchId<0x10000);
+01300         PatchId= (uint16)patchId;
+01301 
+01302         if(errorSize==0)
+01303                 computeDefaultErrorSize();
+01304         else
+01305                 ErrorSize= errorSize;
+01306 
+01307         nlassert(orderS==2 || orderS==4 || orderS==8 || orderS==16);
+01308         nlassert(orderT==2 || orderT==4 || orderT==8 || orderT==16);
+01309         nlassert (OrderS==orderS);
+01310         nlassert (OrderT==orderT);
+01311 
+01312         // Compile additional infos.
+01313         sint    ps= getPowerOf2(orderS) , pt= getPowerOf2(orderT);
+01314         sint    pmin= min(ps,pt);
+01315         sint    pmax= max(ps,pt);
+01316         // Rectangular patch OK.
+01317         // Work, since patch 1xX are illegal. => The TileLimitLevel is at least 2 level distant from the time where
+01318         // the rectangular patch is said "un-rectangular-ed" (tesselation looks like square). Hence, there is no problem
+01319         // with rectangular UV geomorph (well don't bother me, make a draw :) ).
+01320         TileLimitLevel= pmin*2 + pmax-pmin;
+01321         // A TessBlock is a 2*2 tile. This simple formula works because patch 1xX are illegal.
+01322         TessBlockLimitLevel= TileLimitLevel-2;
+01323         // This tell us when the tess face is "un-rectangular-ed" (to say a square). Before, it is a "rectangular" face, 
+01324         // which has a strange fxxxxxg split.
+01325         // If patch is square, then SquareLimitLevel=0 (ok!!).
+01326         SquareLimitLevel= pmax-pmin;
+01327 
+01328         // Bind vertices, to zone base vertices.
+01329         BaseVertices[0]= baseVertices[0];
+01330         BaseVertices[1]= baseVertices[1];
+01331         BaseVertices[2]= baseVertices[2];
+01332         BaseVertices[3]= baseVertices[3];
+01333 
+01334         // build Sons.
+01335         makeRoots();
+01336 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
CVector NL3D::CPatch::computeContinousVertex float  s,
float  t
const
+
+ + + + + +
+   + + +

+Same as computeVertex, but special accurate version for CVisualCollisionEntity. If on a corner of the patch (0,0), (0,1) ...., take directly the BaseVertices[] result if on a border of a patch (ie s==0, s==1, t==0 or t==1), also compute the vertex of the neighbor patch (if any), and then average the result. This ensure that tesselation generated is perfectly continous, even across patchs of same or different zones. This feature is very important for CVisualCollisionEntity::snapToGround() +

+Definition at line 1363 of file patch.cpp. +

+References BaseVertices, NL3D::CPatchUVLocator::build(), computeVertex(), computeVertexButCorner(), NL3D::CTessVertex::EndPos, getBindNeighbor(), getOrderS(), getOrderT(), NL3D::CPatchUVLocator::locateUV(), nlassert, nlstop, s, NL3D::CPatchUVLocator::selectPatch(), sint, t, uint, NLMISC::CVector2f::x, NLMISC::CVector2f::y, and NL3D::CPatch::CBindInfo::Zone. +

+

01364 {
+01365         // must be compiled
+01366         nlassert(Zone);
+01367 
+01368         // Test is on a edge/corner of the patch
+01369         sint    edgeIdS= -1;
+01370         sint    edgeIdT= -1;
+01371         if(s==0)                edgeIdS= 0;
+01372         else if(s==1)   edgeIdS= 2;
+01373         if(t==0)                edgeIdT= 3;
+01374         else if(t==1)   edgeIdT= 1;
+01375 
+01376         // test if on a corner
+01377         if(edgeIdS>=0 && edgeIdT>=0)
+01378         {
+01379                 // return the baseVertex according to edge falgs
+01380                 if(edgeIdS==0 && edgeIdT==3)    return BaseVertices[0]->EndPos;
+01381                 if(edgeIdS==0 && edgeIdT==1)    return BaseVertices[1]->EndPos;
+01382                 if(edgeIdS==2 && edgeIdT==1)    return BaseVertices[2]->EndPos;
+01383                 if(edgeIdS==2 && edgeIdT==3)    return BaseVertices[3]->EndPos;
+01384                 nlstop;
+01385                 // Error, but Avoid warning
+01386                 return CVector::Null;
+01387         }
+01388         // test if on an edge
+01389         else if(edgeIdS>=0 || edgeIdT>=0)
+01390         {
+01391                 // Yes, must compute myslef
+01392                 CVector         vertexOnMe= computeVertex(s,t);
+01393 
+01394                 // Then, must compute my neighbor.
+01395                 sint    edgeId;
+01396                 if(edgeIdS>=0)
+01397                         edgeId= edgeIdS;
+01398                 else
+01399                         edgeId= edgeIdT;
+01400 
+01401                 // Get my neighbor, if any.
+01402                 CBindInfo       bindInfo;
+01403                 getBindNeighbor(edgeId, bindInfo);
+01404                 // Fast reject: if no neighbor on the edge, just return my pos.
+01405                 if(!bindInfo.Zone)
+01406                 {
+01407                         return vertexOnMe;
+01408                 }
+01409                 // else must get vertex pos of my neighbor, and average.
+01410                 else
+01411                 {
+01412                         // use a CPatchUVLocator to get UV in neighbor patch
+01413                         CPatchUVLocator         uvLocator;
+01414                         uvLocator.build(this, edgeId, bindInfo);
+01415 
+01416                         // UVlocator use OrderS/OrderT coordinate system.
+01417                         CVector2f       stTileIn, stTileOut;
+01418                         stTileIn.x= s * getOrderS();
+01419                         stTileIn.y= t * getOrderT();
+01420 
+01421                         // transform coordinate to get into the neigbhor patch
+01422                         uint    pid= uvLocator.selectPatch(stTileIn);
+01423                         CPatch  *nebPatch;
+01424                         uvLocator.locateUV(stTileIn, pid, nebPatch, stTileOut);
+01425 
+01426                         // transform neigbhor coord in 0..1 coordinate space.
+01427                         stTileOut.x/= nebPatch->getOrderS();
+01428                         stTileOut.y/= nebPatch->getOrderT();
+01429 
+01430                         // and compute vertex. NB: if binded on 2 or 4 patch, it is then possible that stTileOut is on a
+01431                         // a corner ( (0,0), (0,1) ...).
+01432                         // In this case, we must use the precomputed Vertex pos, for completeness.
+01433                         bool            onCorner;
+01434                         CVector         vertexOnNeb= nebPatch->computeVertexButCorner(stTileOut.x, stTileOut.y, onCorner);
+01435 
+01436                         // If the neighbor is on a corner, then use its corner value.
+01437                         if(onCorner)
+01438                                 return vertexOnNeb;
+01439                         else
+01440                         {
+01441                                 // Average the 2 and return this result.
+01442                                 vertexOnMe+= vertexOnNeb;
+01443                                 vertexOnMe/= 2;
+01444                                 return vertexOnMe;
+01445                         }
+01446                 }
+01447 
+01448         }
+01449         // else, std case
+01450         else
+01451                 return computeVertex(s, t);
+01452 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::computeCurrentTLILightmapDiv2 NLMISC::CRGBA array  )  const
+
+ + + + + +
+   + + +

+For CTextureFar, compute current TLI Lightmap at tile level. array should be allocated of at least sqr(NL_MAX_TILES_BY_PATCH_EDGE+1). +

+Definition at line 1805 of file patch_lightmap.cpp. +

+References NLMISC::CRGBA::B, NLMISC::CRGBA::G, NLMISC::CRGBA::R, uint, x, and y. +

+Referenced by NL3D::CTextureFar::rebuildPatch(). +

+

01806 {
+01807         // Size of TileLightInfluences
+01808         uint    wTLI= (OrderS>>1)+1;
+01809         uint    hTLI= (OrderT>>1)+1;
+01810         // colros at corners of tiles size.
+01811         uint    wTC= OrderS+1;
+01812         uint    wTCx2= wTC*2;
+01813         uint    hTC= OrderT+1;
+01814         uint    x, y;
+01815 
+01816         // Compute TLI colors at each corner of each TessBlocks.
+01817         //=============
+01818         for(y=0;y<hTLI;y++)
+01819         {
+01820                 // store every 2 tiles corners.
+01821                 CRGBA   *dst= array + y*2*wTC;
+01822                 for(x=0;x<wTLI;x++)
+01823                 {
+01824                         *dst= getCurrentTLIColor(x, y);
+01825                         dst->R >>= 1;
+01826                         dst->G >>= 1;
+01827                         dst->B >>= 1;
+01828                         // skip 2 tiles corners.
+01829                         dst++;
+01830                         dst++;
+01831                 }
+01832         }
+01833 
+01834         // Compute TLI colors at each corner of each Tiles.
+01835         //=============
+01836 
+01837         // Compute corner at middle of vertical TessBlock edges.
+01838         for(y=0;y<hTC-1;y+=2)
+01839         {
+01840                 CRGBA   *dst= array + y*wTC;
+01841                 for(x=0;x<wTC;x+=2)
+01842                 {
+01843                         // Average midlle with cur and next.
+01844                         (dst+wTC)->avg2RGBOnly(*dst, *(dst + wTCx2) );
+01845 
+01846                         // skip 2 tiles corners.
+01847                         dst++;
+01848                         dst++;
+01849                 }
+01850         }
+01851 
+01852         // Compute corner at middle of horizontal TessBlock edges, and at middle of TessBlock.
+01853         for(y=0;y<hTC;y++)
+01854         {
+01855                 CRGBA   *dst= array + y*wTC;
+01856                 for(x=0;x<wTC-1;x+=2)
+01857                 {
+01858                         // Average midlle with cur and next.
+01859                         (dst+1)->avg2RGBOnly(*dst, *(dst+2));
+01860 
+01861                         // skip 2 tiles corners.
+01862                         dst++;
+01863                         dst++;
+01864                 }
+01865         }
+01866 
+01867 
+01868 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CPatch::computeDefaultErrorSize  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 206 of file patch.cpp. +

+References ErrorSize, unpackIntoCache(), and NL3D::CBezierPatch::Vertices. +

+Referenced by compile(). +

+

00207 {
+00208         CBezierPatch    &p= *unpackIntoCache();
+00209         CVector                 &v0= p.Vertices[0];
+00210         CVector                 &v1= p.Vertices[1];
+00211         CVector                 &v2= p.Vertices[2];
+00212 
+00213         // \todo yoyo: TODO_NOISE: modulate this value with tangents (roundiness of patch), and with the displacement map.
+00214         ErrorSize= ((v1 - v0)^(v2 - v0)).norm();
+00215 
+00216 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
float NL3D::CPatch::computeDisplaceCornerSmooth float  s,
float  t,
sint8  smoothBorderX,
sint8  smoothBorderY
const [private]
+
+ + + + + +
+   + + +

+compute the smoothed displacement for s,t ([0;OrderS], [0;OrderT]). Special case on corner. +

+Definition at line 471 of file patch_noise.cpp. +

+References NL3D::CPatchUVLocator::build(), NL3D::computeDisplaceBilinear(), computeDisplaceInteriorSmooth(), computeDisplaceRaw(), computeDisplaceRawOnNeighbor(), getBindNeighbor(), NL3D::CPatchUVLocator::locateUV(), nlassert, nlstop, NL3D::noiseFloor(), s, NL3D::CPatchUVLocator::selectPatch(), NLMISC::CVector2f::set(), sint8, t, uint, NLMISC::CVector2f::x, NLMISC::CVector2f::y, and NL3D::CPatch::CBindInfo::Zone. +

+Referenced by computeNoise(). +

+

00472 {
+00473         // compute the value across the corner (enjoy!!)
+00474         // NB: Only corners with Edges==4 and corners on a bind are correclty supported.
+00475         // ignore problems with corner which nbEdges!=4, because Blend of normals blend to 0 on corner (see computenoise()).
+00476 
+00477         float sTile= s;
+00478         float tTile= t;
+00479         CBindInfo       bindInfoX;
+00480         CBindInfo       bindInfoY;
+00481         uint            edgeX=0;
+00482         uint            edgeY=0;
+00483 
+00484         // both must be not null
+00485         nlassert( (smoothBorderX!=0) && (smoothBorderY!=0) );
+00486 
+00487 
+00488         // Get the edge against we must share displace.
+00489         if(smoothBorderX==-1)   edgeX=0;
+00490         else if(smoothBorderX==1)       edgeX=2;
+00491         else nlstop;
+00492         if(smoothBorderY==1)    edgeY=1;
+00493         else if(smoothBorderY==-1)      edgeY=3;
+00494         else nlstop;
+00495 
+00496         // Build the bindInfo against those 2 edge.
+00497         getBindNeighbor(edgeX, bindInfoX);
+00498         getBindNeighbor(edgeY, bindInfoY);
+00499 
+00500         // Fast reject: if no neighbor on one of the edge, just do a simple computeDisplaceInteriorSmooth.
+00501         if(!bindInfoX.Zone || !bindInfoY.Zone)
+00502                 return computeDisplaceInteriorSmooth(s, t);
+00503         else
+00504         {
+00505                 float   ret;
+00506 
+00507 
+00508                 // compute bi-linear weight factors.
+00509                 float   sInc, tInc, sa, ta, sa1, ta1;
+00510                 computeDisplaceBilinear(sTile, tTile, sInc, tInc, sa, ta, sa1, ta1);
+00511                 // Manage limit case: if bilinear has not chosen the good direction (because of floor and orientation).
+00512                 // eg on Right edge: This case arise if sDecimal==0, so if sa==sa1==0.5f. result is that
+00513                 // smoothBorderX is != than sInc on right border. same reasoning with downBorder (smoothBorderY=1).
+00514 
+00515                 // NO NEED TO DO HERE, because sInc or tInc are not used at all.
+00516 
+00517 
+00518 
+00519                 // compute Neighboring info.
+00520                 CPatchUVLocator         uvLocatorX;
+00521                 CPatchUVLocator         uvLocatorY;
+00522                 uvLocatorX.build(this, edgeX, bindInfoX);
+00523                 uvLocatorY.build(this, edgeY, bindInfoY);
+00524 
+00525 
+00526                 /* NB: see floor problems note in computeDisplaceEdgeSmooth();
+00527                 */
+00528                 sTile= noiseFloor(sTile) + 0.5f;
+00529                 tTile= noiseFloor(tTile) + 0.5f;
+00530                 // If we were exactly on the superior edge, prec compute is false... so correct this here.
+00531                 if(sTile>OrderS) sTile--;
+00532                 if(tTile>OrderT) tTile--;
+00533 
+00534 
+00535                 // Bilinear across a corner.
+00536                 CVector2f       stTileIn, stIn;
+00537                 CVector2f       stTileOut, stOut;
+00538                 CPatch          *patchOut;
+00539                 uint            patchId;
+00540 
+00541 
+00542                 // compute contribution of our patch.
+00543                 ret = computeDisplaceRaw(sTile,tTile, s,t) * sa * ta;
+00544 
+00545                 // compute contribution of the patch on the left/right side. same reasoning as in computeDisplaceEdgeSmooth();
+00546                 stIn.set(s, t);
+00547                 stTileIn.set(sTile+smoothBorderX, tTile);
+00548                 patchId= uvLocatorX.selectPatch(stTileIn);
+00549                 uvLocatorX.locateUV(stTileIn, patchId, patchOut, stTileOut);
+00550                 uvLocatorX.locateUV(stIn, patchId, patchOut, stOut);
+00551                 ret+= patchOut->computeDisplaceRaw(stTileOut.x, stTileOut.y, stOut.x, stOut.y) * sa1 * ta;
+00552 
+00553 
+00554                 // compute contribution of the patch on the up/down side. same reasoning as in computeDisplaceEdgeSmooth();
+00555                 stIn.set(s, t);
+00556                 stTileIn.set(sTile, tTile+smoothBorderY);
+00557                 patchId= uvLocatorY.selectPatch(stTileIn);
+00558                 uvLocatorY.locateUV(stTileIn, patchId, patchOut, stTileOut);
+00559                 uvLocatorY.locateUV(stIn, patchId, patchOut, stOut);
+00560                 ret+= patchOut->computeDisplaceRaw(stTileOut.x, stTileOut.y, stOut.x, stOut.y) * sa * ta1;
+00561 
+00562 
+00563                 /* compute contribution of the patch adjacent to me.
+00564                         There is multiple case to consider here. Take example with corner=0 (ie smBdX=smBdY=-1):
+00565                                 - if we are a normal corner with 4 edges, take the result from the left patch of our top patch.
+00566                                 - if the corner is on a bind Edge, the top patch may be the bigger patch, so don't take the result
+00567                                         from his neighbor (of course).
+00568                                 - if we are a normal corner with N!=4 edges, just do same thing than if N==4. this is false but don't bother.
+00569 
+00570                         To solve smoothly cases 1 and 2, use computeDisplaceRawOnNeighbor().
+00571                         This method, if nessecary, look on his neighbor to compute the value.
+00572                 */
+00573                 stIn.set(s, t);
+00574                 stTileIn.set(sTile+smoothBorderX, tTile+smoothBorderY);
+00575                 // look on our "top" patch (this is arbitrary).
+00576                 patchId= uvLocatorY.selectPatch(stTileIn);
+00577                 uvLocatorY.locateUV(stTileIn, patchId, patchOut, stTileOut);
+00578                 uvLocatorY.locateUV(stIn, patchId, patchOut, stOut);
+00579                 ret+= patchOut->computeDisplaceRawOnNeighbor(stTileOut.x, stTileOut.y, stOut.x, stOut.y) * sa1 * ta1;
+00580 
+00581 
+00582                 return ret;
+00583         }
+00584 
+00585 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
float NL3D::CPatch::computeDisplaceEdgeSmooth float  s,
float  t,
sint8  smoothBorderX,
sint8  smoothBorderY
const [private]
+
+ + + + + +
+   + + +

+compute the smoothed displacement for s,t ([0;OrderS], [0;OrderT]). Special case on edge. +

+Definition at line 288 of file patch_noise.cpp. +

+References NL3D::CPatchUVLocator::build(), NL3D::computeDisplaceBilinear(), computeDisplaceInteriorSmooth(), computeDisplaceRaw(), getBindNeighbor(), NL3D::CPatchUVLocator::locateUV(), nlassert, nlstop, NL3D::noiseFloor(), s, NL3D::CPatchUVLocator::selectPatch(), NLMISC::CVector2f::set(), sint8, t, uint, NLMISC::CVector2f::x, NLMISC::CVector2f::y, and NL3D::CPatch::CBindInfo::Zone. +

+Referenced by computeNoise(). +

+

00289 {
+00290         float sTile= s;
+00291         float tTile= t;
+00292         CBindInfo       bindInfo;
+00293         uint            edge=0;
+00294 
+00295         // only one must be not null
+00296         nlassert( (smoothBorderX==0) != (smoothBorderY==0) );
+00297 
+00298 
+00299         // Get the edge against we must share displace.
+00300         if(smoothBorderX==-1)   edge=0;
+00301         else if(smoothBorderY==1)       edge=1;
+00302         else if(smoothBorderX==1)       edge=2;
+00303         else if(smoothBorderY==-1)      edge=3;
+00304         else nlstop;
+00305 
+00306         // Build the bindInfo against this edge.
+00307         getBindNeighbor(edge, bindInfo);
+00308 
+00309         // Fast reject: if no neighbor, just do a simple computeDisplaceInteriorSmooth.
+00310         if(!bindInfo.Zone)
+00311                 return computeDisplaceInteriorSmooth(s, t);
+00312         // else, look for result in neighborhood.
+00313         else
+00314         {
+00315                 float   ret;
+00316 
+00317 
+00318                 // compute bi-linear weight factors.
+00319                 float   sInc, tInc, sa, ta, sa1, ta1;
+00320                 computeDisplaceBilinear(sTile, tTile, sInc, tInc, sa, ta, sa1, ta1);
+00321                 // Manage limit case: if bilinear has not chosen the good direction (because of floor and orientation).
+00322                 // eg on Right edge: This case arise if sDecimal==0, so if sa==sa1==0.5f. result is that
+00323                 // smoothBorderX is != than sInc on right border. same reasoning with downBorder (smoothBorderY=1).
+00324 
+00325                 // NO NEED TO DO HERE, because sInc or tInc is not used if it is bad (smoothBorder? used instead).
+00326                 // and no need to correct sa, sa1, because in this case they are both equal to 0.5.
+00327 
+00328 
+00329                 // compute Neighboring info.
+00330                 CPatchUVLocator         uvLocator;
+00331                 uvLocator.build(this, edge, bindInfo);
+00332 
+00333                 /* NB: there is floor problems with neighbors:
+00334                         - difference of orientation => uv.v=1. This point to the 1th tile. But this is not the same, if
+00335                                 v goes to up, or goes to down.
+00336                         - if multiple bind, problem at limit (eg a bind 1/2 on edge 0 with OrdertT=8, when uv.v= 4).
+00337                                 because, selection of the patch is dependent of orientation too.
+00338                         To avoid them, just take center of (sTile, tTile) to remove ambiguity.
+00339                         This works because computeDisplaceRaw() use sTile, tTile to get the noiseMap, so the decimal part is not 
+00340                         used.
+00341 
+00342                         Notice that we do this AFTER computeDisplaceBilinear() of course.
+00343                 */
+00344                 sTile= noiseFloor(sTile) + 0.5f;
+00345                 tTile= noiseFloor(tTile) + 0.5f;
+00346                 // If we were exactly on the superior edge, prec compute is false... so correct this here.
+00347                 if(sTile>OrderS) sTile--;
+00348                 if(tTile>OrderT) tTile--;
+00349 
+00350 
+00351                 // Bilinear across an edge (enjoy!!).
+00352                 CVector2f       stTileIn, stIn;
+00353                 CVector2f       stTileOut, stOut;
+00354                 CPatch          *patchOut;
+00355                 uint            patchId;
+00356 
+00357 
+00358                 // if vertical edge.
+00359                 if(smoothBorderX!=0)
+00360                 {
+00361                         // compute contribution of our patch.
+00362                         ret = computeDisplaceRaw(sTile,tTile, s,t) * sa * ta;
+00363                         ret+= computeDisplaceRaw(sTile,tTile+tInc, s,t) * sa * ta1;
+00364 
+00365                         // compute contribution of next(s) patchs.
+00366 
+00367                         // contribution of next at tTile.
+00368                         // Keep the same coordinate.
+00369                         stIn.set(s, t);
+00370                         // But look for the neighbor noise tile.
+00371                         stTileIn.set(sTile+smoothBorderX, tTile);
+00372                         // change basis: find the s,t on the neighbor patch.
+00373                         patchId= uvLocator.selectPatch(stTileIn);
+00374                         uvLocator.locateUV(stTileIn, patchId, patchOut, stTileOut);
+00375                         uvLocator.locateUV(stIn, patchId, patchOut, stOut);
+00376                         // Compute displace, and bi-linear on the neighbor patch.
+00377                         ret+= patchOut->computeDisplaceRaw(stTileOut.x, stTileOut.y, stOut.x, stOut.y) * sa1 * ta;
+00378 
+00379                         // contribution of next at tTile+tInc (same reasoning).
+00380                         stIn.set(s, t);
+00381                         stTileIn.set(sTile+smoothBorderX, tTile+tInc);
+00382                         patchId= uvLocator.selectPatch(stTileIn);
+00383                         uvLocator.locateUV(stTileIn, patchId, patchOut, stTileOut);
+00384                         uvLocator.locateUV(stIn, patchId, patchOut, stOut);
+00385                         ret+= patchOut->computeDisplaceRaw(stTileOut.x, stTileOut.y, stOut.x, stOut.y) * sa1 * ta1;
+00386 
+00387                 }
+00388                 // else if horizontal edge.
+00389                 else
+00390                 {
+00391                         // same reasoning as above.
+00392 
+00393                         // compute contribution of our patch.
+00394                         ret = computeDisplaceRaw(sTile, tTile, s,t) * sa * ta;
+00395                         ret+= computeDisplaceRaw(sTile+sInc,tTile, s,t) * sa1 * ta;
+00396 
+00397                         // compute contribution of next(s) patchs.
+00398                         // contribution of next at tTile.
+00399                         stIn.set(s, t);
+00400                         stTileIn.set(sTile, tTile+smoothBorderY);
+00401                         patchId= uvLocator.selectPatch(stTileIn);
+00402                         uvLocator.locateUV(stTileIn, patchId, patchOut, stTileOut);
+00403                         uvLocator.locateUV(stIn, patchId, patchOut, stOut);
+00404                         ret+= patchOut->computeDisplaceRaw(stTileOut.x, stTileOut.y, stOut.x, stOut.y) * sa * ta1;
+00405 
+00406                         // contribution of next at tTile+tInc (same reasoning).
+00407                         stIn.set(s, t);
+00408                         stTileIn.set(sTile+sInc, tTile+smoothBorderY);
+00409                         patchId= uvLocator.selectPatch(stTileIn);
+00410                         uvLocator.locateUV(stTileIn, patchId, patchOut, stTileOut);
+00411                         uvLocator.locateUV(stIn, patchId, patchOut, stOut);
+00412                         ret+= patchOut->computeDisplaceRaw(stTileOut.x, stTileOut.y, stOut.x, stOut.y) * sa1 * ta1;
+00413                 }
+00414 
+00415                 return ret;
+00416         }
+00417 
+00418 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
float NL3D::CPatch::computeDisplaceInteriorSmooth float  s,
float  t
const [private]
+
+ + + + + +
+   + + +

+compute the smoothed displacement for s,t ([0;OrderS], [0;OrderT]). +

+Definition at line 258 of file patch_noise.cpp. +

+References NL3D::computeDisplaceBilinear(), computeDisplaceRawCoordinates(), computeDisplaceRawInteger(), s, sint, and t. +

+Referenced by computeDisplaceCornerSmooth(), computeDisplaceEdgeSmooth(), and computeNoise(). +

+

00259 {
+00260         float sTile= s;
+00261         float tTile= t;
+00262         float   ret;
+00263 
+00264         // compute bi-linear weight factors.
+00265         float   sInc, tInc, sa, ta, sa1, ta1;
+00266         computeDisplaceBilinear(sTile, tTile, sInc, tInc, sa, ta, sa1, ta1);
+00267 
+00268 
+00269         // NB: to have smooth transition, must keep the same (s,t), so we do a transition with the noise tile of 
+00270         // our neigbhor, but under us.
+00271 
+00272         // speed up, using just one computeDisplaceRawCoordinates(), and multiple computeDisplaceRawInteger().
+00273         sint    ts,tt,ms,mt;
+00274         computeDisplaceRawCoordinates(sTile, tTile, s, t, ts, tt, ms, mt);
+00275 
+00276         sint    sIncInt= (sint) sInc;
+00277         sint    tIncInt= (sint) tInc;
+00278         ret = computeDisplaceRawInteger(ts, tt, ms,mt) * sa * ta;
+00279         ret+= computeDisplaceRawInteger(ts+sIncInt, tt, ms,mt) * sa1 * ta;
+00280         ret+= computeDisplaceRawInteger(ts, tt+tIncInt, ms,mt) * sa * ta1;
+00281         ret+= computeDisplaceRawInteger(ts+sIncInt, tt+tIncInt, ms,mt) * sa1 * ta1;
+00282 
+00283         return ret;
+00284 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
float NL3D::CPatch::computeDisplaceRaw float  sTile,
float  tTile,
float  s,
float  t
const [private]
+
+ + + + + +
+   + + +

+compute the displacement for s,t ([0;OrderS], [0;OrderT]) (sTile, tTile) choose what NoiseMap to use, and (s,t) choose the coordinate in the patch to compute this NoiseMap. Any rotation of the NoiseMap is included in this method. NB: s,t does not have to be clamped to ([0;OrderS], [0;OrderT]). +

+Definition at line 219 of file patch_noise.cpp. +

+References computeDisplaceRawCoordinates(), computeDisplaceRawInteger(), s, sint, and t. +

+Referenced by computeDisplaceCornerSmooth(), computeDisplaceEdgeSmooth(), and computeDisplaceRawOnNeighbor(). +

+

00220 {
+00221         sint    ts,tt,ms,mt;
+00222         computeDisplaceRawCoordinates(sTile, tTile, s, t, ts, tt, ms, mt);
+00223         return computeDisplaceRawInteger(ts, tt, ms, mt);
+00224 
+00225 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::computeDisplaceRawCoordinates float  sTile,
float  tTile,
float  s,
float  t,
sint ts,
sint tt,
sint ms,
sint mt
const [private]
+
+ + + + + +
+   + + +

+compute the smoothed displacement for s,t ([0;OrderS], [0;OrderT]). Special case on corner. +

+Definition at line 168 of file patch_noise.cpp. +

+References NL3D_TILE_NOISE_MAP_SIZE, NL3D_TILE_NOISE_MAP_TILE_FACTOR, NL3D::noiseFloor(), NoiseRotation, s, sint, t, NLMISC::CUV::U, NLMISC::CUV::V, and v. +

+Referenced by computeDisplaceInteriorSmooth(), and computeDisplaceRaw(). +

+

00170 {
+00171         // Choose the noiseMap.
+00172         // ===============================
+00173         // Compute coordinate in the patch.
+00174         ts= noiseFloor(sTile);
+00175         tt= noiseFloor(tTile);
+00176 
+00177 
+00178         // Sample the noiseMap with (s,t).
+00179         // ===============================
+00180 
+00181         // scale the map.
+00182         float   u= s * NL3D_TILE_NOISE_MAP_TILE_FACTOR;
+00183         float   v= t * NL3D_TILE_NOISE_MAP_TILE_FACTOR;
+00184 
+00185         // Speed rotation.
+00186         CUV             uv;
+00187         switch(NoiseRotation & 3)
+00188         {
+00189                 case 0: 
+00190                         uv.U= u;
+00191                         uv.V= v;
+00192                         break;
+00193                 case 1: 
+00194                         uv.U= NL3D_TILE_NOISE_MAP_SIZE-v;
+00195                         uv.V= u;
+00196                         break;
+00197                 case 2: 
+00198                         uv.U= NL3D_TILE_NOISE_MAP_SIZE-u;
+00199                         uv.V= NL3D_TILE_NOISE_MAP_SIZE-v;
+00200                         break;
+00201                 case 3: 
+00202                         uv.U= v;
+00203                         uv.V= NL3D_TILE_NOISE_MAP_SIZE-u;
+00204                         break;
+00205         }
+00206 
+00207         // direct map (no bilinear, no round, the case where s,t < 1/4 of a tile is very rare).
+00208         ms= noiseFloor(uv.U);
+00209         mt= noiseFloor(uv.V);
+00210 
+00211         // Manage Tiling (add NL3D_TILE_NOISE_MAP_SIZE*1 should be sufficient, but take margin).
+00212         ms= (ms + (NL3D_TILE_NOISE_MAP_SIZE*256)) & (NL3D_TILE_NOISE_MAP_SIZE-1);
+00213         mt= (mt + (NL3D_TILE_NOISE_MAP_SIZE*256)) & (NL3D_TILE_NOISE_MAP_SIZE-1);
+00214 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
float NL3D::CPatch::computeDisplaceRawInteger sint  ts,
sint  tt,
sint  ms,
sint  mt
const [private]
+
+ + + + + +
+   + + +

+compute the smoothed displacement for s,t ([0;OrderS], [0;OrderT]). Special case on corner. +

+Definition at line 136 of file patch_noise.cpp. +

+References NLMISC::clamp(), NL3D::CZone::getLandscape(), NL3D::CTileBank::getTileNoiseMap(), getZone(), NL3D_NOISE_MAX, NL3D_TILE_NOISE_MAP_SIZE, NL3D::CTileNoiseMap::Pixels, sint, sint8, NL3D::CLandscape::TileBank, Tiles, and uint. +

+Referenced by computeDisplaceInteriorSmooth(), and computeDisplaceRaw(). +

+

00137 {
+00138         // Choose the noiseMap.
+00139         // ===============================
+00140         clamp(ts, 0, OrderS-1);
+00141         clamp(tt, 0, OrderT-1);
+00142 
+00143         uint    tileId= tt*OrderS + ts;
+00144         // Get the tile for pass0. This is the principal tile, and this one tells what noise to take.
+00145         sint    tileNumber= Tiles[tileId].Tile[0];
+00146         // Get the subNoise from tileElement.
+00147         uint    tileSubNoise= Tiles[tileId].getTileSubNoise();
+00148 
+00149         // retrieve the wanted noiseMap.
+00150         CTileNoiseMap   *noiseMap;
+00151         noiseMap = getZone()->getLandscape()->TileBank.getTileNoiseMap (tileNumber, tileSubNoise);
+00152 
+00153         if (noiseMap == NULL)
+00154                 return 0.0f;
+00155 
+00156         // Sample the noiseMap with (s,t).
+00157         // ===============================
+00158 
+00159         // sample from map.
+00160         sint8   pix= noiseMap->Pixels[mt*NL3D_TILE_NOISE_MAP_SIZE + ms];
+00161 
+00162         // normalize.
+00163         return  (float)pix * (NL3D_NOISE_MAX / 127.f);
+00164 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
float NL3D::CPatch::computeDisplaceRawOnNeighbor float  sTile,
float  tTile,
float  s,
float  t
const [private]
+
+ + + + + +
+   + + +

+usefull only for computeDisplaceCornerSmooth(). This method, if nessecary (ie sTile or tTile <0 or >Order), look on his neighbor to compute the value. +

+Definition at line 422 of file patch_noise.cpp. +

+References NL3D::CPatchUVLocator::build(), computeDisplaceRaw(), getBindNeighbor(), NL3D::CPatchUVLocator::locateUV(), s, NL3D::CPatchUVLocator::selectPatch(), NLMISC::CVector2f::set(), sint, t, uint, NLMISC::CVector2f::x, NLMISC::CVector2f::y, and NL3D::CPatch::CBindInfo::Zone. +

+Referenced by computeDisplaceCornerSmooth(). +

+

00423 {
+00424         sint    edge= -1;
+00425 
+00426         // look on what neighbor patch we must find the value (if any).
+00427         if(sTile<0)     edge=0;
+00428         else if(tTile>OrderT)   edge=1;
+00429         else if(sTile>OrderS)   edge=2;
+00430         else if(tTile<0)                edge=3;
+00431 
+00432         // If the location is In the patch, just return normal value.
+00433         if(edge==-1)
+00434                 return computeDisplaceRaw(sTile, tTile, s, t);
+00435         // else must find on neighbor.
+00436         else
+00437         {
+00438                 CBindInfo       bindInfo;
+00439                 getBindNeighbor(edge, bindInfo);
+00440 
+00441                 // Fast reject: if no neighbor on the edge, just do a simple computeDisplaceRaw()
+00442                 if(!bindInfo.Zone)
+00443                 {
+00444                         return computeDisplaceRaw(sTile, tTile, s, t);
+00445                 }
+00446                 // else must find on neighbor.
+00447                 else
+00448                 {
+00449                         CPatchUVLocator         uvLocator;
+00450                         uvLocator.build(this, edge, bindInfo);
+00451 
+00452                         CVector2f       stTileIn, stIn;
+00453                         CVector2f       stTileOut, stOut;
+00454                         CPatch          *patchOut;
+00455                         uint            patchId;
+00456 
+00457                         // look on neighbor. same reasoning as in computeDisplaceEdgeSmooth();
+00458                         stIn.set(s, t);
+00459                         stTileIn.set(sTile, tTile);
+00460                         patchId= uvLocator.selectPatch(stTileIn);
+00461                         uvLocator.locateUV(stTileIn, patchId, patchOut, stTileOut);
+00462                         uvLocator.locateUV(stIn, patchId, patchOut, stOut);
+00463                         return patchOut->computeDisplaceRaw(stTileOut.x, stTileOut.y, stOut.x, stOut.y);
+00464                 }
+00465 
+00466         }
+00467 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::computeGeomorphAlphaFar1VertexListVB CTessList< CTessFarVertex > &  vertList  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1329 of file patch_render.cpp. +

+References NLMISC::CRGBA::A, NL3D::CTessList< T >::begin(), NLMISC::clamp(), NL3D::CTessFarVertex::Index1, NL3D::CTessNodeList::Next, OOTransitionSqrDelta, NL3D::CTessVertex::Pos, NL3D::CTessFarVertex::Src, TransitionSqrMin, and uint8. +

+Referenced by computeSoftwareGeomorphAndAlpha(). +

+

01330 {
+01331         // Traverse the vertList.
+01332         CTessFarVertex  *pVert;
+01333         for(pVert= vertList.begin(); pVert; pVert= (CTessFarVertex*)pVert->Next)
+01334         {
+01335                 static  uint8   *CurVBPtr;
+01336                 // Compute/build the new vertex.
+01337                 CurVBPtr= (uint8*)CLandscapeGlobals::CurrentFar1VBInfo.VertexCoordPointer;
+01338                 CurVBPtr+= pVert->Index1 * CLandscapeGlobals::CurrentFar1VBInfo.VertexSize;
+01339 
+01340                 // NB: the filling order of data is important, for AGP write combiners.
+01341 
+01342                 // Set Geomorphed Position. Set it local to the current center of landscape
+01343                 *(CVector*)CurVBPtr= pVert->Src->Pos - CLandscapeGlobals::PZBModelPosition;
+01344 
+01345                 // Set Alpha color.
+01346                 static CRGBA    col(255,255,255,255);
+01347                 // For Far1, use alpha fro transition.
+01348                 // Prefer Use Pos, because of caching. So little difference between Soft and VertexProgram mode.
+01349                 float   f= (pVert->Src->Pos - CLandscapeGlobals::RefineCenter).sqrnorm();
+01350                 f= (f-TransitionSqrMin) * OOTransitionSqrDelta;
+01351                 clamp(f,0,1);
+01352                 col.A= (uint8)(f*255);
+01353                 *(CRGBA*)(CurVBPtr + CLandscapeGlobals::CurrentFar1VBInfo.ColorOff)= col;
+01354         }
+01355 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::computeGeomorphFar0VertexListVB CTessList< CTessFarVertex > &  vertList  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1311 of file patch_render.cpp. +

+References NL3D::CTessList< T >::begin(), NL3D::CTessFarVertex::Index0, NL3D::CTessNodeList::Next, NL3D::CTessVertex::Pos, NL3D::CTessFarVertex::Src, and uint8. +

+Referenced by computeSoftwareGeomorphAndAlpha(). +

+

01312 {
+01313         // Traverse the vertList.
+01314         CTessFarVertex  *pVert;
+01315         for(pVert= vertList.begin(); pVert; pVert= (CTessFarVertex*)pVert->Next)
+01316         {
+01317                 static  uint8   *CurVBPtr;
+01318                 // Compute/build the new vertex.
+01319                 CurVBPtr= (uint8*)CLandscapeGlobals::CurrentFar0VBInfo.VertexCoordPointer;
+01320                 CurVBPtr+= pVert->Index0 * CLandscapeGlobals::CurrentFar0VBInfo.VertexSize;
+01321 
+01322                 // Set Geomorphed Position. Set it local to the current center of landscape
+01323                 *(CVector*)CurVBPtr= pVert->Src->Pos - CLandscapeGlobals::PZBModelPosition;
+01324         }
+01325 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::computeGeomorphTileVertexListVB CTessList< CTessNearVertex > &  vertList  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1359 of file patch_render.cpp. +

+References NL3D::CTessList< T >::begin(), NL3D::CTessNearVertex::Index, NL3D::CTessNodeList::Next, NL3D::CTessVertex::Pos, NL3D::CTessNearVertex::Src, and uint8. +

+Referenced by computeSoftwareGeomorphAndAlpha(). +

+

01360 {
+01361         // Traverse the vertList.
+01362         CTessNearVertex *pVert;
+01363         for(pVert= vertList.begin(); pVert; pVert= (CTessNearVertex*)pVert->Next)
+01364         {
+01365                 static  uint8   *CurVBPtr;
+01366                 // Compute/build the new vertex.
+01367                 CurVBPtr= (uint8*)CLandscapeGlobals::CurrentTileVBInfo.VertexCoordPointer;
+01368                 CurVBPtr+= pVert->Index * CLandscapeGlobals::CurrentTileVBInfo.VertexSize;
+01369 
+01370                 // Set Geomorphed Position. Set it local to the current center of landscape
+01371                 *(CVector*)CurVBPtr= pVert->Src->Pos - CLandscapeGlobals::PZBModelPosition;
+01372         }
+01373 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::computeGeomorphVertexList CTessList< CTessFarVertex > &  vertList  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1298 of file patch_render.cpp. +

+References NL3D::CTessList< T >::begin(), NL3D::CTessVertex::computeGeomPos(), NL3D::CTessNodeList::Next, and NL3D::CTessFarVertex::Src. +

+Referenced by computeSoftwareGeomorphAndAlpha(). +

+

01299 {
+01300         // Traverse the vertList.
+01301         CTessFarVertex  *pVert;
+01302         for(pVert= vertList.begin(); pVert; pVert= (CTessFarVertex*)pVert->Next)
+01303         {
+01304                 // compute geomorph.
+01305                 pVert->Src->computeGeomPos();
+01306         }
+01307 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::computeNearBlockLightmap uint  ts,
uint  tt,
NLMISC::CRGBA lightText
[private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 864 of file patch_lightmap.cpp. +

+References NL3D::CPatchUVLocator::build(), computeTileLightmap(), computeTileLightmapEdge(), computeTileLightmapPixel(), computeTileLightmapPixelAroundCorner(), NL3D::CPatch::CBindInfo::Edge, getBindNeighbor(), getCornerSmoothFlag(), getSmoothFlag(), NL3D::CPatchUVLocator::locateUV(), NL_LUMEL_BY_TILE, NL_LUMEL_BY_TILE_SHIFT, NL_TILE_LIGHTMAP_SIZE, nlassert, NL3D::CPatchUVLocator::sameEdgeOrder(), NL3D::CPatchUVLocator::selectPatch(), NLMISC::CVector2f::set(), sint, src, stride, uint, v, NLMISC::CVector2f::x, NLMISC::CVector2f::y, and NL3D::CPatch::CBindInfo::Zone. +

+Referenced by getTileLightMap(), and updateTessBlockLighting(). +

+

00865 {
+00866         sint    ts= uts;
+00867         sint    tt= utt;
+00868 
+00869         // hardcoded for 10x10.
+00870         nlassert(NL_TILE_LIGHTMAP_SIZE==10);
+00871         CRGBA   *dest;
+00872         uint    edge;
+00873         uint    corner;
+00874 
+00875         // Compute center of the TessBlock: the 2x2 tiles.
+00876         //=================
+00877         // compute tile 0,0 of the tessBlock. must decal of 1 pixel.
+00878         dest= lightText+NL_TILE_LIGHTMAP_SIZE+1;
+00879         computeTileLightmap(ts, tt, dest, NL_TILE_LIGHTMAP_SIZE);
+00880         // compute tile 1,0 of the tessBlock. must decal of 1 pixel.
+00881         dest= lightText + NL_LUMEL_BY_TILE + NL_TILE_LIGHTMAP_SIZE+1 ;
+00882         computeTileLightmap(ts+1, tt, dest, NL_TILE_LIGHTMAP_SIZE);
+00883         // compute tile 0,1 of the tessBlock. must decal of 1 pixel.
+00884         dest= lightText + NL_LUMEL_BY_TILE*NL_TILE_LIGHTMAP_SIZE + NL_TILE_LIGHTMAP_SIZE+1 ;
+00885         computeTileLightmap(ts, tt+1, dest, NL_TILE_LIGHTMAP_SIZE);
+00886         // compute tile 1,1 of the tessBlock. must decal of 1 pixel.
+00887         dest= lightText + NL_LUMEL_BY_TILE*NL_TILE_LIGHTMAP_SIZE + NL_LUMEL_BY_TILE + NL_TILE_LIGHTMAP_SIZE+1 ;
+00888         computeTileLightmap(ts+1, tt+1, dest, NL_TILE_LIGHTMAP_SIZE);
+00889 
+00890 
+00891         // Compute edges of the TessBlock.
+00892         //=================
+00893         bool    edgeBorder[4];
+00894         // where are we on a border of a patch??
+00895         edgeBorder[0]= ( ts==0 );
+00896         edgeBorder[1]= ( tt == OrderT-2 );
+00897         edgeBorder[2]= ( ts == OrderS-2 );
+00898         edgeBorder[3]= ( tt==0 );
+00899 
+00900         // For all edges.
+00901         for(edge=0; edge<4; edge++)
+00902         {
+00903                 // compute dest info.
+00904                 //==============
+00905                 // Are we on a vertical edge or horizontal edge??
+00906                 uint    stride= (edge&1)==0? NL_TILE_LIGHTMAP_SIZE : 1;
+00907 
+00908                 // must compute on which tile we must find info.
+00909                 sint    decalS=0;
+00910                 sint    decalT=0;
+00911                 // and must compute ptr, where we store the result of the edge.
+00912                 switch(edge)
+00913                 {
+00914                 case 0: decalS=-1; dest= lightText + 0 + NL_TILE_LIGHTMAP_SIZE; break;
+00915                 case 1: decalT= 2; dest= lightText + 1 + (NL_TILE_LIGHTMAP_SIZE-1)*NL_TILE_LIGHTMAP_SIZE; break;
+00916                 case 2: decalS= 2; dest= lightText + (NL_TILE_LIGHTMAP_SIZE-1) + NL_TILE_LIGHTMAP_SIZE; break;
+00917                 case 3: decalT=-1; dest= lightText + 1; break;
+00918                 };
+00919 
+00920                 // compute the second tile dest info.
+00921                 CRGBA   *dest2;
+00922                 sint    decalS2;
+00923                 sint    decalT2;
+00924                 // if vertical edge.
+00925                 if((edge&1)==0)
+00926                 {
+00927                         // Next Y tile.
+00928                         dest2= dest + NL_LUMEL_BY_TILE*NL_TILE_LIGHTMAP_SIZE;
+00929                         decalS2= decalS;
+00930                         decalT2= decalT+1;
+00931                 }
+00932                 else
+00933                 {
+00934                         // Next X tile.
+00935                         dest2= dest + NL_LUMEL_BY_TILE;
+00936                         decalS2= decalS+1;
+00937                         decalT2= decalT;
+00938                 }
+00939 
+00940 
+00941                 // If we are not on a border of a patch, just compute on the interior of the patch.
+00942                 //==============
+00943                 if(!edgeBorder[edge])
+00944                 {
+00945                         // find the result on the mirrored border of us. First tile.
+00946                         computeTileLightmapEdge(ts+decalS, tt+decalT, (edge+2)&3, dest, stride, false);
+00947 
+00948                         // find the result on the mirrored border of us. Second Tile.
+00949                         computeTileLightmapEdge(ts+decalS2, tt+decalT2, (edge+2)&3, dest2, stride, false);
+00950 
+00951                 }
+00952                 // else, slightly complicated, must find the result on neighbor patch(s).
+00953                 //==============
+00954                 else
+00955                 {
+00956                         CPatchUVLocator         uvLocator;
+00957                         CBindInfo                       bindInfo;
+00958                         bindInfo.Zone= NULL;
+00959 
+00960                         // if smoothed edge, search the neighbor.
+00961                         if(getSmoothFlag(edge))
+00962                         {
+00963                                 // Build the bindInfo against this edge.
+00964                                 getBindNeighbor(edge, bindInfo);
+00965 
+00966                                 // if ok, build the uv info against this edge.
+00967                                 if(bindInfo.Zone)
+00968                                 {
+00969                                         uvLocator.build(this, edge, bindInfo);
+00970                                         // if there is not same tile order across the edge, invalidate the smooth.
+00971                                         // This is rare, so don't bother.
+00972                                         if(!uvLocator.sameEdgeOrder())
+00973                                                 bindInfo.Zone= NULL;
+00974                                 }
+00975                         }
+00976 
+00977 
+00978                         // Fast reject: if no neighbor, or if not smoothed, or if edge order pb, just copy from my interior.
+00979                         if(!bindInfo.Zone)
+00980                         {
+00981                                 CRGBA   *src=0;
+00982                                 switch(edge)
+00983                                 {
+00984                                 case 0: src= dest + 1; break;
+00985                                 case 1: src= dest - NL_TILE_LIGHTMAP_SIZE; break;
+00986                                 case 2: src= dest - 1; break;
+00987                                 case 3: src= dest + NL_TILE_LIGHTMAP_SIZE; break;
+00988                                 };
+00989                                 
+00990                                 // fill the NL_LUMEL_BY_TILE*2 (8) pixels.
+00991                                 for(uint n=NL_LUMEL_BY_TILE*2; n>0; n--, src+=stride, dest+=stride)
+00992                                         *dest= *src;
+00993                         }
+00994                         // else, ok, get from neighbor.
+00995                         else
+00996                         {
+00997                                 CVector2f       stIn, stOut;
+00998                                 CPatch          *patchOut;
+00999                                 uint            patchId;
+01000                                 uint            edgeOut;
+01001                                 bool            inverse;
+01002 
+01003                                 // First Tile.
+01004                                 //=========
+01005                                 // to remove floor pbs, take the center of the wanted tile.
+01006                                 stIn.set(ts+decalS + 0.5f, tt+decalT + 0.5f);
+01007                                 patchId= uvLocator.selectPatch(stIn);
+01008                                 uvLocator.locateUV(stIn, patchId, patchOut, stOut);
+01009                                 // must find what edge on neighbor to compute, and if we must inverse (swap) result.
+01010                                 // easy: the edge of the tile is the edge of the patch where we are binded.
+01011                                 edgeOut= bindInfo.Edge[patchId];
+01012                                 // edge0 is oriented in T increasing order. edge1 is oriented in S increasing order.
+01013                                 // edge2 is oriented in T decreasing order. edge3 is oriented in S decreasing order.
+01014                                 // inverse is true if same sens on both edges (because of mirroring, sens should be different).
+01015                                 inverse= (edge>>1)==(edgeOut>>1);
+01016                                 // compute the lightmap on the edge of the neighbor.
+01017                                 patchOut->computeTileLightmapEdge((sint)floor(stOut.x), (sint)floor(stOut.y), edgeOut, dest, stride, inverse);
+01018 
+01019                                 // Second Tile.
+01020                                 //=========
+01021                                 // same reasoning.
+01022                                 stIn.set(ts+decalS2 + 0.5f, tt+decalT2 + 0.5f);
+01023                                 patchId= uvLocator.selectPatch(stIn);
+01024                                 uvLocator.locateUV(stIn, patchId, patchOut, stOut);
+01025                                 edgeOut= bindInfo.Edge[patchId];
+01026                                 inverse= (edge>>1)==(edgeOut>>1);
+01027                                 patchOut->computeTileLightmapEdge((sint)floor(stOut.x), (sint)floor(stOut.y), edgeOut, dest2, stride, inverse);
+01028                         }
+01029 
+01030                 }
+01031         }
+01032 
+01033 
+01034         // Compute corners of the TessBlock.
+01035         //=================
+01036         bool    cornerOnPatchEdge[4];
+01037         bool    cornerOnPatchCorner[4];
+01038         // where are we on a edge border of a patch??
+01039         cornerOnPatchEdge[0]= edgeBorder[3] != edgeBorder[0];
+01040         cornerOnPatchEdge[1]= edgeBorder[0] != edgeBorder[1];
+01041         cornerOnPatchEdge[2]= edgeBorder[1] != edgeBorder[2];
+01042         cornerOnPatchEdge[3]= edgeBorder[2] != edgeBorder[3];
+01043         // where are we on a corner border of a patch??
+01044         cornerOnPatchCorner[0]= edgeBorder[3] && edgeBorder[0];
+01045         cornerOnPatchCorner[1]= edgeBorder[0] && edgeBorder[1];
+01046         cornerOnPatchCorner[2]= edgeBorder[1] && edgeBorder[2];
+01047         cornerOnPatchCorner[3]= edgeBorder[2] && edgeBorder[3];
+01048 
+01049         // For all corners.
+01050         for(corner=0; corner<4; corner++)
+01051         {
+01052                 // compute dest info.
+01053                 //==============
+01054                 // must compute on which tile we must find info.
+01055                 sint    decalS=0;
+01056                 sint    decalT=0;
+01057                 // and must compute ptr, where we store the result of the corner.
+01058                 switch(corner)
+01059                 {
+01060                 case 0: decalS=-1; decalT=-1; dest= lightText + 0 + 0; break;
+01061                 case 1: decalS=-1; decalT= 2; dest= lightText + 0 + (NL_TILE_LIGHTMAP_SIZE-1)*NL_TILE_LIGHTMAP_SIZE; break;
+01062                 case 2: decalS= 2; decalT= 2; dest= lightText + (NL_TILE_LIGHTMAP_SIZE-1) + (NL_TILE_LIGHTMAP_SIZE-1)*NL_TILE_LIGHTMAP_SIZE; break;
+01063                 case 3: decalS= 2; decalT=-1; dest= lightText + (NL_TILE_LIGHTMAP_SIZE-1) + 0; break;
+01064                 };
+01065 
+01066 
+01067                 // If we are not on a border of a patch, just compute on the interior of the patch.
+01068                 //==============
+01069                 // if the corner is IN the patch.
+01070                 if(!cornerOnPatchCorner[corner] && !cornerOnPatchEdge[corner])
+01071                 {
+01072                         // what pixel to read.
+01073                         uint    subS, subT;
+01074                         if(decalS==-1)  subS= NL_LUMEL_BY_TILE-1;
+01075                         else                    subS= 0;
+01076                         if(decalT==-1)  subT= NL_LUMEL_BY_TILE-1;
+01077                         else                    subT= 0;
+01078 
+01079                         // find the result on the corner of the neighbor tile.
+01080                         computeTileLightmapPixel(ts+decalS, tt+decalT, subS, subT, dest);
+01081                 }
+01082                 else
+01083                 {
+01084                         // By default, fill the corner with our interior corner. Because other methods may fail.
+01085                         CRGBA   *src=0;
+01086                         switch(corner)
+01087                         {
+01088                         case 0: src= dest + 1 + NL_TILE_LIGHTMAP_SIZE; break;
+01089                         case 1: src= dest + 1 - NL_TILE_LIGHTMAP_SIZE; break;
+01090                         case 2: src= dest - 1 - NL_TILE_LIGHTMAP_SIZE; break;
+01091                         case 3: src= dest - 1 + NL_TILE_LIGHTMAP_SIZE; break;
+01092                         };
+01093                         
+01094                         // fill the pixel.
+01095                         *dest= *src;
+01096 
+01097                         // get the coordinate of the corner, in our [0,Order] basis. get it at the center of the pixel.
+01098                         CBindInfo                       bindInfo;
+01099                         CPatchUVLocator         uvLocator;
+01100                         CVector2f                       stIn, stOut;
+01101                         CPatch                          *patchOut;
+01102                         uint                            patchId;
+01103                         float                           decX, decY;
+01104                         static const float      lumelSize= 1.f/NL_LUMEL_BY_TILE;
+01105                         static const float      semiLumelSize= 0.5f*lumelSize;
+01106 
+01107                         if(decalS==-1)  decX= -  semiLumelSize;
+01108                         else                    decX= 2+ semiLumelSize;
+01109                         if(decalT==-1)  decY= -  semiLumelSize;
+01110                         else                    decY= 2+ semiLumelSize;
+01111                         stIn.set( ts+decX, tt+decY);
+01112 
+01113 
+01114                         // if the corner is on One edge only of the patch.
+01115                         if(cornerOnPatchEdge[corner])
+01116                         {
+01117                                 // find the edge where to read this corner: hard edge after or before this corner.
+01118                                 if(edgeBorder[corner])  edge= corner;
+01119                                 else                                    edge= (corner+4-1) & 3;
+01120 
+01121                                 // if this edge is smoothed, find on neighbor.
+01122                                 if(getSmoothFlag(edge))
+01123                                 {
+01124                                         // retrieve neigbhor info.
+01125                                         getBindNeighbor(edge, bindInfo);
+01126 
+01127                                         // if neighbor present.
+01128                                         if(bindInfo.Zone)
+01129                                         {
+01130                                                 // Ok, search uv on this patch.
+01131                                                 uvLocator.build(this, edge, bindInfo);
+01132                                                 patchId= uvLocator.selectPatch(stIn);
+01133                                                 uvLocator.locateUV(stIn, patchId, patchOut, stOut);
+01134 
+01135                                                 // Get the Uv, in [0,Order?*NL_LUMEL_BY_TILE] basis (ie lumel basis), and get from neighbor patch
+01136                                                 sint    u, v;
+01137                                                 u= (sint)floor(stOut.x*NL_LUMEL_BY_TILE);
+01138                                                 v= (sint)floor(stOut.y*NL_LUMEL_BY_TILE);
+01139                                                 patchOut->computeTileLightmapPixel(u>>NL_LUMEL_BY_TILE_SHIFT, v>>NL_LUMEL_BY_TILE_SHIFT, u&(NL_LUMEL_BY_TILE-1), v&(NL_LUMEL_BY_TILE-1), dest);
+01140                                         }
+01141                                 }
+01142                                 // else we must still smooth with our lumel on this patch, so get it from neighbor on edge.
+01143                                 else
+01144                                 {
+01145                                         // first, clamp to our patch (recenter on the previous pixel)
+01146                                         if(stIn.x<0)                    stIn.x+= lumelSize;
+01147                                         else if(stIn.x>OrderS)  stIn.x-= lumelSize;
+01148                                         else if(stIn.y<0)               stIn.y+= lumelSize;
+01149                                         else if(stIn.y>OrderT)  stIn.y-= lumelSize;
+01150 
+01151                                         // Get the Uv, in [0,Order?*NL_LUMEL_BY_TILE] basis (ie lumel basis), and get from this patch
+01152                                         sint    u, v;
+01153                                         u= (sint)floor(stIn.x*NL_LUMEL_BY_TILE);
+01154                                         v= (sint)floor(stIn.y*NL_LUMEL_BY_TILE);
+01155                                         computeTileLightmapPixel(u>>NL_LUMEL_BY_TILE_SHIFT, v>>NL_LUMEL_BY_TILE_SHIFT, u&(NL_LUMEL_BY_TILE-1), v&(NL_LUMEL_BY_TILE-1), dest);
+01156                                 }
+01157                         }
+01158                         // else it is on a corner of the patch.
+01159                         else
+01160                         {
+01161                                 // if the corner of the patch (same as tile corner) is smoothed, find on neighbor
+01162                                 if(getCornerSmoothFlag(corner))
+01163                                 {
+01164                                         // retrieve neigbhor info. NB: use edgeId=corner, (corner X is the start of the edge X)it works.
+01165                                         getBindNeighbor(corner, bindInfo);
+01166 
+01167                                         // if neighbor present.
+01168                                         if(bindInfo.Zone)
+01169                                         {
+01170                                                 // Ok, search uv on this patch.
+01171                                                 uvLocator.build(this, corner, bindInfo);
+01172                                                 patchId= uvLocator.selectPatch(stIn);
+01173                                                 uvLocator.locateUV(stIn, patchId, patchOut, stOut);
+01174 
+01175                                                 // same reasoning as in computeDisplaceCornerSmooth(), must find the pixel on the neighbor 
+01176                                                 // of our neighbor. But the current corner may be a corner on a bind X/1. All is managed by doing
+01177                                                 // this way.
+01178                                                 patchOut->computeTileLightmapPixelAroundCorner(stOut, dest, true);
+01179                                         }
+01180                                 }
+01181                         }
+01182                 }
+01183 
+01184         }
+01185 
+01186 
+01187 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::computeNewFar const NLMISC::CBSphere patchSphere,
sint newFar0,
sint newFar1
[private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 54 of file patch_render.cpp. +

+References _PatchRdrPassFar0, _PatchRdrPassFar1, NLMISC::CBSphere::Center, Far0UBias, Far0UScale, Far0VBias, Far0VScale, Far1UBias, Far1UScale, Far1VBias, Far1VScale, NL3D::CLandscape::freeFarRenderPass(), NL3D::CLandscape::getFarRenderPass(), NL3D::CZone::Landscape, NL_PATCH_FAR0_ROTATED, NL_PATCH_FAR1_ROTATED, nlassert, nlstop, OOTransitionSqrDelta, r, NLMISC::CBSphere::Radius, sint, NLMISC::sqr(), TransitionSqrMin, and uint8. +

+Referenced by preRender(), and updateTextureFarOnly(). +

+

00055 {
+00056         // Classify the patch.
+00057         //========================
+00058         float   r= (CLandscapeGlobals::RefineCenter-patchSphere.Center).norm() - patchSphere.Radius;
+00059         float   rr=0.0;
+00060         if(r<CLandscapeGlobals::TileDistNear)
+00061                 rr= r-CLandscapeGlobals::TileDistNear, newFar0= 0;
+00062         else if(r<CLandscapeGlobals::Far0Dist)
+00063                 rr= r-CLandscapeGlobals::Far0Dist, newFar0= 1;
+00064         else if(r<CLandscapeGlobals::Far1Dist)
+00065                 rr= r-CLandscapeGlobals::Far1Dist, newFar0= 2;
+00066         else
+00067                 newFar0= 3;
+00068         // Transition with the next level.
+00069         newFar1=0;
+00070         if(newFar0<3 && rr>-(CLandscapeGlobals::FarTransition+2*patchSphere.Radius))
+00071         {
+00072                 newFar1= newFar0+1;
+00073         }
+00074 
+00075 
+00076         // Update Texture Info.
+00077         //========================
+00078         if(newFar0!=Far0 || newFar1!=Far1)
+00079         {
+00080                 // Backup old pass0
+00081                 CPatchRdrPass   *oldPass0=_PatchRdrPassFar0;
+00082                 CPatchRdrPass   *oldPass1=_PatchRdrPassFar1;
+00083 
+00084                 // Checks
+00085                 if (oldPass0==NULL)
+00086                         nlassert (Far0<=0);
+00087                 if (oldPass1==NULL)
+00088                         nlassert (Far1<=0);
+00089 
+00090                 float oldFar0UScale=Far0UScale;
+00091                 float oldFar0VScale=Far0VScale;
+00092                 float oldFar0UBias=Far0UBias;
+00093                 float oldFar0VBias=Far0VBias;
+00094                 uint8 oldFlags=Flags;
+00095 
+00096 
+00097                 // Don't delete the pass0 if the new newFar1 will use it
+00098                 if ((newFar1==Far0)&&(Far0>0))
+00099                         _PatchRdrPassFar0=NULL;
+00100 
+00101                 // Don't delete the pass1 if the new newFar0 will use it
+00102                 if ((newFar0==Far1)&&(Far1>0))
+00103                         _PatchRdrPassFar1=NULL;
+00104 
+00105                 // Pass0 have changed ?
+00106                 if (newFar0!=Far0)
+00107                 {
+00108                         // Compute / get the texture Far.
+00109                         if(newFar0>0)
+00110                         {
+00111                                 // Free the old pass, don't used any more
+00112                                 if (_PatchRdrPassFar0)
+00113                                         Zone->Landscape->freeFarRenderPass (this, _PatchRdrPassFar0, Far0);
+00114 
+00115                                 // Can we use the old pass1 ?
+00116                                 if (newFar0==Far1)
+00117                                 {
+00118                                         // Yes, recycle it!
+00119                                         _PatchRdrPassFar0=oldPass1;
+00120 
+00121                                         // Copy uv coordinates
+00122                                         Far0UScale=Far1UScale;
+00123                                         Far0VScale=Far1VScale;
+00124                                         Far0UBias=Far1UBias;
+00125                                         Far0VBias=Far1VBias;
+00126 
+00127                                         // Copy rotation flag
+00128                                         Flags&=~NL_PATCH_FAR0_ROTATED;                  // erase it
+00129                                         if (Flags&NL_PATCH_FAR1_ROTATED)
+00130                                                 Flags|=NL_PATCH_FAR0_ROTATED;                   // copy it
+00131                                 }
+00132                                 else    // get a new render pass
+00133                                 {
+00134                                         // Rotation boolean
+00135                                         bool bRot;
+00136                                         _PatchRdrPassFar0=Zone->Landscape->getFarRenderPass(this, newFar0, Far0UScale, Far0VScale, Far0UBias, Far0VBias, bRot);
+00137 
+00138                                         // Flags is set if the far texture is rotated of 90deg to the left
+00139                                         if (bRot)
+00140                                                 Flags|=NL_PATCH_FAR0_ROTATED;
+00141                                         else
+00142                                                 Flags&=~NL_PATCH_FAR0_ROTATED;
+00143                                 }
+00144                         }
+00145                         else    // no more far pass0
+00146                         {
+00147                                 if (_PatchRdrPassFar0)
+00148                                 {
+00149                                         Zone->Landscape->freeFarRenderPass (this, _PatchRdrPassFar0, Far0);
+00150                                         _PatchRdrPassFar0=NULL;
+00151                                 }
+00152                         }
+00153                 }
+00154 
+00155                 // Pass1 have changed ?
+00156                 if (newFar1!=Far1)
+00157                 {
+00158                         // Now let's go with pass1
+00159                         if(newFar1>0)
+00160                         {
+00161                                 // Delete the pass1 if not used any more
+00162                                 if (_PatchRdrPassFar1)
+00163                                         Zone->Landscape->freeFarRenderPass (this, _PatchRdrPassFar1, Far1);
+00164 
+00165                                 // Can we use the old pass1 ?
+00166                                 if (newFar1==Far0)
+00167                                 {
+00168                                         // Yes, recycle it!
+00169                                         _PatchRdrPassFar1= oldPass0;
+00170                                         nlassert (_PatchRdrPassFar1);
+00171 
+00172                                         // Copy uv coordinates
+00173                                         Far1UScale=oldFar0UScale;
+00174                                         Far1VScale=oldFar0VScale;
+00175                                         Far1UBias=oldFar0UBias;
+00176                                         Far1VBias=oldFar0VBias;
+00177 
+00178                                         // Copy rotation flag
+00179                                         Flags&=~NL_PATCH_FAR1_ROTATED;                  // erase it
+00180                                         if (oldFlags&NL_PATCH_FAR0_ROTATED)
+00181                                                 Flags|=NL_PATCH_FAR1_ROTATED;                   // copy it
+00182                                 }
+00183                                 else    // get a new render pass
+00184                                 {
+00185                                         // Rotation boolean
+00186                                         bool bRot;
+00187                                         _PatchRdrPassFar1=Zone->Landscape->getFarRenderPass(this, newFar1, Far1UScale, Far1VScale, Far1UBias, Far1VBias, bRot);
+00188                                         nlassert (_PatchRdrPassFar1);
+00189 
+00190                                         // Flags is set if the far texture is rotated of 90deg to the left
+00191                                         if (bRot)
+00192                                                 Flags|=NL_PATCH_FAR1_ROTATED;
+00193                                         else
+00194                                                 Flags&=~NL_PATCH_FAR1_ROTATED;
+00195                                 }
+00196 
+00197                                 // Compute info for transition.
+00198                                 float   farDist;
+00199                                 switch(newFar1)
+00200                                 {
+00201                                         case 1: farDist= CLandscapeGlobals::TileDistNear; break;
+00202                                         case 2: farDist= CLandscapeGlobals::Far0Dist; break;
+00203                                         case 3: farDist= CLandscapeGlobals::Far1Dist; break;
+00204                                         default: nlstop;
+00205                                 };
+00206                                 TransitionSqrMin= sqr(farDist-CLandscapeGlobals::FarTransition);
+00207                                 OOTransitionSqrDelta= 1.0f/(sqr(farDist)-TransitionSqrMin);
+00208                         }
+00209                         else    // no more far pass1
+00210                         {
+00211                                 if (_PatchRdrPassFar1)
+00212                                 {
+00213                                         Zone->Landscape->freeFarRenderPass (this, _PatchRdrPassFar1, Far1);
+00214                                         _PatchRdrPassFar1=NULL;
+00215                                 }
+00216                         }
+00217                 }
+00218 
+00219         }
+00220 
+00221         // Don't copy Far0 and Far1.
+00222 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::computeNoise float  s,
float  t,
CVector displace
const [private]
+
+ + + + + +
+   + + +

+compute the Final displacement for s,t ([0;1], [0;1]). This is the top call. displace.norm() should be <= NL3D_NOISE_MAX. +

+Definition at line 874 of file patch_noise.cpp. +

+References computeDisplaceCornerSmooth(), computeDisplaceEdgeSmooth(), computeDisplaceInteriorSmooth(), computeNormalCornerSmooth(), computeNormalEdgeSmooth(), NL3D::CBezierPatch::evalNormal(), s, sint8, t, and unpackIntoCache(). +

+Referenced by computeVertex(). +

+

00875 {
+00876         float   so= s*OrderS;
+00877         float   to= t*OrderT;
+00878 
+00879 
+00880         // Pre-Compute Border Smothing.
+00881         //=========================
+00882         // If we are on a border, flag it.
+00883         sint8   smoothNormalBorderX= 0;
+00884         sint8   smoothNormalBorderY= 0;
+00885         // NB: because OrderS and OrderT >=2, smoothNormalBorderX=-1 and smoothNormalBorderX=1 are exclusive (as smoothNormalBorderY).
+00886         if(so < 1) smoothNormalBorderX= -1;
+00887         else if(so > OrderS-1) smoothNormalBorderX= 1;
+00888         if(to < 1) smoothNormalBorderY= -1;
+00889         else if(to > OrderT-1) smoothNormalBorderY= 1;
+00890 
+00891         bool    smoothNormalEdge= (smoothNormalBorderX!=0) != (smoothNormalBorderY!=0);
+00892         bool    smoothNormalCorner= (smoothNormalBorderX!=0) && (smoothNormalBorderY!=0);
+00893 
+00894 
+00895         // Do same thing, but to know if we must compute a displace on an interior, on an edge or on a corner.
+00896         sint8   smoothDisplaceBorderX= 0;
+00897         sint8   smoothDisplaceBorderY= 0;
+00898         // NB: because OrderS and OrderT >=2, smoothBorderX=-1 and smoothBorderX=1 are exclusive (as smoothBorderY).
+00899         if(so < 0.5) smoothDisplaceBorderX= -1;
+00900         else if(so > OrderS-0.5) smoothDisplaceBorderX= 1;
+00901         if(to < 0.5) smoothDisplaceBorderY= -1;
+00902         else if(to > OrderT-0.5) smoothDisplaceBorderY= 1;
+00903 
+00904         bool    smoothDisplaceEdge= (smoothDisplaceBorderX!=0) != (smoothDisplaceBorderY!=0);
+00905         bool    smoothDisplaceCorner= (smoothDisplaceBorderX!=0) && (smoothDisplaceBorderY!=0);
+00906 
+00907 
+00908         // Compute Displace value.
+00909         //=========================
+00910         float   displaceValue;
+00911 
+00912         if(smoothDisplaceCorner)
+00913                 displaceValue= computeDisplaceCornerSmooth(so, to, smoothDisplaceBorderX, smoothDisplaceBorderY);
+00914         else if(smoothDisplaceEdge)
+00915                 displaceValue= computeDisplaceEdgeSmooth(so, to, smoothDisplaceBorderX, smoothDisplaceBorderY);
+00916         else
+00917                 displaceValue= computeDisplaceInteriorSmooth(so, to);
+00918 
+00919 
+00920 
+00921         // Compute Displace normal.
+00922         //=========================
+00923 
+00924         // Evaluate the normal.
+00925         CVector         displaceNormal;
+00926 
+00927 
+00928         // smooth on edges and on corners.
+00929         if(smoothNormalCorner)
+00930                 displaceNormal= computeNormalCornerSmooth(so, to, smoothNormalBorderX, smoothNormalBorderY);
+00931         else if(smoothNormalEdge)
+00932                 displaceNormal= computeNormalEdgeSmooth(so, to, smoothNormalBorderX, smoothNormalBorderY);
+00933         else
+00934         {
+00935                 // unpack...
+00936                 CBezierPatch    *bpatch= unpackIntoCache();
+00937                 // eval.
+00938                 displaceNormal= bpatch->evalNormal(s, t);
+00939         }
+00940 
+00941 
+00942 
+00943         // Final result.
+00944         //=========================
+00945         displace= displaceNormal * displaceValue;
+00946 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CVector NL3D::CPatch::computeNormalCornerSmooth float  s,
float  t,
sint8  smoothBorderX,
sint8  smoothBorderY
const [private]
+
+ + + + + +
+   + + +

+compute the smoothed normal for s,t ([0;OrderS], [0;OrderT]). Special case on corner. +

+Definition at line 728 of file patch_noise.cpp. +

+References NL3D::CPatchUVLocator::build(), computeNormalEdgeSmooth(), computeNormalOnNeighbor(), NL3D::CPatch::CBindInfo::Edge, NL3D::CBezierPatch::evalNormal(), getBindNeighbor(), getCornerSmoothFlag(), getOrderS(), getOrderT(), NL3D::CPatchUVLocator::locateUV(), nlassert, nlstop, NL3D::noiseCeilF(), NL3D::noiseFloorF(), s, NL3D::CPatchUVLocator::selectPatch(), NLMISC::CVector2f::set(), sint8, t, uint, unpackIntoCache(), NLMISC::CVector2f::x, NLMISC::CVector2f::y, and NL3D::CPatch::CBindInfo::Zone. +

+Referenced by computeNoise(). +

+

00729 {
+00730         CBindInfo       bindInfoX;
+00731         CBindInfo       bindInfoY;
+00732         uint            edgeX=0;
+00733         uint            edgeY=0;
+00734         uint            corner;
+00735         CBezierPatch    *bpatch;
+00736         bpatch= unpackIntoCache();
+00737 
+00738         // both must be not null
+00739         nlassert( (smoothBorderX!=0) && (smoothBorderY!=0) );
+00740 
+00741 
+00742         // Get the edge against we must share displace.
+00743         if(smoothBorderX==-1)   edgeX=0;
+00744         else if(smoothBorderX==1)       edgeX=2;
+00745         else nlstop;
+00746         if(smoothBorderY==1)    edgeY=1;
+00747         else if(smoothBorderY==-1)      edgeY=3;
+00748         else nlstop;
+00749 
+00750         // Get the corner against we must share displace.
+00751         if(smoothBorderX==-1)
+00752         {
+00753                 if(smoothBorderY==-1)   corner=0;
+00754                 else                                    corner=1;
+00755         }
+00756         else
+00757         {
+00758                 if(smoothBorderY==-1)   corner=3;
+00759                 else                                    corner=2;
+00760         }
+00761 
+00762         // If this corner is smoothed, blend with 4 neighbors patchs.
+00763         if(getCornerSmoothFlag(corner))
+00764         {
+00765                 // Build the bindInfo against the 2 edge.
+00766                 getBindNeighbor(edgeX, bindInfoX);
+00767                 getBindNeighbor(edgeY, bindInfoY);
+00768 
+00769                 // Fast reject: if no neighbor, just do a simple computeDisplaceInteriorSmooth.
+00770                 if(!bindInfoX.Zone || !bindInfoY.Zone)
+00771                         return bpatch->evalNormal(s/getOrderS(), t/getOrderT());
+00772                 else
+00773                 {
+00774                         CVector         ret;
+00775 
+00776 
+00777                         // Compute the coordinate on the border of the edge, and the coef of the blend.
+00778                         float           se=s;
+00779                         float           te=t;
+00780                         float           coefX;
+00781                         float           coefY;
+00782                         if(smoothBorderX==-1)   se= noiseFloorF(se), coefX=s-se;
+00783                         else                                    se= noiseCeilF(se), coefX=se-s;
+00784                         if(smoothBorderY==-1)   te= noiseFloorF(te), coefY=t-te;
+00785                         else                                    te= noiseCeilF(te), coefY=te-t;
+00786                         coefX= 0.5f + coefX*0.5f;
+00787                         coefY= 0.5f + coefY*0.5f;
+00788 
+00789 
+00790                         // Compute our contribution.
+00791                         ret= bpatch->evalNormal(s/getOrderS(), t/getOrderT()) *coefX*coefY;
+00792 
+00793 
+00794                         // compute Neighboring info.
+00795                         CPatchUVLocator         uvLocatorX;
+00796                         CPatchUVLocator         uvLocatorY;
+00797                         CVector2f       stIn, stOut;
+00798                         CPatch          *patchOut;
+00799                         uint            patchId;
+00800 
+00801                         uvLocatorX.build(this, edgeX, bindInfoX);
+00802                         uvLocatorY.build(this, edgeY, bindInfoY);
+00803 
+00804                         // Patch on our X side.
+00805                         stIn.set(se, te);
+00806                         patchId= uvLocatorX.selectPatch(stIn);
+00807                         uvLocatorX.locateUV(stIn, patchId, patchOut, stOut);
+00808                         bpatch= patchOut->unpackIntoCache();
+00809                         ret+= bpatch->evalNormal(stOut.x/patchOut->getOrderS(), stOut.y/patchOut->getOrderT()) *(1-coefX)*coefY;
+00810 
+00811                         // Patch on our Y side.
+00812                         stIn.set(se, te);
+00813                         patchId= uvLocatorY.selectPatch(stIn);
+00814                         uvLocatorY.locateUV(stIn, patchId, patchOut, stOut);
+00815                         bpatch= patchOut->unpackIntoCache();
+00816                         ret+= bpatch->evalNormal(stOut.x/patchOut->getOrderS(), stOut.y/patchOut->getOrderT()) *coefX*(1-coefY);
+00817 
+00818                         /* compute contribution of the patch adjacent to me.
+00819                                 Same reasoning as in computeDisplaceCornerSmooth().
+00820                         */
+00821                         stIn.set(se, te);
+00822                         patchId= uvLocatorY.selectPatch(stIn);
+00823                         uvLocatorY.locateUV(stIn, patchId, patchOut, stOut);
+00824                         // Because we compute the normal exactly on the edge, we must inform this method not to take us as neighbor.
+00825                         // ugly but simpler.
+00826                         ret+= patchOut->computeNormalOnNeighbor(stOut.x, stOut.y, bindInfoY.Edge[patchId]) *(1-coefX)*(1-coefY);
+00827 
+00828                         return ret;
+00829                 }
+00830         }
+00831         // else must blend with 0.
+00832         else
+00833         {
+00834                 // compute coef.
+00835                 float           se=s;
+00836                 float           te=t;
+00837                 float           coefX;
+00838                 float           coefY;
+00839                 if(smoothBorderX==-1)   se= noiseFloorF(se), coefX=s-se;
+00840                 else                                    se= noiseCeilF(se), coefX=se-s;
+00841                 if(smoothBorderY==-1)   te= noiseFloorF(te), coefY=t-te;
+00842                 else                                    te= noiseCeilF(te), coefY=te-t;
+00843 
+00844 
+00845                 // To have smooth continuities with smooth on edge (if any), we must do this.
+00846                 CVector         rx, ry;
+00847                 // Compute a smooth with my X neighbor.
+00848                 rx= computeNormalEdgeSmooth(s, t, smoothBorderX, 0);
+00849                 // Compute a smooth with my Y neighbor.
+00850                 ry= computeNormalEdgeSmooth(s, t, 0, smoothBorderY);
+00851 
+00852                 // Blend the 2 result.
+00853                 if(coefY + coefX>0)
+00854                 {
+00855                         // This the weight used to blend to 0.
+00856                         float   maxCoef= max(coefY, coefX);
+00857                         // This the weight used to blend beetween rx and ry.
+00858                         float   ooSum= 1.0f / (coefY + coefX);
+00859                         float   blendCoefX= coefX * ooSum;
+00860                         float   blendCoefY= coefY * ooSum;
+00861 
+00862                         return maxCoef* (rx*blendCoefY + ry*blendCoefX);
+00863                 }
+00864                 else
+00865                 {
+00866                         return CVector::Null;
+00867                 }
+00868         }
+00869 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
CVector NL3D::CPatch::computeNormalEdgeSmooth float  s,
float  t,
sint8  smoothBorderX,
sint8  smoothBorderY
const [private]
+
+ + + + + +
+   + + +

+compute the smoothed normal for s,t ([0;OrderS], [0;OrderT]). Special case on edge. +

+Definition at line 588 of file patch_noise.cpp. +

+References NL3D::CPatchUVLocator::build(), NL3D::CBezierPatch::evalNormal(), getBindNeighbor(), getOrderS(), getOrderT(), getSmoothFlag(), NL3D::CPatchUVLocator::locateUV(), nlassert, nlstop, NL3D::noiseCeilF(), NL3D::noiseFloorF(), s, NL3D::CPatchUVLocator::selectPatch(), NLMISC::CVector2f::set(), sint8, t, uint, unpackIntoCache(), NLMISC::CVector2f::x, NLMISC::CVector2f::y, and NL3D::CPatch::CBindInfo::Zone. +

+Referenced by computeNoise(), and computeNormalCornerSmooth(). +

+

00589 {
+00590         CBindInfo       bindInfo;
+00591         uint            edge=0;
+00592         CBezierPatch    *bpatch;
+00593         bpatch= unpackIntoCache();
+00594 
+00595         // only one must be not null
+00596         nlassert( (smoothBorderX==0) != (smoothBorderY==0) );
+00597 
+00598 
+00599         // Get the edge against we must share displace.
+00600         if(smoothBorderX==-1)   edge=0;
+00601         else if(smoothBorderY==1)       edge=1;
+00602         else if(smoothBorderX==1)       edge=2;
+00603         else if(smoothBorderY==-1)      edge=3;
+00604         else nlstop;
+00605 
+00606         // If the edge is smoothed, blend with neighbor.
+00607         if(getSmoothFlag(edge))
+00608         {
+00609                 // Build the bindInfo against this edge.
+00610                 getBindNeighbor(edge, bindInfo);
+00611 
+00612                 // Fast reject: if no neighbor, just do a simple computeDisplaceInteriorSmooth.
+00613                 if(!bindInfo.Zone)
+00614                         return bpatch->evalNormal(s/getOrderS(), t/getOrderT());
+00615                 else
+00616                 {
+00617                         CVector         r0, r1;
+00618 
+00619                         // Compute our contribution.
+00620                         r0= bpatch->evalNormal(s/getOrderS(), t/getOrderT());
+00621 
+00622                         // Compute the coordinate on the border of the edge, and the coef of the blend.
+00623                         float           se=s;
+00624                         float           te=t;
+00625                         float           coef=0.0;
+00626                         if(smoothBorderX==-1)           se= noiseFloorF(se), coef=s-se;
+00627                         else if(smoothBorderX==1)       se= noiseCeilF(se), coef=se-s;
+00628                         else if(smoothBorderY==-1)      te= noiseFloorF(te), coef=t-te;
+00629                         else if(smoothBorderY==1)       te= noiseCeilF(te), coef=te-t;
+00630                         coef= 0.5f + coef*0.5f;
+00631 
+00632                         // Compute contribution of the normal on the neighbor, on the border of the edge.
+00633                         CPatchUVLocator         uvLocator;
+00634                         CVector2f       stIn, stOut;
+00635                         CPatch          *patchOut;
+00636                         uint            patchId;
+00637 
+00638                         uvLocator.build(this, edge, bindInfo);
+00639                         stIn.set(se, te);
+00640                         patchId= uvLocator.selectPatch(stIn);
+00641                         uvLocator.locateUV(stIn, patchId, patchOut, stOut);
+00642 
+00643                         bpatch= patchOut->unpackIntoCache();
+00644                         r1= bpatch->evalNormal(stOut.x/patchOut->getOrderS(), stOut.y/patchOut->getOrderT());
+00645 
+00646                         // NB: don't bother problems with bind 1/X and the choice of the patch, because bind are C1, so normal is C0.
+00647 
+00648                         // Blend 2 result. For speed optim, don't normalize.
+00649                         return r0*coef + r1*(1-coef);
+00650                 }
+00651         }
+00652         // else blend with vector Null.
+00653         else
+00654         {
+00655                 // compute coef.
+00656                 float           se=s;
+00657                 float           te=t;
+00658                 float           coef=0.0;
+00659                 if(smoothBorderX==-1)           se= noiseFloorF(se), coef=s-se;
+00660                 else if(smoothBorderX==1)       se= noiseCeilF(se), coef=se-s;
+00661                 else if(smoothBorderY==-1)      te= noiseFloorF(te), coef=t-te;
+00662                 else if(smoothBorderY==1)       te= noiseCeilF(te), coef=te-t;
+00663 
+00664                 // Compute our contribution.
+00665                 CVector         r0;
+00666                 r0= bpatch->evalNormal(s/getOrderS(), t/getOrderT());
+00667 
+00668                 // Blend with 0.
+00669                 return r0*coef;
+00670         }
+00671 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
CVector NL3D::CPatch::computeNormalOnNeighbor float  s,
float  t,
uint  edgeExclude
const [private]
+
+ + + + + +
+   + + +

+same reasoning as in computeDisplaceRawOnNeighbor(). +

+Definition at line 675 of file patch_noise.cpp. +

+References NL3D::CPatchUVLocator::build(), NL3D::CBezierPatch::evalNormal(), getBindNeighbor(), getOrderS(), getOrderT(), NL3D::CPatchUVLocator::locateUV(), s, NL3D::CPatchUVLocator::selectPatch(), NLMISC::CVector2f::set(), sint, t, uint, unpackIntoCache(), NLMISC::CVector2f::x, NLMISC::CVector2f::y, and NL3D::CPatch::CBindInfo::Zone. +

+Referenced by computeNormalCornerSmooth(). +

+

00676 {
+00677         sint    edge= -1;
+00678 
+00679         // look on what neighbor patch we must find the value (if any).
+00680         if(s<1 && edgeExclude!=0)                               edge=0;
+00681         else if(t>OrderT-1 && edgeExclude!=1)   edge=1;
+00682         else if(s>OrderS-1 && edgeExclude!=2)   edge=2;
+00683         else if(t<1 && edgeExclude!=3)                  edge=3;
+00684 
+00685 
+00686         // If the location is In the patch, just return normal value. (case of a bind 1/X).
+00687         if(edge==-1)
+00688         {
+00689                 CBezierPatch    *bpatch= unpackIntoCache();
+00690                 return bpatch->evalNormal(s/getOrderS(), t/getOrderT());
+00691         }
+00692         // else must find on neighbor.
+00693         else
+00694         {
+00695                 CBindInfo       bindInfo;
+00696                 getBindNeighbor(edge, bindInfo);
+00697 
+00698                 // Fast reject: if no neighbor on the edge, just do a simple computeDisplaceRaw()
+00699                 if(!bindInfo.Zone)
+00700                 {
+00701                         CBezierPatch    *bpatch= unpackIntoCache();
+00702                         return bpatch->evalNormal(s/getOrderS(), t/getOrderT());
+00703                 }
+00704                 // else must find on neighbor.
+00705                 else
+00706                 {
+00707                         CPatchUVLocator         uvLocator;
+00708                         uvLocator.build(this, edge, bindInfo);
+00709 
+00710                         CVector2f       stIn;
+00711                         CVector2f       stOut;
+00712                         CPatch          *patchOut;
+00713                         uint            patchId;
+00714 
+00715                         // look on neighbor. same reasoning as in computeDisplaceEdgeSmooth();
+00716                         stIn.set(s, t);
+00717                         patchId= uvLocator.selectPatch(stIn);
+00718                         uvLocator.locateUV(stIn, patchId, patchOut, stOut);
+00719                         CBezierPatch    *bpatch= patchOut->unpackIntoCache();
+00720                         return bpatch->evalNormal(stOut.x/patchOut->getOrderS(), stOut.y/patchOut->getOrderT());
+00721                 }
+00722 
+00723         }
+00724 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CPatch::computeSoftwareGeomorphAndAlpha  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 1378 of file patch_render.cpp. +

+References computeGeomorphAlphaFar1VertexListVB(), computeGeomorphFar0VertexListVB(), computeGeomorphTileVertexListVB(), computeGeomorphVertexList(), NL3D::CTessBlock::FarVertexList, NL3D::CTessBlock::getClipped(), isRenderClipped(), MasterBlock, NL3D::CTessBlock::NearVertexList, sint, NLMISC::CObjectVector< CTessBlock >::size(), TessBlocks, NL3D::CTessBlock::visibleFar0(), NL3D::CTessBlock::visibleFar1(), and NL3D::CTessBlock::visibleTile(). +

+Referenced by NL3D::CLandscape::render(). +

+

01379 {
+01380         if(isRenderClipped())
+01381                 return;
+01382 
+01383         // Compute Geomorph.
+01384         //=======
+01385         // Need only to fill CTessVertex, so do it only for FarVertices
+01386         // Hence Geomorph is done twice on edges of patches!!.
+01387         // If not too near for precise, fast compute of geomorph.
+01388         if( TessBlocks.size()==0 )
+01389         {
+01390                 // Just update all vertices of master block.
+01391                 computeGeomorphVertexList(MasterBlock.FarVertexList);
+01392         }
+01393         else
+01394         {
+01395                 // update all vertices of master block.
+01396                 computeGeomorphVertexList(MasterBlock.FarVertexList);
+01397                 // update vertices of others block.
+01398                 for(sint i=0; i<(sint)TessBlocks.size(); i++)
+01399                 {
+01400                         CTessBlock      &tblock= TessBlocks[i];
+01401                         // Precise Clip.
+01402                         if(!tblock.getClipped())
+01403                         {
+01404                                 // compute the geomorph of the vertices in the tessblock.
+01405                                 computeGeomorphVertexList(tblock.FarVertexList);
+01406                         }
+01407                 }
+01408         }
+01409 
+01410 
+01411         // Fill Far0.
+01412         //=======
+01413         if(Far0>0)
+01414         {
+01415                 // Fill Far0 VB.
+01416                 computeGeomorphFar0VertexListVB(MasterBlock.FarVertexList);
+01417                 for(sint i=0; i<(sint)TessBlocks.size(); i++)
+01418                 {
+01419                         CTessBlock      &tblock= TessBlocks[i];
+01420                         // Precise Clip.
+01421                         if( tblock.visibleFar0() )
+01422                                 computeGeomorphFar0VertexListVB(tblock.FarVertexList);
+01423                 }
+01424         }
+01425         else if(Far0==0)
+01426         {
+01427                 // Fill Tile VB.
+01428                 // No Tiles in MasterBlock!!
+01429                 // Traverse the TessBlocks to compute vertices.
+01430                 for(sint i=0; i<(sint)TessBlocks.size(); i++)
+01431                 {
+01432                         CTessBlock      &tblock= TessBlocks[i];
+01433                         // Precise Clip.
+01434                         if( tblock.visibleTile() )
+01435                                 computeGeomorphTileVertexListVB(tblock.NearVertexList);
+01436                 }
+01437         }
+01438 
+01439         // Fill Far1.
+01440         //=======
+01441         if(Far1>0)
+01442         {
+01443                 // Fill VB.
+01444                 computeGeomorphAlphaFar1VertexListVB(MasterBlock.FarVertexList);
+01445                 for(sint i=0; i<(sint)TessBlocks.size(); i++)
+01446                 {
+01447                         CTessBlock      &tblock= TessBlocks[i];
+01448                         // Precise Clip.
+01449                         if( tblock.visibleFar1() )
+01450                                 computeGeomorphAlphaFar1VertexListVB(tblock.FarVertexList);
+01451                 }
+01452         }
+01453 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::computeTbTm uint numtb,
uint numtm,
uint  ts,
uint  tt
[private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 942 of file patch.cpp. +

+References sint, and uint. +

+Referenced by appendNearVertexToRenderList(), appendTileMaterialToRenderList(), getTileLightMap(), getTileLightMapUvInfo(), releaseTileLightMap(), removeNearVertexFromRenderList(), and removeTileMaterialFromRenderList(). +

+

00943 {
+00944         sint    is= ts&1;
+00945         sint    it= tt&1;
+00946         ts>>=1;
+00947         tt>>=1;
+00948         
+00949         numtb= tt*(uint)(OrderS>>1) + ts;
+00950         numtm= it*2+is;
+00951 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::computeTileLightmap uint  ts,
uint  tt,
NLMISC::CRGBA dest,
uint  stride
[private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 750 of file patch_lightmap.cpp. +

+References addTileLightmapWithTLI(), computeTileLightmapAutomatic(), computeTileLightmapPrecomputed(), NL3D::CLandscape::getAutomaticLighting(), getLandscape(), modulateTileLightmapWithTileColors(), stride, and uint. +

+Referenced by computeNearBlockLightmap(). +

+

00751 {
+00752         if(getLandscape()->getAutomaticLighting())
+00753                 computeTileLightmapAutomatic(ts, tt, dest, stride);
+00754         else
+00755         {
+00756                 computeTileLightmapPrecomputed(ts, tt, dest, stride);
+00757                 // Add the inlufence of TLI.
+00758                 addTileLightmapWithTLI(ts, tt, dest, stride);
+00759         }
+00760 
+00761         // modulate dest with tileColors (at center of lumels).
+00762         modulateTileLightmapWithTileColors(ts, tt, dest, stride);
+00763 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::computeTileLightmapAutomatic uint  ts,
uint  tt,
NLMISC::CRGBA dest,
uint  stride
[private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 557 of file patch_lightmap.cpp. +

+References computeTileLightmapPixelAutomatic(), NL_LUMEL_BY_TILE, stride, uint, x, and y. +

+Referenced by computeTileLightmap(). +

+

00558 {
+00559         uint    x, y;
+00560         for(y=0; y<NL_LUMEL_BY_TILE; y++)
+00561         {
+00562                 for(x=0; x<NL_LUMEL_BY_TILE; x++)
+00563                 {
+00564                         // compute this pixel.
+00565                         computeTileLightmapPixelAutomatic(ts, tt, x, y, dest+ y*stride + x);
+00566                 }
+00567         }
+00568 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::computeTileLightmapEdge uint  ts,
uint  tt,
uint  edge,
NLMISC::CRGBA dest,
uint  stride,
bool  inverse
[private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 765 of file patch_lightmap.cpp. +

+References addTileLightmapEdgeWithTLI(), computeTileLightmapEdgeAutomatic(), computeTileLightmapEdgePrecomputed(), NL3D::CLandscape::getAutomaticLighting(), getLandscape(), modulateTileLightmapEdgeWithTileColors(), stride, and uint. +

+Referenced by computeNearBlockLightmap(). +

+

00766 {
+00767         if(getLandscape()->getAutomaticLighting())
+00768                 computeTileLightmapEdgeAutomatic(ts, tt, edge, dest, stride, inverse);
+00769         else
+00770         {
+00771                 computeTileLightmapEdgePrecomputed(ts, tt, edge, dest, stride, inverse);
+00772                 // Add the inlufence of TLI.
+00773                 addTileLightmapEdgeWithTLI(ts, tt, edge, dest, stride, inverse);
+00774         }
+00775 
+00776         // modulate dest with tileColors (at center of lumels).
+00777         modulateTileLightmapEdgeWithTileColors(ts, tt, edge, dest, stride, inverse);
+00778 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::computeTileLightmapEdgeAutomatic uint  ts,
uint  tt,
uint  edge,
NLMISC::CRGBA dest,
uint  stride,
bool  inverse
[private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 571 of file patch_lightmap.cpp. +

+References computeTileLightmapPixelAutomatic(), NL_LUMEL_BY_TILE, stride, uint, x, and y. +

+Referenced by computeTileLightmapEdge(). +

+

00572 {
+00573         // get coordinate according to edge.
+00574         uint    x=0,y=0;
+00575         switch(edge)
+00576         {
+00577         case 0: x= 0; break;
+00578         case 1: y= NL_LUMEL_BY_TILE-1; break;
+00579         case 2: x= NL_LUMEL_BY_TILE-1; break;
+00580         case 3: y= 0; break;
+00581         };
+00582 
+00583         uint    i;
+00584         for(i=0; i<NL_LUMEL_BY_TILE; i++)
+00585         {
+00586                 // if vertical edge
+00587                 if( (edge&1)==0 )       y= i;
+00588                 // else horizontal edge
+00589                 else                            x= i;
+00590 
+00591                 // manage inverse.
+00592                 uint    where;
+00593                 if(inverse)             where= (NL_LUMEL_BY_TILE-1)-i;
+00594                 else                    where= i;
+00595                 // compute this pixel.
+00596                 computeTileLightmapPixelAutomatic(ts, tt, x, y, dest+ where*stride);
+00597         }
+00598 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::computeTileLightmapEdgePrecomputed uint  ts,
uint  tt,
uint  edge,
NLMISC::CRGBA dest,
uint  stride,
bool  inverse
[private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 704 of file patch_lightmap.cpp. +

+References CompressedLumels, getLandscape(), NL3D::CLandscape::getStaticLight(), NL3D::getUnpackLumelBlock(), NL3D::NL3DDeltaLumel, NL3D::NL3DPixelStartLumel, NL_BLOCK_LUMEL_COMPRESSED_SIZE, src, stride, uint, uint8, and x. +

+Referenced by computeTileLightmapEdge(). +

+

00705 {
+00706         // Lumel table
+00707         const CRGBA* colorTable=getLandscape ()->getStaticLight ();
+00708 
+00709         // Witch corner to start ?
+00710         uint pixel=NL3DPixelStartLumel[edge];
+00711         uint delta=NL3DDeltaLumel[edge];
+00712 
+00713         // For each lumels
+00714         const uint8 *src=&(CompressedLumels[(ts + (tt*OrderS))*NL_BLOCK_LUMEL_COMPRESSED_SIZE]);
+00715         uint x;
+00716         if (inverse)
+00717         {
+00718                 uint inverseStride=stride*(4-1);
+00719                 for(x=0; x<4; x++)
+00720                 {
+00721                         // lumel
+00722                         dest[inverseStride-x*stride]=colorTable[getUnpackLumelBlock (src, pixel)];
+00723                         pixel+=delta;
+00724                 }
+00725         }
+00726         else
+00727         {
+00728                 for(x=0; x<4; x++)
+00729                 {
+00730                         // lumel
+00731                         dest[x*stride]=colorTable[getUnpackLumelBlock (src, pixel)];
+00732                         pixel+=delta;
+00733                 }
+00734         }
+00735 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::computeTileLightmapPixel uint  ts,
uint  tt,
uint  s,
uint  t,
NLMISC::CRGBA dest
[private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 782 of file patch_lightmap.cpp. +

+References addTileLightmapPixelWithTLI(), computeTileLightmapPixelAutomatic(), computeTileLightmapPixelPrecomputed(), NL3D::CLandscape::getAutomaticLighting(), getLandscape(), modulateTileLightmapPixelWithTileColors(), s, t, and uint. +

+Referenced by computeNearBlockLightmap(), and computeTileLightmapPixelAroundCorner(). +

+

00783 {
+00784         if(getLandscape()->getAutomaticLighting())
+00785                 computeTileLightmapPixelAutomatic(ts, tt, s, t, dest);
+00786         else
+00787         {
+00788                 computeTileLightmapPixelPrecomputed(ts, tt, s, t, dest);
+00789                 // Add the inlufence of TLI.
+00790                 addTileLightmapPixelWithTLI(ts, tt, s, t, dest);
+00791         }
+00792 
+00793         // modulate dest with tileColors (at center of lumels).
+00794         modulateTileLightmapPixelWithTileColors(ts, tt, s, t, dest);
+00795 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::computeTileLightmapPixelAroundCorner const NLMISC::CVector2f stIn,
NLMISC::CRGBA dest,
bool  lookAround
[private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 799 of file patch_lightmap.cpp. +

+References NL3D::CPatchUVLocator::build(), computeTileLightmapPixel(), getBindNeighbor(), NL3D::CPatchUVLocator::locateUV(), NL_LUMEL_BY_TILE, NL_LUMEL_BY_TILE_SHIFT, NL3D::CPatchUVLocator::selectPatch(), sint, uint, v, NLMISC::CVector2f::x, NLMISC::CVector2f::y, and NL3D::CPatch::CBindInfo::Zone. +

+Referenced by computeNearBlockLightmap(). +

+

00800 {
+00801         bool    mustLookOnNeighbor= false;
+00802 
+00803         // Get the Uv, in [0,Order?*NL_LUMEL_BY_TILE] basis (ie lumel basis).
+00804         sint    u, v;
+00805         u= (sint)floor(stIn.x*NL_LUMEL_BY_TILE);
+00806         v= (sint)floor(stIn.y*NL_LUMEL_BY_TILE);
+00807 
+00808         // if allowed, try to go on neighbor patch.
+00809         if(lookAround)
+00810         {
+00811                 // try to know if we must go on a neighbor patch (maybe false with bind X/1).
+00812                 if( u<0 || u>=OrderS*NL_LUMEL_BY_TILE || v<0 || v>=OrderT*NL_LUMEL_BY_TILE)
+00813                         mustLookOnNeighbor= true;
+00814         }
+00815 
+00816 
+00817         // If we must get (if possible) the pixel in the current patch, do it.
+00818         if(!mustLookOnNeighbor)
+00819         {
+00820                 // if out this patch, abort.
+00821                 if( u<0 || u>=OrderS*NL_LUMEL_BY_TILE || v<0 || v>=OrderT*NL_LUMEL_BY_TILE)
+00822                         return;
+00823                 else
+00824                 {
+00825                         // get this pixel.
+00826                         computeTileLightmapPixel(u>>NL_LUMEL_BY_TILE_SHIFT, v>>NL_LUMEL_BY_TILE_SHIFT, u&(NL_LUMEL_BY_TILE-1), v&(NL_LUMEL_BY_TILE-1), dest);
+00827                 }
+00828         }
+00829         // else get from the best neighbor patch.
+00830         else
+00831         {
+00832                 // choose against which edge we must find the pixel.
+00833                 uint    edge=0;
+00834                 if(u<0)                                 edge=0;
+00835                 else if(v>=OrderT*NL_LUMEL_BY_TILE)     edge=1;
+00836                 else if(u>=OrderS*NL_LUMEL_BY_TILE)     edge=2;
+00837                 else if(v<0)                    edge=3;
+00838 
+00839                 // retrieve info on neighbor.
+00840                 CBindInfo                       bindInfo;
+00841                 getBindNeighbor(edge, bindInfo);
+00842 
+00843                 // if neighbor present.
+00844                 if(bindInfo.Zone)
+00845                 {
+00846                         CVector2f       stOut;
+00847                         CPatch          *patchOut;
+00848                         uint            patchId;
+00849 
+00850                         // Ok, search uv on this patch.
+00851                         CPatchUVLocator         uvLocator;
+00852                         uvLocator.build(this, edge, bindInfo);
+00853                         patchId= uvLocator.selectPatch(stIn);
+00854                         uvLocator.locateUV(stIn, patchId, patchOut, stOut);
+00855 
+00856                         // retry only one time, so at next call, must find the data IN htis patch (else abort).
+00857                         patchOut->computeTileLightmapPixelAroundCorner(stOut, dest, false);
+00858                 }
+00859         }
+00860 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::computeTileLightmapPixelAutomatic uint  ts,
uint  tt,
uint  s,
uint  t,
NLMISC::CRGBA dest
[private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 601 of file patch_lightmap.cpp. +

+References NLMISC::clamp(), computeVertex(), NL3D::CLandscape::getAutomaticLightDir(), getLandscape(), NL3D::CLandscape::getStaticLight(), NL_LUMEL_BY_TILE, NLMISC::CVector::normalize(), s, sint, t, uint, and v. +

+Referenced by computeTileLightmapAutomatic(), computeTileLightmapEdgeAutomatic(), and computeTileLightmapPixel(). +

+

00602 {
+00603         float           u,v;
+00604         static const float      lumelSize= 1.f/NL_LUMEL_BY_TILE;
+00605 
+00606         // use 3 computeVertex to compute a normal. This is slow....
+00607         CVector         p0, p1 ,p2;
+00608         // 1st vert. Top-left of the lumel.
+00609         u= (ts + s*lumelSize )/OrderS;
+00610         v= (tt + t*lumelSize )/OrderT;
+00611         p0= computeVertex(u, v);
+00612         // 2nd vert. Bottom-left of the lumel.
+00613         u= (ts + s*lumelSize )/OrderS;
+00614         v= (tt + (t+1)*lumelSize )/OrderT;
+00615         p1= computeVertex(u, v);
+00616         // 3rd vert. Center-Right of the lumel.
+00617         u= (ts + (s+1)*lumelSize )/OrderS;
+00618         v= (tt + (t+0.5f)*lumelSize )/OrderT;
+00619         p2= computeVertex(u, v);
+00620 
+00621         // the normal.
+00622         CVector         normal;
+00623         normal= (p1-p0)^(p2-p0);
+00624         normal.normalize();
+00625 
+00626         // lighting.
+00627         float   c= -normal*getLandscape()->getAutomaticLightDir();
+00628         c= max(c, 0.f);
+00629         sint    ic;
+00630 
+00631 #ifdef NL_OS_WINDOWS
+00632         // FastFloor using fistp. Don't care convention.
+00633         float   fc= c*256;
+00634         _asm
+00635         {
+00636                 fld fc
+00637                 fistp ic
+00638         }
+00639 #else
+00640         ic= (sint)floor(c*256);
+00641 #endif
+00642         clamp(ic, 0, 255);
+00643 
+00644         // ambiant/diffuse lighting.
+00645         *dest= getLandscape()->getStaticLight()[ic];
+00646 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::computeTileLightmapPixelPrecomputed uint  ts,
uint  tt,
uint  s,
uint  t,
NLMISC::CRGBA dest
[private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 738 of file patch_lightmap.cpp. +

+References CompressedLumels, getLandscape(), NL3D::CLandscape::getStaticLight(), NL3D::getUnpackLumelBlock(), NL_BLOCK_LUMEL_COMPRESSED_SIZE, s, t, and uint. +

+Referenced by computeTileLightmapPixel(). +

+

00739 {
+00740         // Lumel table
+00741         const CRGBA* colorTable=getLandscape ()->getStaticLight ();
+00742 
+00743         // Return the lumel
+00744         *dest=colorTable[getUnpackLumelBlock (&(CompressedLumels[(ts + (tt*OrderS))*NL_BLOCK_LUMEL_COMPRESSED_SIZE]), s+(t<<2))];
+00745 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::computeTileLightmapPrecomputed uint  ts,
uint  tt,
NLMISC::CRGBA dest,
uint  stride
[private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 678 of file patch_lightmap.cpp. +

+References buffer, CompressedLumels, getLandscape(), NL3D::CLandscape::getStaticLight(), NL_BLOCK_LUMEL_COMPRESSED_SIZE, NL_LUMEL_BY_TILE, NL_LUMEL_BY_TILE_SHIFT, stride, uint, uint8, unpackLumelBlock(), x, and y. +

+Referenced by computeTileLightmap(). +

+

00679 {
+00680         // Lumel table
+00681         const CRGBA* colorTable=getLandscape ()->getStaticLight ();
+00682         // Unpack the lumels
+00683         uint8 buffer[NL_LUMEL_BY_TILE*NL_LUMEL_BY_TILE];
+00684         unpackLumelBlock (buffer, &(CompressedLumels[(ts + (tt*OrderS))*NL_BLOCK_LUMEL_COMPRESSED_SIZE]));
+00685 
+00686         // Retrun it
+00687         uint    x, y;
+00688         for(y=0; y<NL_LUMEL_BY_TILE; y++)
+00689         {
+00690                 for(x=0; x<NL_LUMEL_BY_TILE; x++)
+00691                 {
+00692                         // lumel
+00693                         dest[y*stride + x]=colorTable[buffer[x+(y<<NL_LUMEL_BY_TILE_SHIFT)]];
+00694                 }
+00695         }
+00696 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
CVector NL3D::CPatch::computeVertex float  s,
float  t
const
+
+ + + + + +
+   + + +

+Compute a vertex. Compute a vertex according to:

    +
  • s,t
  • patch control points uncompressed with zone Bias/Scale.
+

+Patch UV geometric correction.

    +
  • Patch noise (and noise of Patch neighbor).
+ +

+Definition at line 1338 of file patch.cpp. +

+References computeNoise(), NL3D::CBezierPatch::eval(), getLandscape(), NL3D::CLandscape::getNoiseMode(), s, t, and unpackIntoCache(). +

+Referenced by addTileTrianglesInBBox(), NL3D::CTessFace::averageTesselationVertices(), averageTesselationVertices(), bind(), NL3D::CLandscape::buildCollideFaces(), computeContinousVertex(), computeTileLightmapPixelAutomatic(), computeVertexButCorner(), NL3D::CLandscapeVegetableBlockCreateContext::eval(), makeRoots(), NL3D::CZoneLighter::processZonePointLightRT(), NL3D::CTessFace::refreshTesselationGeometry(), refreshTesselationGeometry(), NL3D::CTessFace::split(), and NL3D::CTessFace::splitRectangular(). +

+

01339 {
+01340         // \todo yoyo: TODO_UVCORRECT: use UV correction.
+01341 
+01342         if(getLandscape()->getNoiseMode())
+01343         {
+01344                 // compute displacement map to disturb result.
+01345                 CVector         displace;
+01346                 computeNoise(s,t, displace);
+01347 
+01348                 // return patch(s,t) + dispalcement result.
+01349                 // unpack. Do it after computeNoise(), because this last may change the cache.
+01350                 CBezierPatch    *patch= unpackIntoCache();
+01351                 return patch->eval(s,t) + displace;
+01352         }
+01353         else
+01354         {
+01355                 // unpack and return patch(s,t).
+01356                 CBezierPatch    *patch= unpackIntoCache();
+01357                 return patch->eval(s,t);
+01358         }
+01359 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
CVector NL3D::CPatch::computeVertexButCorner float  s,
float  t,
bool &  onCorner
const [private]
+
+ + + + + +
+   + + +

+Used by computeContinousVertex(). +

+ +

+Definition at line 1456 of file patch.cpp. +

+References BaseVertices, computeVertex(), NL3D::CTessVertex::EndPos, nlassert, nlstop, s, sint, and t. +

+Referenced by computeContinousVertex(). +

+

01457 {
+01458         // must be compiled
+01459         nlassert(Zone);
+01460 
+01461         // Test is on a edge/corner of the patch
+01462         sint    edgeIdS= -1;
+01463         sint    edgeIdT= -1;
+01464         if(s==0)                edgeIdS= 0;
+01465         else if(s==1)   edgeIdS= 2;
+01466         if(t==0)                edgeIdT= 3;
+01467         else if(t==1)   edgeIdT= 1;
+01468 
+01469         // test if on a corner
+01470         if(edgeIdS>=0 && edgeIdT>=0)
+01471         {
+01472                 // indicate that yes, we are on a corner
+01473                 onCorner= true;
+01474                 // return the baseVertex according to edge falgs
+01475                 if(edgeIdS==0 && edgeIdT==3)    return BaseVertices[0]->EndPos;
+01476                 if(edgeIdS==0 && edgeIdT==1)    return BaseVertices[1]->EndPos;
+01477                 if(edgeIdS==2 && edgeIdT==1)    return BaseVertices[2]->EndPos;
+01478                 if(edgeIdS==2 && edgeIdT==3)    return BaseVertices[3]->EndPos;
+01479                 nlstop;
+01480                 // Error, but Avoid warning
+01481                 return CVector::Null;
+01482         }
+01483         // else, std case
+01484         else
+01485         {
+01486                 onCorner= false;
+01487                 return computeVertex(s, t);
+01488         }
+01489 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::copyTileFlagsFromPatch const CPatch src  ) 
+
+ + + + + +
+   + + +

+Set this patch flags from an other one. The patchs must match +

+Definition at line 2245 of file patch.cpp. +

+References nlassert, src, Tiles, and uint. +

+Referenced by NL3D::CZone::copyTilesFlags(). +

+

02246 {
+02247         nlassert(OrderS == src->OrderS
+02248                          && OrderT == src->OrderT);
+02249 
+02250         for (uint k = 0; k  < Tiles.size(); ++k)
+02251         {
+02252                 Tiles[k].copyFlagsFromOther(src->Tiles[k]);
+02253         }
+02254 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
CRGBA NL3D::CPatch::CPatch::getCurrentTLIColor uint  x,
uint  y
const [private]
+
+ + + + + +
+   + + +

+

+

+ + + + +
+ + + + + + + + + +
void NL3D::CPatch::createFaceVectorFar0OrTile  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 663 of file patch_render.cpp. +

+References NL3D::CTessBlock::createFaceVectorFar0(), getLandscape(), MasterBlock, NLMISC::CObjectVector< CTessBlock >::size(), TessBlocks, and uint. +

+Referenced by allocateVBAndFaceVector(). +

+

00664 {
+00665         // If Far Mode.
+00666         if(Far0>0)
+00667         {
+00668                 // Create the face for all TessBlocks.
+00669                 MasterBlock.createFaceVectorFar0(getLandscape()->_FaceVectorManager);
+00670                 for(uint i=0; i<TessBlocks.size(); i++)
+00671                         TessBlocks[i].createFaceVectorFar0(getLandscape()->_FaceVectorManager);
+00672         }
+00673         // Or If Tile Mode.
+00674         else if(Far0==0)
+00675         {
+00676                 // Create the face for all TessBlocks.
+00677                 // No tiles in MasterBlock!
+00678                 for(uint i=0; i<TessBlocks.size(); i++)
+00679                         TessBlocks[i].createFaceVectorTile(getLandscape()->_FaceVectorManager);
+00680         }
+00681 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CPatch::createFaceVectorFar1  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 641 of file patch_render.cpp. +

+References NL3D::CTessBlock::createFaceVectorFar1(), getLandscape(), MasterBlock, NLMISC::CObjectVector< CTessBlock >::size(), TessBlocks, and uint. +

+Referenced by allocateVBAndFaceVector(), and allocateVBAndFaceVectorFar1Only(). +

+

00642 {
+00643         if(Far1>0)
+00644         {
+00645                 // Create the face for all TessBlocks.
+00646                 MasterBlock.createFaceVectorFar1(getLandscape()->_FaceVectorManager);
+00647                 for(uint i=0; i<TessBlocks.size(); i++)
+00648                         TessBlocks[i].createFaceVectorFar1(getLandscape()->_FaceVectorManager);
+00649         }
+00650 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::createVegetableBlock uint  numTb,
uint  ts,
uint  tt
[private]
+
+ + + + + +
+   + + +

+Create / init the vegetableBlock in the corresponding TessBlock. TessBlocks must exist. +

+ +

+Definition at line 294 of file patch_vegetable.cpp. +

+References NL3D::CBezierPatch::eval(), getLandscape(), NL3D::CLandscapeVegetableBlock::init(), NL3D_PATCH_VEGETABLE_NUM_TESSBLOCK_PER_CLIPBLOCK, NL3D_PATCH_VEGETABLE_NUM_TESSBLOCK_PER_CLIPBLOCK_SHIFT, TessBlocks, uint, unpackIntoCache(), and VegetableClipBlocks. +

+Referenced by appendTileMaterialToRenderList(), and recreateAllVegetableIgs(). +

+

00295 {
+00296         // TessBlock width
+00297         uint    tbWidth= OrderS >> 1;
+00298         // clipBlock width
+00299         uint    nTbPerCb= NL3D_PATCH_VEGETABLE_NUM_TESSBLOCK_PER_CLIPBLOCK;
+00300         uint    cbWidth= (tbWidth + nTbPerCb-1) >> NL3D_PATCH_VEGETABLE_NUM_TESSBLOCK_PER_CLIPBLOCK_SHIFT;
+00301 
+00302         // compute tessBlock coordinate.
+00303         uint    tbs ,tbt;
+00304         tbs= ts >> 1;
+00305         tbt= tt >> 1;
+00306         // compute clipBlock coordinate.
+00307         uint    cbs,cbt;
+00308         cbs= tbs >> NL3D_PATCH_VEGETABLE_NUM_TESSBLOCK_PER_CLIPBLOCK_SHIFT;
+00309         cbt= tbt >> NL3D_PATCH_VEGETABLE_NUM_TESSBLOCK_PER_CLIPBLOCK_SHIFT;
+00310 
+00311         // create the vegetable block.
+00312         CLandscapeVegetableBlock                *vegetBlock= new CLandscapeVegetableBlock;
+00313         // Init / append to list.
+00314         // compute center of the vegetableBlock (approx).
+00315         CBezierPatch    *bpatch= unpackIntoCache();
+00316         CVector         center= bpatch->eval( (float)(tbs*2+1)/OrderS, (float)(tbt*2+1)/OrderT );
+00317         // Lower-Left tile is (tbs*2, tbt*2)
+00318         vegetBlock->init(center, getLandscape()->_VegetableManager, VegetableClipBlocks[cbt *cbWidth + cbs], this, tbs*2, tbt*2, getLandscape()->_VegetableBlockList);
+00319 
+00320         // set in the tessBlock
+00321         TessBlocks[numTb].VegetableBlock= vegetBlock;
+00322 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::debugAllocationMarkIndices uint  marker  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 914 of file patch_render.cpp. +

+References debugAllocationMarkIndicesFarList(), debugAllocationMarkIndicesNearList(), NL3D::CTessBlock::FarVertexList, MasterBlock, NL3D::CTessBlock::NearVertexList, sint, NLMISC::CObjectVector< CTessBlock >::size(), TessBlocks, and uint. +

+

00915 {
+00916         sint i;
+00917 
+00918         // Do it For Far.
+00919         debugAllocationMarkIndicesFarList(MasterBlock.FarVertexList, marker);
+00920         for(i=0; i<(sint)TessBlocks.size(); i++)
+00921         {
+00922                 CTessBlock      &tblock= TessBlocks[i];
+00923                 debugAllocationMarkIndicesFarList(tblock.FarVertexList, marker);
+00924         }
+00925         // Do it For Near.
+00926         // No Tiles in MasterBlock!!
+00927         for(i=0; i<(sint)TessBlocks.size(); i++)
+00928         {
+00929                 CTessBlock      &tblock= TessBlocks[i];
+00930                 debugAllocationMarkIndicesNearList(tblock.NearVertexList, marker);
+00931         }
+00932 
+00933 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::debugAllocationMarkIndicesFarList CTessList< CTessFarVertex > &  vertList,
uint  marker
[private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 893 of file patch_render.cpp. +

+References NL3D::CTessList< T >::begin(), NL3D::CTessFarVertex::Index0, NL3D::CTessFarVertex::Index1, NL3D::CTessNodeList::Next, and uint. +

+Referenced by debugAllocationMarkIndices(). +

+

00894 {
+00895         // Traverse the vertList.
+00896         CTessFarVertex  *pVert;
+00897         for(pVert= vertList.begin(); pVert; pVert= (CTessFarVertex*)pVert->Next)
+00898         {
+00899                 pVert->Index0= marker;
+00900                 pVert->Index1= marker;
+00901         }
+00902 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::debugAllocationMarkIndicesNearList CTessList< CTessNearVertex > &  vertList,
uint  marker
[private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 904 of file patch_render.cpp. +

+References NL3D::CTessList< T >::begin(), NL3D::CTessNearVertex::Index, NL3D::CTessNodeList::Next, and uint. +

+Referenced by debugAllocationMarkIndices(). +

+

00905 {
+00906         // Traverse the vertList.
+00907         CTessNearVertex *pVert;
+00908         for(pVert= vertList.begin(); pVert; pVert= (CTessNearVertex*)pVert->Next)
+00909         {
+00910                 pVert->Index= marker;
+00911         }
+00912 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::decRefDLMContext uint  count = 1  )  [private]
+
+ + + + + +
+   + + +

+Dec a ref count to the DLMContext, deleting it if refCount== 0. +

+ +

+Definition at line 1977 of file patch_lightmap.cpp. +

+References _DLMContext, _DLMContextRefCount, count, fillVBFarsDLMUvOnly(), isRenderClipped(), nlassert, and uint. +

+Referenced by endDLMLighting(), and removeTileMaterialFromRenderList(). +

+

01978 {
+01979         // the patch must be compiled.
+01980         nlassert(Zone);
+01981         nlassert(_DLMContextRefCount>0);
+01982 
+01983         // dec Ref.
+01984         _DLMContextRefCount-= count;
+01985         nlassert(_DLMContextRefCount>=0);
+01986 
+01987         // If 0, delete the context.
+01988         if(_DLMContextRefCount==0)
+01989         {
+01990                 delete _DLMContext;
+01991                 _DLMContext= NULL;
+01992 
+01993                 // If the patch is visible, it may have Far Vertices created, 
+01994                 // hence, we must reset their DLM Uvs (to point to black pixel)
+01995                 if(!isRenderClipped())
+01996                 {
+01997                         // setup DLM Uv with new _DLMContext
+01998                         fillVBFarsDLMUvOnly();
+01999                 }
+02000         }
+02001 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CPatch::decRefTessBlocks  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 658 of file patch.cpp. +

+References clearTessBlocks(), nlassert, and TessBlockRefCount. +

+Referenced by removeFaceFromRenderList(), removeFarVertexFromRenderList(), removeNearVertexFromRenderList(), and removeTileMaterialFromRenderList(). +

+

00659 {
+00660         TessBlockRefCount--;
+00661         // If no loinger need the tessblocks, delete them.
+00662         if(TessBlockRefCount==0)
+00663                 clearTessBlocks();
+00664         nlassert(TessBlockRefCount>=0);
+00665 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CPatch::deleteAllVegetableIgs  ) 
+
+ + + + + +
+   + + +

+Delete any vegetable Ig still existing in this patch. +

+ +

+Definition at line 282 of file patch_vegetable.cpp. +

+References releaseVegetableBlock(), NLMISC::CObjectVector< CTessBlock >::size(), TessBlocks, and uint. +

+Referenced by clearTessBlocks(), and NL3D::CLandscape::enableVegetable(). +

+

00283 {
+00284         // For all TessBlocks, try to release their VegetableBlock
+00285         for(uint i=0; i<TessBlocks.size(); i++)
+00286         {
+00287                 releaseVegetableBlock(i);
+00288         }
+00289 
+00290 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CPatch::deleteFaceVectorFar0OrTile  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 683 of file patch_render.cpp. +

+References NL3D::CTessBlock::deleteFaceVectorFar0(), getLandscape(), MasterBlock, NLMISC::CObjectVector< CTessBlock >::size(), TessBlocks, and uint. +

+Referenced by deleteVBAndFaceVector(). +

+

00684 {
+00685         // If Far Mode.
+00686         if(Far0>0)
+00687         {
+00688                 // delete the face for all TessBlocks.
+00689                 MasterBlock.deleteFaceVectorFar0(getLandscape()->_FaceVectorManager);
+00690                 for(uint i=0; i<TessBlocks.size(); i++)
+00691                         TessBlocks[i].deleteFaceVectorFar0(getLandscape()->_FaceVectorManager);
+00692         }
+00693         // Or If Tile Mode.
+00694         else if(Far0==0)
+00695         {
+00696                 // delete the face for all TessBlocks.
+00697                 // No tiles in MasterBlock!
+00698                 for(uint i=0; i<TessBlocks.size(); i++)
+00699                         TessBlocks[i].deleteFaceVectorTile(getLandscape()->_FaceVectorManager);
+00700         }
+00701 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CPatch::deleteFaceVectorFar1  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 652 of file patch_render.cpp. +

+References NL3D::CTessBlock::deleteFaceVectorFar1(), getLandscape(), MasterBlock, NLMISC::CObjectVector< CTessBlock >::size(), TessBlocks, and uint. +

+Referenced by deleteVBAndFaceVector(), and deleteVBAndFaceVectorFar1Only(). +

+

00653 {
+00654         if(Far1>0)
+00655         {
+00656                 // delete the face for all TessBlocks.
+00657                 MasterBlock.deleteFaceVectorFar1(getLandscape()->_FaceVectorManager);
+00658                 for(uint i=0; i<TessBlocks.size(); i++)
+00659                         TessBlocks[i].deleteFaceVectorFar1(getLandscape()->_FaceVectorManager);
+00660         }
+00661 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CPatch::deleteTileUvs  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 2142 of file patch.cpp. +

+References NL3D::CTessFace::deleteTileUvs(), Son0, and Son1. +

+

02143 {
+02144         Son0->deleteTileUvs();
+02145         Son1->deleteTileUvs();
+02146 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CPatch::deleteVBAndFaceVector  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 837 of file patch_render.cpp. +

+References deleteFaceVectorFar0OrTile(), deleteFaceVectorFar1(), and updateVBAlloc(). +

+Referenced by preRender(), release(), and updateClipPatchVB(). +

+

00838 {
+00839         updateVBAlloc(false);
+00840         deleteFaceVectorFar1();
+00841         deleteFaceVectorFar0OrTile();
+00842 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CPatch::deleteVBAndFaceVectorFar1Only  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 854 of file patch_render.cpp. +

+References deleteFaceVectorFar1(), NL3D::CTessBlock::FarVertexList, MasterBlock, sint, NLMISC::CObjectVector< CTessBlock >::size(), TessBlocks, updateFar1VBAlloc(), and NL3D::CTessBlock::visibleFar1(). +

+Referenced by preRender(). +

+

00855 {
+00856         if(Far1>0)
+00857         {
+00858                 // alloc VB.
+00859                 updateFar1VBAlloc(MasterBlock.FarVertexList, false);
+00860                 for(sint i=0; i<(sint)TessBlocks.size(); i++)
+00861                 {
+00862                         CTessBlock      &tblock= TessBlocks[i];
+00863                         // need update VB only if tessBlock is visible.
+00864                         if( tblock.visibleFar1() )
+00865                                 updateFar1VBAlloc(tblock.FarVertexList, false);
+00866                 }
+00867         }
+00868 
+00869         deleteFaceVectorFar1();
+00870 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::dirtTessBlockFaceVector CTessBlock block  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 783 of file patch.cpp. +

+References NL3D::CTessBlock::appendToModifyListAndDeleteFaceVector(), getLandscape(), NL3D::CTessBlock::isInModifyList(), and isRenderClipped(). +

+Referenced by appendFaceToRenderList(), appendFaceToTileRenderList(), removeFaceFromRenderList(), and removeFaceFromTileRenderList(). +

+

00784 {
+00785         // If patch is visible, block's faceVector should exist, but are no more valid.
+00786         if(!isRenderClipped())
+00787         {
+00788                 // If this tessBlock not already notified to modification.
+00789                 if(!tb.isInModifyList())
+00790                 {
+00791                         // Then append, and delete all FaceVector.
+00792                         // NB: delete FaceVector now, because the TessBlock himself may disapear soon.
+00793                         tb.appendToModifyListAndDeleteFaceVector(getLandscape()->_TessBlockModificationRoot, getLandscape()->_FaceVectorManager);
+00794                 }
+00795         }
+00796 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CPatch::endDLMLighting  ) 
+
+ + + + + +
+   + + +

+end Dynamic light Process, deleting the DLMContext if necessary. NB: _DLMContext->compileLighting() is not called, since done during render phase. Called by CLandscape. _DLMContext must exist +

+Definition at line 2035 of file patch_lightmap.cpp. +

+References _DLMContext, decRefDLMContext(), nlassert, and NL3D::CPatchDLMContext::OldPointLightCount. +

+Referenced by NL3D::CLandscape::computeDynamicLighting(). +

+

02036 {
+02037         nlassert(_DLMContext);
+02038 
+02039         // delete reference from old pointLight influences, at prec render() pass. _DLMContext may be deleted here,
+02040         // if no more lights use it, and if the patch is not in Near.
+02041         decRefDLMContext(_DLMContext->OldPointLightCount);
+02042 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
uint NL3D::CPatch::evalLumelBlock const uint8 original,
const uint8 unCompressed,
uint  width,
uint  height
[private]
+
+ + + + + +
+   + + +

+Eval an uncompressed 4x4 block against the original

+

See also:
packShadowMap(), unpackShadowMap()
+ +

+Definition at line 244 of file patch_lightmap.cpp. +

+References height, sint, uint, uint8, v, and width. +

+Referenced by packShadowMap(). +

+

00245 {
+00246         // Sum
+00247         uint sum=0;
+00248 
+00249         // Eval error for each..
+00250         for (uint v=0; v<height; v++)
+00251         for (uint u=0; u<width; u++)
+00252         {
+00253                 sum += abs((sint)original[v*4+u]-(sint)unCompressed[v*4+u]);
+00254         }
+00255 
+00256         // return the sum
+00257         return sum;
+00258 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::extendTessBlockWithEndPos CTessFace face  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 766 of file patch.cpp. +

+References NL3D::CTessVertex::EndPos, getNumTessBlock(), NL3D::CTessFace::Level, TessBlockLimitLevel, TessBlocks, uint, NL3D::CTessFace::VBase, NL3D::CTessFace::VLeft, and NL3D::CTessFace::VRight. +

+Referenced by NL3D::CTessFace::refreshTesselationGeometry(). +

+

00767 {
+00768         if(face->Level>=TessBlockLimitLevel)
+00769         {
+00770                 // get the tessBlock of the face.
+00771                 uint    numtb= getNumTessBlock(face);
+00772 
+00773                 // Must enlarge the BSphere of the tesblock!!
+00774                 TessBlocks[numtb].extendSphereFirst(face->VBase->EndPos);
+00775                 TessBlocks[numtb].extendSphereAdd(face->VLeft->EndPos);
+00776                 TessBlocks[numtb].extendSphereAdd(face->VRight->EndPos);
+00777                 TessBlocks[numtb].extendSphereCompile();
+00778         }
+00779 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::fillFar0DLMUvOnlyVertexListVB CTessList< CTessFarVertex > &  vertList  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 1609 of file patch_render.cpp. +

+References _DLMContext, NL3D::CTessList< T >::begin(), NL3D::CPatchDLMContext::DLMUBias, NL3D::CPatchDLMContext::DLMUScale, NL3D::CPatchDLMContext::DLMVBias, NL3D::CPatchDLMContext::DLMVScale, NL3D::CParamCoord::getS(), NL3D::CParamCoord::getT(), NL3D::CTessFarVertex::Index0, NL3D::CTessNodeList::Next, nlassert, NL3D::CTessFarVertex::PCoord, NLMISC::CUV::U, uint8, and NLMISC::CUV::V. +

+Referenced by fillVBFarsDLMUvOnly(). +

+

01610 {
+01611         // The Buffers must have been locked
+01612         nlassert(CLandscapeGlobals::CurrentFar0VBAllocator);
+01613         nlassert(CLandscapeGlobals::CurrentFar0VBAllocator->bufferLocked());
+01614         // VBInfo must be OK.
+01615         nlassert(!CLandscapeGlobals::CurrentFar0VBAllocator->reallocationOccurs());
+01616 
+01617         static  uint8   *CurVBPtr;
+01618         static CUV              uvDLM;
+01619 
+01620         // If the DLMContext exist
+01621         if(_DLMContext)
+01622         {
+01623                 // Traverse the vertList, to compute new uvDLM
+01624                 CTessFarVertex  *pVert;
+01625                 for(pVert= vertList.begin(); pVert; pVert= (CTessFarVertex*)pVert->Next)
+01626                 {
+01627                         // Compute/build the new vertex.
+01628                         CurVBPtr= (uint8*)CLandscapeGlobals::CurrentFar0VBInfo.VertexCoordPointer;
+01629                         CurVBPtr+= pVert->Index0 * CLandscapeGlobals::CurrentFar0VBInfo.VertexSize;
+01630 
+01631                         // compute Uvs.
+01632                         CParamCoord     pc= pVert->PCoord;
+01633 
+01634                         // compute Dynamic lightmap Uv with DLM context info.
+01635                         uvDLM.U= pc.getS()* _DLMContext->DLMUScale + _DLMContext->DLMUBias;
+01636                         uvDLM.V= pc.getT()* _DLMContext->DLMVScale + _DLMContext->DLMVBias;
+01637 
+01638                         // Set Uv DLM only (NB: same code for VertexProgram or not, only TexCoordOff1 may change).
+01639                         *(CUV*)(CurVBPtr + CLandscapeGlobals::CurrentFar0VBInfo.TexCoordOff1)= uvDLM;
+01640                 }
+01641         }
+01642         // else, reset all Uvs
+01643         else
+01644         {
+01645                 // just set UV so the vertex point to a black pixel (see CTextureDLM).
+01646                 uvDLM.U= 1;
+01647                 uvDLM.V= 1;
+01648 
+01649                 // Traverse the vertList, to reset uv
+01650                 CTessFarVertex  *pVert;
+01651                 for(pVert= vertList.begin(); pVert; pVert= (CTessFarVertex*)pVert->Next)
+01652                 {
+01653                         // Compute/build the new vertex.
+01654                         CurVBPtr= (uint8*)CLandscapeGlobals::CurrentFar0VBInfo.VertexCoordPointer;
+01655                         CurVBPtr+= pVert->Index0 * CLandscapeGlobals::CurrentFar0VBInfo.VertexSize;
+01656 
+01657                         // Set Uv DLM only (NB: same code for VertexProgram or not, only TexCoordOff1 may change).
+01658                         *(CUV*)(CurVBPtr + CLandscapeGlobals::CurrentFar0VBInfo.TexCoordOff1)= uvDLM;
+01659                 }
+01660         }
+01661 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::fillFar0VertexListVB CTessList< CTessFarVertex > &  vertList  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1161 of file patch_render.cpp. +

+References NL3D::CTessList< T >::begin(), fillFar0VertexVB(), and NL3D::CTessNodeList::Next. +

+Referenced by fillVB(), fillVBFar0Only(), and preRender(). +

+

01162 {
+01163         // Traverse the vertList.
+01164         CTessFarVertex  *pVert;
+01165         for(pVert= vertList.begin(); pVert; pVert= (CTessFarVertex*)pVert->Next)
+01166         {
+01167                 fillFar0VertexVB(pVert);
+01168         }
+01169 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::fillFar0VertexVB CTessFarVertex pVert  )  [inline, private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 946 of file patch_render.cpp. +

+References _DLMContext, NL3D::CPatchDLMContext::DLMUBias, NL3D::CPatchDLMContext::DLMUScale, NL3D::CPatchDLMContext::DLMVBias, NL3D::CPatchDLMContext::DLMVScale, NL3D::CTessVertex::EndPos, Far0UBias, Far0UScale, Far0VBias, Far0VScale, NL3D::CParamCoord::getS(), NL3D::CParamCoord::getT(), NL3D::CTessFarVertex::Index0, NL3D::CTessVertex::MaxFaceSize, NL3D::CTessVertex::MaxNearLimit, NL_PATCH_FAR0_ROTATED, nlassert, NL3D::CTessFarVertex::PCoord, NL3D::CTessVertex::Pos, NL3D::CTessFarVertex::Src, NL3D::CTessVertex::StartPos, NLMISC::CUV::U, uint8, and NLMISC::CUV::V. +

+Referenced by checkFillVertexVBFar(), and fillFar0VertexListVB(). +

+

00947 {
+00948         // The Buffers must have been locked
+00949         nlassert(CLandscapeGlobals::CurrentFar0VBAllocator);
+00950         nlassert(CLandscapeGlobals::CurrentFar0VBAllocator->bufferLocked());
+00951         // VBInfo must be OK.
+00952         nlassert(!CLandscapeGlobals::CurrentFar0VBAllocator->reallocationOccurs());
+00953 
+00954         static  uint8   *CurVBPtr;
+00955         // Compute/build the new vertex.
+00956         CurVBPtr= (uint8*)CLandscapeGlobals::CurrentFar0VBInfo.VertexCoordPointer;
+00957         CurVBPtr+= pVert->Index0 * CLandscapeGlobals::CurrentFar0VBInfo.VertexSize;
+00958 
+00959         // NB: the filling order of data is important, for AGP write combiners.
+00960 
+00961         // compute Uvs.
+00962         static CUV      uv;
+00963         CParamCoord     pc= pVert->PCoord;
+00964         if (Flags&NL_PATCH_FAR0_ROTATED)
+00965         {
+00966                 uv.U= pc.getT()* Far0UScale + Far0UBias;
+00967                 uv.V= (1.f-pc.getS())* Far0VScale + Far0VBias;
+00968         }
+00969         else
+00970         {
+00971                 uv.U= pc.getS()* Far0UScale + Far0UBias;
+00972                 uv.V= pc.getT()* Far0VScale + Far0VBias;
+00973         }
+00974 
+00975         // compute Dynamic lightmap Uv.
+00976         static CUV      uvDLM;
+00977         if(_DLMContext)         //  (NB: Suppose BTB kill this test).
+00978         {
+00979                 // compute UV with DLM context info.
+00980                 uvDLM.U= pc.getS()* _DLMContext->DLMUScale + _DLMContext->DLMUBias;
+00981                 uvDLM.V= pc.getT()* _DLMContext->DLMVScale + _DLMContext->DLMVBias;
+00982         }
+00983         else
+00984         {
+00985                 // just set UV so the vertex point to a black pixel (see CTextureDLM).
+00986                 uvDLM.U= 1;
+00987                 uvDLM.V= 1;
+00988         }
+00989 
+00990         // If not VertexProgram (NB: Suppose BTB kill this test).
+00991         if( !CLandscapeGlobals::VertexProgramEnabled )
+00992         {
+00993                 // Set Pos. Set it local to the current center of landscape
+00994                 *(CVector*)CurVBPtr= pVert->Src->Pos - CLandscapeGlobals::PZBModelPosition;
+00995                 // Set Uvs.
+00996                 *(CUV*)(CurVBPtr + CLandscapeGlobals::CurrentFar0VBInfo.TexCoordOff0)= uv;
+00997                 *(CUV*)(CurVBPtr + CLandscapeGlobals::CurrentFar0VBInfo.TexCoordOff1)= uvDLM;
+00998         }
+00999         else
+01000         {
+01001                 // Else must setup Vertex program inputs
+01002                 // v[0]== StartPos.
+01003                 *(CVector*)CurVBPtr= pVert->Src->StartPos;
+01004                 // v[8]== Tex0
+01005                 *(CUV*)(CurVBPtr + CLandscapeGlobals::CurrentFar0VBInfo.TexCoordOff0)= uv;
+01006                 // v[9]== Tex1
+01007                 *(CUV*)(CurVBPtr + CLandscapeGlobals::CurrentFar0VBInfo.TexCoordOff1)= uvDLM;
+01008 
+01009                 // v[10]== GeomInfo.
+01010                 static CUV      geomInfo;
+01011                 geomInfo.U= pVert->Src->MaxFaceSize * CLandscapeGlobals::OORefineThreshold;
+01012                 geomInfo.V= pVert->Src->MaxNearLimit;
+01013                 *(CUV*)(CurVBPtr + CLandscapeGlobals::CurrentFar0VBInfo.GeomInfoOff)= geomInfo;
+01014 
+01015                 // v[11]== EndPos - StartPos
+01016                 *(CVector*)(CurVBPtr + CLandscapeGlobals::CurrentFar0VBInfo.DeltaPosOff)=
+01017                         pVert->Src->EndPos - pVert->Src->StartPos;
+01018         }
+01019 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::fillFar1DLMUvOnlyVertexListVB CTessList< CTessFarVertex > &  vertList  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 1664 of file patch_render.cpp. +

+References _DLMContext, NL3D::CTessList< T >::begin(), NL3D::CPatchDLMContext::DLMUBias, NL3D::CPatchDLMContext::DLMUScale, NL3D::CPatchDLMContext::DLMVBias, NL3D::CPatchDLMContext::DLMVScale, NL3D::CParamCoord::getS(), NL3D::CParamCoord::getT(), NL3D::CTessFarVertex::Index1, NL3D::CTessNodeList::Next, nlassert, NL3D::CTessFarVertex::PCoord, NLMISC::CUV::U, uint8, and NLMISC::CUV::V. +

+Referenced by fillVBFarsDLMUvOnly(). +

+

01665 {
+01666         // The Buffers must have been locked
+01667         nlassert(CLandscapeGlobals::CurrentFar1VBAllocator);
+01668         nlassert(CLandscapeGlobals::CurrentFar1VBAllocator->bufferLocked());
+01669         // VBInfo must be OK.
+01670         nlassert(!CLandscapeGlobals::CurrentFar1VBAllocator->reallocationOccurs());
+01671 
+01672         static  uint8   *CurVBPtr;
+01673         static CUV              uvDLM;
+01674 
+01675         // If the DLMContext exist
+01676         if(_DLMContext)
+01677         {
+01678                 // Traverse the vertList, to compute new uvDLM
+01679                 CTessFarVertex  *pVert;
+01680                 for(pVert= vertList.begin(); pVert; pVert= (CTessFarVertex*)pVert->Next)
+01681                 {
+01682                         // Compute/build the new vertex.
+01683                         CurVBPtr= (uint8*)CLandscapeGlobals::CurrentFar1VBInfo.VertexCoordPointer;
+01684                         CurVBPtr+= pVert->Index1 * CLandscapeGlobals::CurrentFar1VBInfo.VertexSize;
+01685 
+01686                         // compute Uvs.
+01687                         CParamCoord     pc= pVert->PCoord;
+01688 
+01689                         // compute Dynamic lightmap Uv with DLM context info.
+01690                         uvDLM.U= pc.getS()* _DLMContext->DLMUScale + _DLMContext->DLMUBias;
+01691                         uvDLM.V= pc.getT()* _DLMContext->DLMVScale + _DLMContext->DLMVBias;
+01692 
+01693                         // Set Uv DLM only (NB: same code for VertexProgram or not, only TexCoordOff1 may change).
+01694                         *(CUV*)(CurVBPtr + CLandscapeGlobals::CurrentFar1VBInfo.TexCoordOff1)= uvDLM;
+01695                 }
+01696         }
+01697         // else, reset all Uvs
+01698         else
+01699         {
+01700                 // just set UV so the vertex point to a black pixel (see CTextureDLM).
+01701                 uvDLM.U= 1;
+01702                 uvDLM.V= 1;
+01703 
+01704                 // Traverse the vertList, to reset uv
+01705                 CTessFarVertex  *pVert;
+01706                 for(pVert= vertList.begin(); pVert; pVert= (CTessFarVertex*)pVert->Next)
+01707                 {
+01708                         // Compute/build the new vertex.
+01709                         CurVBPtr= (uint8*)CLandscapeGlobals::CurrentFar1VBInfo.VertexCoordPointer;
+01710                         CurVBPtr+= pVert->Index1 * CLandscapeGlobals::CurrentFar1VBInfo.VertexSize;
+01711 
+01712                         // Set Uv DLM only (NB: same code for VertexProgram or not, only TexCoordOff1 may change).
+01713                         *(CUV*)(CurVBPtr + CLandscapeGlobals::CurrentFar1VBInfo.TexCoordOff1)= uvDLM;
+01714                 }
+01715         }
+01716 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::fillFar1VertexListVB CTessList< CTessFarVertex > &  vertList  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1173 of file patch_render.cpp. +

+References NL3D::CTessList< T >::begin(), fillFar1VertexVB(), and NL3D::CTessNodeList::Next. +

+Referenced by fillVB(), fillVBFar1Only(), and preRender(). +

+

01174 {
+01175         // Traverse the vertList.
+01176         CTessFarVertex  *pVert;
+01177         for(pVert= vertList.begin(); pVert; pVert= (CTessFarVertex*)pVert->Next)
+01178         {
+01179                 fillFar1VertexVB(pVert);
+01180         }
+01181 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::fillFar1VertexVB CTessFarVertex pVert  )  [inline, private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1022 of file patch_render.cpp. +

+References _DLMContext, NL3D::CPatchDLMContext::DLMUBias, NL3D::CPatchDLMContext::DLMUScale, NL3D::CPatchDLMContext::DLMVBias, NL3D::CPatchDLMContext::DLMVScale, NL3D::CTessVertex::EndPos, Far1UBias, Far1UScale, Far1VBias, Far1VScale, NL3D::CParamCoord::getS(), NL3D::CParamCoord::getT(), NL3D::CTessFarVertex::Index1, NL3D::CTessVertex::MaxFaceSize, NL3D::CTessVertex::MaxNearLimit, NL_PATCH_FAR1_ROTATED, nlassert, OOTransitionSqrDelta, NL3D::CTessFarVertex::PCoord, NL3D::CTessVertex::Pos, NL3D::CTessFarVertex::Src, NL3D::CTessVertex::StartPos, TransitionSqrMin, NLMISC::CUV::U, uint8, and NLMISC::CUV::V. +

+Referenced by checkFillVertexVBFar(), and fillFar1VertexListVB(). +

+

01023 {
+01024         // The Buffers must have been locked
+01025         nlassert(CLandscapeGlobals::CurrentFar1VBAllocator);
+01026         nlassert(CLandscapeGlobals::CurrentFar1VBAllocator->bufferLocked());
+01027         // VBInfo must be OK.
+01028         nlassert(!CLandscapeGlobals::CurrentFar1VBAllocator->reallocationOccurs());
+01029 
+01030         static  uint8   *CurVBPtr;
+01031         // Compute/build the new vertex.
+01032         CurVBPtr= (uint8*)CLandscapeGlobals::CurrentFar1VBInfo.VertexCoordPointer;
+01033         CurVBPtr+= pVert->Index1 * CLandscapeGlobals::CurrentFar1VBInfo.VertexSize;
+01034 
+01035         // NB: the filling order of data is important, for AGP write combiners.
+01036 
+01037         // compute Uvs.
+01038         static CUV      uv;
+01039         CParamCoord     pc= pVert->PCoord;
+01040         if (Flags&NL_PATCH_FAR1_ROTATED)
+01041         {
+01042                 uv.U= pc.getT()* Far1UScale + Far1UBias;
+01043                 uv.V= (1.f-pc.getS())* Far1VScale + Far1VBias;
+01044         }
+01045         else
+01046         {
+01047                 uv.U= pc.getS()* Far1UScale + Far1UBias;
+01048                 uv.V= pc.getT()* Far1VScale + Far1VBias;
+01049         }
+01050 
+01051         // compute Dynamic lightmap Uv.
+01052         static CUV      uvDLM;
+01053         if(_DLMContext)         //  (NB: Suppose BTB kill this test).
+01054         {
+01055                 // compute UV with DLM context info.
+01056                 uvDLM.U= pc.getS()* _DLMContext->DLMUScale + _DLMContext->DLMUBias;
+01057                 uvDLM.V= pc.getT()* _DLMContext->DLMVScale + _DLMContext->DLMVBias;
+01058         }
+01059         else
+01060         {
+01061                 // just set UV so the vertex point to a black pixel (see CTextureDLM).
+01062                 uvDLM.U= 1;
+01063                 uvDLM.V= 1;
+01064         }
+01065 
+01066         // If not VertexProgram (NB: Suppose BTB kill this test).
+01067         if( !CLandscapeGlobals::VertexProgramEnabled )
+01068         {
+01069                 // Set Pos. Set it local to the current center of landscape
+01070                 *(CVector*)CurVBPtr= pVert->Src->Pos - CLandscapeGlobals::PZBModelPosition;
+01071                 // Set Uvs.
+01072                 *(CUV*)(CurVBPtr + CLandscapeGlobals::CurrentFar1VBInfo.TexCoordOff0)= uv;
+01073                 *(CUV*)(CurVBPtr + CLandscapeGlobals::CurrentFar1VBInfo.TexCoordOff1)= uvDLM;
+01074                 // Set default color.
+01075                 static CRGBA    col(255,255,255,255);
+01076                 *(CRGBA*)(CurVBPtr + CLandscapeGlobals::CurrentFar1VBInfo.ColorOff)= col;
+01077         }
+01078         else
+01079         {
+01080                 // Else must setup Vertex program inputs
+01081                 // v[0]== StartPos.
+01082                 *(CVector*)CurVBPtr= pVert->Src->StartPos;
+01083                 // v[8]== Tex0
+01084                 *(CUV*)(CurVBPtr + CLandscapeGlobals::CurrentFar1VBInfo.TexCoordOff0)= uv;
+01085                 // v[9]== Tex1
+01086                 *(CUV*)(CurVBPtr + CLandscapeGlobals::CurrentFar1VBInfo.TexCoordOff1)= uvDLM;
+01087 
+01088                 // v[10]== GeomInfo.
+01089                 static CUV      geomInfo;
+01090                 geomInfo.U= pVert->Src->MaxFaceSize * CLandscapeGlobals::OORefineThreshold;
+01091                 geomInfo.V= pVert->Src->MaxNearLimit;
+01092                 *(CUV*)(CurVBPtr + CLandscapeGlobals::CurrentFar1VBInfo.GeomInfoOff)= geomInfo;
+01093 
+01094                 // v[11]== EndPos - StartPos
+01095                 *(CVector*)(CurVBPtr + CLandscapeGlobals::CurrentFar1VBInfo.DeltaPosOff)=
+01096                         pVert->Src->EndPos - pVert->Src->StartPos;
+01097 
+01098                 // v[12]== Alpha information
+01099                 // Hopefully, fillVBFar1Only() is called each Time the Far1 change, in preRender().
+01100                 // So TransitionSqrMin and OOTransitionSqrDelta in CPath are valid.
+01101                 geomInfo.U= TransitionSqrMin;
+01102                 geomInfo.V= OOTransitionSqrDelta;
+01103                 *(CUV*)(CurVBPtr + CLandscapeGlobals::CurrentFar1VBInfo.AlphaInfoOff)= geomInfo;
+01104 
+01105         }
+01106 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::fillPatchQuadBlock CPatchQuadBlock quadBlock  )  const
+
+ + + + + +
+   + + +

+Fill a CPatchQuadBlock, from its required PatchId. nlassert(PatchId size is less than NL_PATCH_BLOCK_MAX_QUAD) +

+Definition at line 460 of file patch.cpp. +

+References NL_PATCH_BLOCK_MAX_QUAD, NL_PATCH_BLOCK_MAX_VERTEX, nlassert, NL3D::CPatchBlockIdent::OrderS, NL3D::CPatchBlockIdent::OrderT, NL3D::CPatchBlockIdent::S0, NL3D::CPatchBlockIdent::S1, NL3D::CPatchBlockIdent::T0, NL3D::CPatchBlockIdent::T1, and uint. +

+Referenced by NL3D::CLandscape::fillPatchQuadBlock(). +

+

00461 {
+00462         CPatchBlockIdent        &pbId= quadBlock.PatchBlockId;
+00463         uint    lenS= pbId.S1-pbId.S0;
+00464         uint    lenT= pbId.T1-pbId.T0;
+00465         nlassert( pbId.OrderS==OrderS );
+00466         nlassert( pbId.OrderT==OrderT );
+00467         nlassert( pbId.S1<=OrderS );
+00468         nlassert( pbId.T1<=OrderT );
+00469         nlassert( pbId.S0<pbId.S1 );
+00470         nlassert( pbId.T0<pbId.T1 );
+00471         nlassert( lenS<=NL_PATCH_BLOCK_MAX_QUAD );
+00472         nlassert( lenT<=NL_PATCH_BLOCK_MAX_QUAD );
+00473 
+00474         // Fill vertices.
+00475         uint    s0= pbId.S0;
+00476         uint    t0= pbId.T0;
+00477         // some preca.
+00478         float   startS0= (float)s0 / (float)(OrderS);
+00479         float   startT0= (float)t0 / (float)(OrderT);
+00480         float   ds= 1.0f/(float)(OrderS);
+00481         float   dt= 1.0f/(float)(OrderT);
+00482 
+00483         // Parse all quads vertices corner.
+00484         uint    sl,tl;
+00485         for(tl=0; tl<lenT+1; tl++)
+00486         {
+00487                 float   fs, ft;
+00488                 // compute t patch coordinates.
+00489                 ft= startT0 + (float)tl * dt ;
+00490                 for(sl=0; sl<lenS+1; sl++)
+00491                 {
+00492                         // compute s patch coordinates.
+00493                         fs= startS0 + (float)sl * ds ;
+00494 
+00495                         // Must use computeContinousVertex, to ensure continous coordinate on patch edges
+00496                         quadBlock.Vertices[sl + tl*NL_PATCH_BLOCK_MAX_VERTEX]= computeContinousVertex(fs, ft);
+00497                 }
+00498         }
+00499 
+00500 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::fillTileVertexListVB CTessList< CTessNearVertex > &  vertList  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1185 of file patch_render.cpp. +

+References NL3D::CTessList< T >::begin(), fillTileVertexVB(), and NL3D::CTessNodeList::Next. +

+Referenced by fillVB(), and preRender(). +

+

01186 {
+01187         // Traverse the vertList.
+01188         CTessNearVertex *pVert;
+01189         for(pVert= vertList.begin(); pVert; pVert= (CTessNearVertex*)pVert->Next)
+01190         {
+01191                 fillTileVertexVB(pVert);
+01192         }
+01193 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::fillTileVertexVB CTessNearVertex pVert  )  [inline, private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1109 of file patch_render.cpp. +

+References NL3D::CTessVertex::EndPos, NL3D::CTessNearVertex::Index, NL3D::CTessVertex::MaxFaceSize, NL3D::CTessVertex::MaxNearLimit, nlassert, NL3D::CTessVertex::Pos, NL3D::CTessNearVertex::PUv0, NL3D::CTessNearVertex::PUv1, NL3D::CTessNearVertex::PUv2, NL3D::CTessNearVertex::Src, NL3D::CTessVertex::StartPos, NLMISC::CUV::U, uint8, and NLMISC::CUV::V. +

+Referenced by checkFillVertexVBNear(), and fillTileVertexListVB(). +

+

01110 {
+01111         // The Buffers must have been locked
+01112         nlassert(CLandscapeGlobals::CurrentTileVBAllocator);
+01113         nlassert(CLandscapeGlobals::CurrentTileVBAllocator->bufferLocked());
+01114         // VBInfo must be OK.
+01115         nlassert(!CLandscapeGlobals::CurrentTileVBAllocator->reallocationOccurs());
+01116 
+01117         static  uint8   *CurVBPtr;
+01118         // Compute/build the new vertex.
+01119         CurVBPtr= (uint8*)CLandscapeGlobals::CurrentTileVBInfo.VertexCoordPointer;
+01120         CurVBPtr+= pVert->Index * CLandscapeGlobals::CurrentTileVBInfo.VertexSize;
+01121 
+01122 
+01123         // NB: the filling order of data is important, for AGP write combiners.
+01124 
+01125         // If not VertexProgram (NB: Suppose BTB kill this test).
+01126         if( !CLandscapeGlobals::VertexProgramEnabled )
+01127         {
+01128                 // Set Pos. Set it local to the current center of landscape
+01129                 *(CVector*)CurVBPtr= pVert->Src->Pos - CLandscapeGlobals::PZBModelPosition;
+01130                 // Set Uvs.
+01131                 *(CUV*)(CurVBPtr + CLandscapeGlobals::CurrentTileVBInfo.TexCoordOff0)= pVert->PUv0;
+01132                 *(CUV*)(CurVBPtr + CLandscapeGlobals::CurrentTileVBInfo.TexCoordOff1)= pVert->PUv1;
+01133                 *(CUV*)(CurVBPtr + CLandscapeGlobals::CurrentTileVBInfo.TexCoordOff2)= pVert->PUv2;
+01134         }
+01135         else
+01136         {
+01137                 // Else must setup Vertex program inputs
+01138                 // v[0]== StartPos.
+01139                 *(CVector*)CurVBPtr= pVert->Src->StartPos;
+01140                 // v[8]== Tex0
+01141                 *(CUV*)(CurVBPtr + CLandscapeGlobals::CurrentTileVBInfo.TexCoordOff0)= pVert->PUv0;
+01142                 // v[9]== Tex1
+01143                 *(CUV*)(CurVBPtr + CLandscapeGlobals::CurrentTileVBInfo.TexCoordOff1)= pVert->PUv1;
+01144                 // v[13]== Tex2
+01145                 *(CUV*)(CurVBPtr + CLandscapeGlobals::CurrentTileVBInfo.TexCoordOff2)= pVert->PUv2;
+01146 
+01147                 // v[10]== GeomInfo.
+01148                 static CUV      geomInfo;
+01149                 geomInfo.U= pVert->Src->MaxFaceSize * CLandscapeGlobals::OORefineThreshold;
+01150                 geomInfo.V= pVert->Src->MaxNearLimit;
+01151                 *(CUV*)(CurVBPtr + CLandscapeGlobals::CurrentTileVBInfo.GeomInfoOff)= geomInfo;
+01152 
+01153                 // v[11]== EndPos - StartPos
+01154                 *(CVector*)(CurVBPtr + CLandscapeGlobals::CurrentTileVBInfo.DeltaPosOff)=
+01155                         pVert->Src->EndPos - pVert->Src->StartPos;
+01156         }
+01157 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CPatch::fillVB  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 1198 of file patch_render.cpp. +

+References NL3D::CTessBlock::FarVertexList, fillFar0VertexListVB(), fillFar1VertexListVB(), fillTileVertexListVB(), MasterBlock, NL3D::CTessBlock::NearVertexList, sint, NLMISC::CObjectVector< CTessBlock >::size(), TessBlocks, NL3D::CTessBlock::visibleFar0(), NL3D::CTessBlock::visibleFar1(), and NL3D::CTessBlock::visibleTile(). +

+Referenced by fillVBIfVisible(), preRender(), and updateClipPatchVB(). +

+

01199 {
+01200         // Fill Far0.
+01201         //=======
+01202         // fill only if no reallcoation occurs
+01203         if(Far0>0 && !CLandscapeGlobals::CurrentFar0VBAllocator->reallocationOccurs() )
+01204         {
+01205                 // Fill Far0 VB.
+01206                 fillFar0VertexListVB(MasterBlock.FarVertexList);
+01207                 for(sint i=0; i<(sint)TessBlocks.size(); i++)
+01208                 {
+01209                         CTessBlock      &tblock= TessBlocks[i];
+01210                         // fill only if tblock visible.
+01211                         if( tblock.visibleFar0() )
+01212                                 fillFar0VertexListVB(tblock.FarVertexList);
+01213                 }
+01214         }
+01215         else if(Far0==0 && !CLandscapeGlobals::CurrentTileVBAllocator->reallocationOccurs() )
+01216         {
+01217                 // Fill Tile VB.
+01218                 // No Tiles in MasterBlock!!
+01219                 // Traverse the TessBlocks to add vertices.
+01220                 for(sint i=0; i<(sint)TessBlocks.size(); i++)
+01221                 {
+01222                         CTessBlock      &tblock= TessBlocks[i];
+01223                         // fill only if tblock visible.
+01224                         if( tblock.visibleTile() )
+01225                                 fillTileVertexListVB(tblock.NearVertexList);
+01226                 }
+01227         }
+01228 
+01229         // Fill Far1.
+01230         //=======
+01231         if(Far1>0 && !CLandscapeGlobals::CurrentFar1VBAllocator->reallocationOccurs() )
+01232         {
+01233                 // Fill VB.
+01234                 fillFar1VertexListVB(MasterBlock.FarVertexList);
+01235                 for(sint i=0; i<(sint)TessBlocks.size(); i++)
+01236                 {
+01237                         CTessBlock      &tblock= TessBlocks[i];
+01238                         // fill only if tblock visible.
+01239                         if( tblock.visibleFar1() )
+01240                                 fillFar1VertexListVB(tblock.FarVertexList);
+01241                 }
+01242         }
+01243 
+01244 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CPatch::fillVBFar0Only  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 1256 of file patch_render.cpp. +

+References NL3D::CTessBlock::FarVertexList, fillFar0VertexListVB(), MasterBlock, sint, NLMISC::CObjectVector< CTessBlock >::size(), TessBlocks, and NL3D::CTessBlock::visibleFar0(). +

+Referenced by preRender(). +

+

01257 {
+01258         if(Far0>0 && !CLandscapeGlobals::CurrentFar0VBAllocator->reallocationOccurs() )
+01259         {
+01260                 // Fill Far0 VB.
+01261                 fillFar0VertexListVB(MasterBlock.FarVertexList);
+01262                 for(sint i=0; i<(sint)TessBlocks.size(); i++)
+01263                 {
+01264                         CTessBlock      &tblock= TessBlocks[i];
+01265                         // fill only if tblock visible.
+01266                         if( tblock.visibleFar0() )
+01267                                 fillFar0VertexListVB(tblock.FarVertexList);
+01268                 }
+01269         }
+01270 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CPatch::fillVBFar1Only  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 1274 of file patch_render.cpp. +

+References NL3D::CTessBlock::FarVertexList, fillFar1VertexListVB(), MasterBlock, sint, NLMISC::CObjectVector< CTessBlock >::size(), TessBlocks, and NL3D::CTessBlock::visibleFar1(). +

+Referenced by preRender(). +

+

01275 {
+01276         if(Far1>0 && !CLandscapeGlobals::CurrentFar1VBAllocator->reallocationOccurs() )
+01277         {
+01278                 // Fill VB.
+01279                 fillFar1VertexListVB(MasterBlock.FarVertexList);
+01280                 for(sint i=0; i<(sint)TessBlocks.size(); i++)
+01281                 {
+01282                         CTessBlock      &tblock= TessBlocks[i];
+01283                         // fill only if tblock visible.
+01284                         if( tblock.visibleFar1() )
+01285                                 fillFar1VertexListVB(tblock.FarVertexList);
+01286                 }
+01287         }
+01288 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CPatch::fillVBFarsDLMUvOnly  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 1720 of file patch_render.cpp. +

+References NL3D::CTessBlock::FarVertexList, fillFar0DLMUvOnlyVertexListVB(), fillFar1DLMUvOnlyVertexListVB(), MasterBlock, sint, NLMISC::CObjectVector< CTessBlock >::size(), TessBlocks, NL3D::CTessBlock::visibleFar0(), and NL3D::CTessBlock::visibleFar1(). +

+Referenced by addRefDLMContext(), and decRefDLMContext(). +

+

01721 {
+01722         // Do it for Far0.
+01723         if(Far0>0 && !CLandscapeGlobals::CurrentFar0VBAllocator->reallocationOccurs() )
+01724         {
+01725                 // Fill Far0 VB.
+01726                 fillFar0DLMUvOnlyVertexListVB(MasterBlock.FarVertexList);
+01727                 for(sint i=0; i<(sint)TessBlocks.size(); i++)
+01728                 {
+01729                         CTessBlock      &tblock= TessBlocks[i];
+01730                         // fill only if tblock visible.
+01731                         if( tblock.visibleFar0() )
+01732                                 fillFar0DLMUvOnlyVertexListVB(tblock.FarVertexList);
+01733                 }
+01734         }
+01735 
+01736         // Do it for Far1.
+01737         if(Far1>0 && !CLandscapeGlobals::CurrentFar1VBAllocator->reallocationOccurs() )
+01738         {
+01739                 // Fill VB.
+01740                 fillFar1DLMUvOnlyVertexListVB(MasterBlock.FarVertexList);
+01741                 for(sint i=0; i<(sint)TessBlocks.size(); i++)
+01742                 {
+01743                         CTessBlock      &tblock= TessBlocks[i];
+01744                         // fill only if tblock visible.
+01745                         if( tblock.visibleFar1() )
+01746                                 fillFar1DLMUvOnlyVertexListVB(tblock.FarVertexList);
+01747                 }
+01748         }
+01749 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CPatch::fillVBIfVisible  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 1248 of file patch_render.cpp. +

+References fillVB(), and isRenderClipped(). +

+Referenced by NL3D::CLandscape::render(). +

+

01249 {
+01250         if(isRenderClipped()==false)
+01251                 fillVB();
+01252 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CPatch::forceMergeAtTileLevel  ) 
+
+ + + + + +
+   + + +

+For changing TileMaxSubdivision. force tesselation to be under tile. +

+ +

+Definition at line 2022 of file patch.cpp. +

+References NL3D::CTessFace::forceMergeAtTileLevel(), nlassert, Son0, and Son1. +

+Referenced by NL3D::CZone::forceMergeAtTileLevel(). +

+

02023 {
+02024         nlassert(Son0 && Son1);
+02025 
+02026         Son0->forceMergeAtTileLevel();
+02027         Son1->forceMergeAtTileLevel();
+02028 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::generateTileVegetable CVegetableInstanceGroup vegetIg,
uint  distType,
uint  ts,
uint  tt,
CLandscapeVegetableBlockCreateContext vbCreateCtx
[private]
+
+ + + + + +
+   + + +

+Create / init the vegetableBlock in the corresponding TessBlock. TessBlocks must exist. +

+ +

+Definition at line 50 of file patch_vegetable.cpp. +

+References _DLMContext, NL3D::CLandscape::_VegetableManager, NLMISC::CRGBAF::A, appendTileLightInfluences(), NLMISC::CRGBAF::B, NLMISC::clamp(), NL3D::CVegetableLightEx::computeCurrentColors(), NL3D::CPointLight::computeLinearAttenuation(), NL3D::CVegetableLightEx::Direction, NL3D::CPatchDLMContext::DLMUBias, NL3D::CPatchDLMContext::DLMUScale, NL3D::CPatchDLMContext::DLMVBias, NL3D::CPatchDLMContext::DLMVScale, NL3D::CLandscapeVegetableBlockCreateContext::eval(), NL3D::CBezierPatch::eval(), NL3D::CBezierPatch::evalNormal(), NLMISC::CRGBAF::G, NL3D::CVegetable::generateGroupBiLinear(), NL3D::CVegetable::generateInstance(), getLandscape(), NL3D::CPointLight::getPosition(), getTileLumelmapPrecomputed(), NL3D::CLandscape::getTileVegetableDesc(), NL3D::CTileVegetableDesc::getVegetableList(), NL3D::CTileVegetableDesc::getVegetableSeed(), NL3D::CPatchDLMContext::MaxU8, NL3D::CPatchDLMContext::MaxV8, min, NL3D::CPatchDLMContext::MinU8, NL3D::CPatchDLMContext::MinV8, NL3D_PATCH_TILE_AREA, NL3D_VEGETABLE_BLOCK_ELTDIST, NL_LUMEL_BY_TILE, NL_LUMEL_BY_TILE_SHIFT, nlassert, NLMISC::CVector::normalize(), NLMISC::CMatrix::normalize(), NL3D::CVegetableLightEx::NumLights, NLMISC::OptFastFloor(), NL3D::CVegetableLightEx::PointLight, NL3D::CVegetableLightEx::PointLightFactor, NLMISC::CRGBAF::R, NL3D::CVegetable::reserveIgAddInstances(), NL3D::CVegetableManager::reserveIgCompile(), NLMISC::CMatrix::setPos(), NLMISC::CMatrix::setRot(), sint, size, Tiles, NL3D::CVegetableUV8::U, NLMISC::CUV::U, uint, uint8, unpackIntoCache(), NL3D::CVegetableUV8::V, NLMISC::CUV::V, NL3D::CVegetableInstanceGroup::VegetableLightEx, x, NLMISC::CVector::x, y, and NLMISC::CVector::y. +

+Referenced by NL3D::CLandscapeVegetableBlock::createVegetableIGForDistType(). +

+

00052 {
+00053         uint    i;
+00054 
+00055         // Get tile infos for vegetable
+00056         // =========================
+00057 
+00058         // Get the state for this vegetable tile
+00059         CTileElement::TVegetableInfo    vegetWaterState= Tiles[tt * OrderS + ts].getVegetableState();
+00060         // If vegetable disabled, skip!
+00061         if(vegetWaterState == CTileElement::VegetableDisabled)
+00062                 return;
+00063 
+00064         // get the tileId under this tile (<=> the tile material)
+00065         uint    tileId= Tiles[tt * OrderS + ts].Tile[0];
+00066 
+00067         // get list of vegetable for this tile, and for hist distanceType category.
+00068         const CTileVegetableDesc                &tileVegetDesc= getLandscape()->getTileVegetableDesc(tileId);
+00069         const std::vector<CVegetable>   &vegetableList= tileVegetDesc.getVegetableList(distType);
+00070         uint                                                    distAddSeed= tileVegetDesc.getVegetableSeed(distType);
+00071         uint                                                    numVegetable= vegetableList.size();
+00072         
+00073         // If no vegetables at all, skip.
+00074         if(numVegetable==0)
+00075                 return;
+00076 
+00077         // compute approximate tile position and normal: get the middle
+00078         float   tileU= (ts + 0.5f) / (float)OrderS;
+00079         float   tileV= (tt + 0.5f) / (float)OrderT;
+00080         CBezierPatch    *bpatch= unpackIntoCache();
+00081         // Get approximate position for the tile (usefull for noise). NB: eval() is faster than computeVertex().
+00082         CVector         tilePos= bpatch->eval(tileU, tileV);
+00083         // Get also the normal used for all instances on this tile (not precise, 
+00084         // don't take noise into account, but faster).
+00085         CVector         tileNormal= bpatch->evalNormal(tileU, tileV);
+00086 
+00087         // Compute also position on middle of 4 edges of this tile, for generateGroupBiLinear().
+00088         CVector         tilePosBiLinear[4];
+00089         float           OOos= 1.0f / OrderS;
+00090         float           OOot= 1.0f / OrderT;
+00091         tilePosBiLinear[0]= bpatch->eval( (ts + 0.0f) * OOos, (tt + 0.5f) * OOot);
+00092         tilePosBiLinear[1]= bpatch->eval( (ts + 1.0f) * OOos, (tt + 0.5f) * OOot);
+00093         tilePosBiLinear[2]= bpatch->eval( (ts + 0.5f) * OOos, (tt + 0.0f) * OOot);
+00094         tilePosBiLinear[3]= bpatch->eval( (ts + 0.5f) * OOos, (tt + 1.0f) * OOot);
+00095 
+00096 
+00097         // compute a rotation matrix with the normal
+00098         CMatrix         matInstance;
+00099         matInstance.setRot(CVector::I, CVector::J, tileNormal);
+00100         // must normalize the matrix. use the vector which is the most orthogonal to tileNormal
+00101         // If tileNormal is much more a J vector, then use plane (I,tileNormal), and vice-versa
+00102         if(fabs(tileNormal.y) > fabs(tileNormal.x))
+00103                 matInstance.normalize(CMatrix::ZXY);
+00104         else
+00105                 matInstance.normalize(CMatrix::ZYX);
+00106 
+00107 
+00108         // prepare color / lighting
+00109         // =========================
+00110 
+00111         // say that ambient never change. VegetableManager handle the ambient and diffuse itself (for precomputeLighting)
+00112         CRGBAF  ambientF= CRGBAF(1,1,1,1);
+00113 
+00114         // Compute the tileLightmap (not modified by tileColor).
+00115         static  uint8   tileLumelmap[NL_LUMEL_BY_TILE * NL_LUMEL_BY_TILE];
+00116         getTileLumelmapPrecomputed(ts, tt, tileLumelmap, NL_LUMEL_BY_TILE);
+00117         // compute diffuse color by substracting from ambient.
+00118         CRGBAF  diffuseColorF[NL_LUMEL_BY_TILE * NL_LUMEL_BY_TILE];
+00119         // TODO_VEGET_OPTIM: optimize this.
+00120         // For all lumel of this tile.
+00121         for(i= 0; i<NL_LUMEL_BY_TILE*NL_LUMEL_BY_TILE; i++)
+00122         {
+00123                 // mul by 2, because shade is done twice here: by vertex, and by landscape.
+00124                 sint    tileLumel= 2*tileLumelmap[i];
+00125                 tileLumel= min(tileLumel, 255);
+00126                 float   tlf= tileLumel / 255.f;
+00127                 diffuseColorF[i].R= tlf;
+00128                 diffuseColorF[i].G= tlf;
+00129                 diffuseColorF[i].B= tlf;
+00130                 diffuseColorF[i].A= 1;
+00131         }
+00132 
+00133         // Compute The CVegetableLightEx, adding pointLight effect to vegetation
+00134         // First get pointLight at this tiles.
+00135         static  vector<CPointLightInfluence>    lightList;
+00136         lightList.clear();
+00137         appendTileLightInfluences( CUV(tileU, tileV), lightList);
+00138         // for each light, modulate the factor of influence
+00139         for(i=0; i<lightList.size();i++)
+00140         {
+00141                 CPointLight     *pl= lightList[i].PointLight;
+00142                 // compute the attenuation to the pos of the tile
+00143                 float   att= pl->computeLinearAttenuation(tilePos);
+00144                 // modulate the influence with this factor
+00145                 lightList[i].BkupInfluence= lightList[i].Influence;
+00146                 lightList[i].Influence*= att;
+00147         }
+00148         // sort the light by influence
+00149         sort(lightList.begin(), lightList.end());
+00150         // Setup the vegetLex directly in the ig. 
+00151         CVegetableLightEx       &vegetLex= vegetIg->VegetableLightEx;
+00152         // take only 2 first, computing direction to tilePos and computing attenuation.
+00153         vegetLex.NumLights= min((uint)CVegetableLightEx::MaxNumLight, (uint)lightList.size());
+00154         for(i=0;i<vegetLex.NumLights;i++)
+00155         {
+00156                 // WARNING: can C cast to CPointLightNamed here because comes from CPatch::appendTileLightInfluences() only!
+00157                 CPointLightNamed        *pl= (CPointLightNamed*)(lightList[i].PointLight);
+00158                 // copy to vegetLex.
+00159                 vegetLex.PointLight[i]= pl;
+00160                 // get the attenuation
+00161                 vegetLex.PointLightFactor[i]= (uint)(256* lightList[i].Influence);
+00162                 // Setup the direction from pointLight.
+00163                 vegetLex.Direction[i]= tilePos - pl->getPosition();
+00164                 vegetLex.Direction[i].normalize();
+00165         }
+00166         // compute now the current colors of the vegetLex.
+00167         vegetLex.computeCurrentColors();
+00168 
+00169 
+00170         // Compute Dynamic Lightmap UV for this tile.
+00171         nlassert(_DLMContext);
+00172         CUV             dlmUV;
+00173         // get coordinate in 0..1 in texture.
+00174         dlmUV.U= _DLMContext->DLMUBias + _DLMContext->DLMUScale * tileU;
+00175         dlmUV.V= _DLMContext->DLMVBias + _DLMContext->DLMVScale * tileV;
+00176         // get coordinate in 0..255.
+00177         CVegetableUV8   dlmUV8;
+00178         dlmUV8.U= (uint8)NLMISC::OptFastFloor(dlmUV.U * 255 + 0.5f);
+00179         dlmUV8.V= (uint8)NLMISC::OptFastFloor(dlmUV.V * 255 + 0.5f);
+00180         // bound them, ensuring 8Bits UV "uncompressed" by driver are in the lightmap area.
+00181         clamp(dlmUV8.U, _DLMContext->MinU8, _DLMContext->MaxU8);
+00182         clamp(dlmUV8.V, _DLMContext->MinV8, _DLMContext->MaxV8);
+00183 
+00184 
+00185         // for all vegetable of this list, generate instances.
+00186         // =========================
+00187 
+00188         // Get an array for each vegetable (static for speed).
+00189         typedef         std::vector<NLMISC::CVector2f>  TPositionVector;
+00190         static  std::vector<TPositionVector>    instanceUVArray;
+00191         // realloc if necessary.
+00192         if(instanceUVArray.size() < numVegetable)
+00193         {
+00194                 // clean.
+00195                 contReset(instanceUVArray);
+00196                 // realloc.
+00197                 instanceUVArray.resize(numVegetable);
+00198         }
+00199 
+00200         // First, for each vegetable, generate the number of instance to create, and their relative position.
+00201         for(i= 0; i<numVegetable; i++)
+00202         {
+00203                 // get the vegetable
+00204                 const CVegetable        &veget= vegetableList[i];
+00205 
+00206                 // generate instance for this vegetable.
+00207                 veget.generateGroupBiLinear(tilePos, tilePosBiLinear, tileNormal, NL3D_PATCH_TILE_AREA, i + distAddSeed, instanceUVArray[i]);
+00208         }
+00209 
+00210         // Then, now that we kno how many instance to generate for each vegetable, reserve space.
+00211         CVegetableInstanceGroupReserve  vegetIgReserve;
+00212         for(i= 0; i<numVegetable; i++)
+00213         {
+00214                 // get the vegetable
+00215                 const CVegetable        &veget= vegetableList[i];
+00216 
+00217                 // reseve instance space for this vegetable.
+00218                 // instanceUVArray[i].size() is the number of instances to create.
+00219                 veget.reserveIgAddInstances(vegetIgReserve, (CVegetable::TVegetableWater)vegetWaterState, instanceUVArray[i].size());
+00220         }
+00221         // actual reseve memory of the ig.
+00222         getLandscape()->_VegetableManager->reserveIgCompile(vegetIg, vegetIgReserve);
+00223 
+00224 
+00225         // generate the instances for all the vegetables.
+00226         for(i= 0; i<numVegetable; i++)
+00227         {
+00228                 // get the vegetable
+00229                 const CVegetable        &veget= vegetableList[i];
+00230 
+00231                 // get the relatives position of the instances
+00232                 std::vector<CVector2f>  &instanceUV= instanceUVArray[i];
+00233 
+00234                 // For all instance, generate the real instances.
+00235                 for(uint j=0; j<instanceUV.size(); j++)
+00236                 {
+00237                         // generate the position in world Space.
+00238                         // instanceUV is in [0..1] interval, which maps to a tile, so explode to the patch
+00239                         CVector         instancePos;
+00240                         vbCreateCtx.eval(ts, tt, instanceUV[j].x, instanceUV[j].y, instancePos);
+00241                         // NB: use same normal for rotation for all instances in a same tile.
+00242                         matInstance.setPos( instancePos );
+00243 
+00244                         // peek color into the lightmap.
+00245                         sint    lumelS= NLMISC::OptFastFloor(instanceUV[j].x * NL_LUMEL_BY_TILE);
+00246                         sint    lumelT= NLMISC::OptFastFloor(instanceUV[j].y * NL_LUMEL_BY_TILE);
+00247                         clamp(lumelS, 0, NL_LUMEL_BY_TILE-1);
+00248                         clamp(lumelT, 0, NL_LUMEL_BY_TILE-1);
+00249 
+00250                         // generate the instance of the vegetable
+00251                         veget.generateInstance(vegetIg, matInstance, ambientF, 
+00252                                 diffuseColorF[ (lumelT<<NL_LUMEL_BY_TILE_SHIFT) + lumelS ],
+00253                                 (distType+1) * NL3D_VEGETABLE_BLOCK_ELTDIST, (CVegetable::TVegetableWater)vegetWaterState, dlmUV8);
+00254                 }
+00255         }
+00256 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::getBindNeighbor uint  edge,
CBindInfo neighborEdge
const
+
+ + + + + +
+   + + +

+return neighborhood information. +

+ +

+Definition at line 2213 of file patch.cpp. +

+References _BindZoneNeighbor, NL3D::CZone::buildBindInfo(), getZone(), NL3D::CPatch::CBindInfo::MultipleBindNum, nlassert, NL3D::CPatch::CBindInfo::NPatchs, uint, and NL3D::CPatch::CBindInfo::Zone. +

+Referenced by bind(), NL3D::CZone::bindPatch(), NL3D::CZoneCornerSmoother::buildPatchBindInfo(), NL3D::CZoneLighter::buildZoneInformation(), computeContinousVertex(), computeDisplaceCornerSmooth(), computeDisplaceEdgeSmooth(), computeDisplaceRawOnNeighbor(), computeNearBlockLightmap(), computeNormalCornerSmooth(), computeNormalEdgeSmooth(), computeNormalOnNeighbor(), and computeTileLightmapPixelAroundCorner(). +

+

02214 {
+02215         nlassert(edge<4);
+02216 
+02217         if(_BindZoneNeighbor[edge]!=NULL)
+02218         {
+02219                 getZone()->buildBindInfo(PatchId, edge, _BindZoneNeighbor[edge], neighborEdge);
+02220         }
+02221         else
+02222         {
+02223                 neighborEdge.Zone= NULL;
+02224                 neighborEdge.NPatchs= 0;
+02225                 neighborEdge.MultipleBindNum= 0;
+02226         }
+02227 }
+
+

+ + + + +
+ + + + + + + + + + +
bool NL3D::CPatch::getCornerSmoothFlag uint  corner  )  const
+
+ + + + + +
+   + + +

+ +

+Definition at line 962 of file patch_noise.cpp. +

+References _CornerSmoothFlag, nlassert, and uint. +

+Referenced by computeNearBlockLightmap(), computeNormalCornerSmooth(), and NL3D::CZone::retrieve(). +

+

00963 {
+00964         nlassert(corner<=3);
+00965         uint    mask= 1<<corner;
+00966         return  (_CornerSmoothFlag& mask)!=0;
+00967 }
+
+

+ + + + +
+ + + + + + + + + + +
const CTessVertex* NL3D::CPatch::getCornerVertex uint  corner  )  [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 659 of file patch.h. +

+References BaseVertices, and uint. +

+Referenced by NL3D::CZoneCornerSmoother::computeAllCornerSmoothFlags(). +

+

00660         {
+00661                 return BaseVertices[corner];
+00662         }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::getCurrentTileTLIColors uint  ts,
uint  tt,
NLMISC::CRGBA  corners[4]
[private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1655 of file patch_lightmap.cpp. +

+References NL3D::CZone::_PointLightArray, NLMISC::CRGBA::avg2RGBOnly(), NL3D::CPointLightNamedArray::getPointLights(), getZone(), uint, x, and y. +

+Referenced by addTileLightmapEdgeWithTLI(), addTileLightmapPixelWithTLI(), and addTileLightmapWithTLI(). +

+

01656 {
+01657         // Get ref on array of PointLightNamed.
+01658         if( getZone()->_PointLightArray.getPointLights().size() >0 )
+01659         {
+01660                 // get coord of the tessBlock
+01661                 uint    tbs= ts>>1;
+01662                 uint    tbt= tt>>1;
+01663                 // get tile id local to tessBlock.
+01664                 uint    tls= ts-(tbs<<1);
+01665                 uint    tlt= tt-(tbt<<1);
+01666 
+01667                 // For each corner of the tessBlock, compute lighting with pointLights.
+01668                 CRGBA   tbCorners[4];
+01669                 for(uint y=0;y<2;y++)
+01670                 {
+01671                         for(uint x=0;x<2;x++)
+01672                         {
+01673                                 CRGBA   &cornerCol= tbCorners[y*2+x];
+01674                                 cornerCol= getCurrentTLIColor(tbs+x, tbt+y);
+01675                         }
+01676                 }
+01677 
+01678                 // Then biLinear to tile Level (tessBlock==2x2 tiles).
+01679                 CRGBA   tbEdges[4];
+01680                 CRGBA   tbMiddle;
+01681                 // left.
+01682                 tbEdges[0].avg2RGBOnly(tbCorners[0], tbCorners[2]);
+01683                 // bottom
+01684                 tbEdges[1].avg2RGBOnly(tbCorners[2], tbCorners[3]);
+01685                 // right
+01686                 tbEdges[2].avg2RGBOnly(tbCorners[1], tbCorners[3]);
+01687                 // up
+01688                 tbEdges[3].avg2RGBOnly(tbCorners[0], tbCorners[1]);
+01689                 // middle.
+01690                 tbMiddle.avg2RGBOnly(tbEdges[0], tbEdges[2]);
+01691                 
+01692                 // just copy result according to tile pos in tessBlock.
+01693                 if(tlt==0)
+01694                 {
+01695                         if(tls==0)
+01696                         {
+01697                                 corners[0]= tbCorners[0];
+01698                                 corners[1]= tbEdges[3];
+01699                                 corners[2]= tbEdges[0];
+01700                                 corners[3]= tbMiddle;
+01701                         }
+01702                         else
+01703                         {
+01704                                 corners[0]= tbEdges[3];
+01705                                 corners[1]= tbCorners[1];
+01706                                 corners[2]= tbMiddle;
+01707                                 corners[3]= tbEdges[2];
+01708                         }
+01709                 }
+01710                 else
+01711                 {
+01712                         if(tls==0)
+01713                         {
+01714                                 corners[0]= tbEdges[0];
+01715                                 corners[1]= tbMiddle;
+01716                                 corners[2]= tbCorners[2];
+01717                                 corners[3]= tbEdges[1];
+01718                         }
+01719                         else
+01720                         {
+01721                                 corners[0]= tbMiddle;
+01722                                 corners[1]= tbEdges[2];
+01723                                 corners[2]= tbEdges[1];
+01724                                 corners[3]= tbCorners[3];
+01725                         }
+01726                 }
+01727         }
+01728         else
+01729         {
+01730                 // Just fill with 0s.
+01731                 corners[0]= CRGBA::Black;
+01732                 corners[1]= CRGBA::Black;
+01733                 corners[2]= CRGBA::Black;
+01734                 corners[3]= CRGBA::Black;
+01735         }
+01736 }
+
+

+ + + + +
+ + + + + + + + + +
float NL3D::CPatch::getErrorSize  )  const [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 395 of file patch.h. +

+References ErrorSize. +

+

00395 {return ErrorSize;}
+
+

+ + + + +
+ + + + + + + + + +
sint NL3D::CPatch::getFar0  )  const [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 396 of file patch.h. +

+References sint. +

+Referenced by NL3D::CLandscape::render(). +

+

00396 {return Far0;}
+
+

+ + + + +
+ + + + + + + + + +
sint NL3D::CPatch::getFar1  )  const [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 397 of file patch.h. +

+References sint. +

+Referenced by NL3D::CLandscape::render(). +

+

00397 {return Far1;}
+
+

+ + + + +
+ + + + + + + + + +
CLandscape * NL3D::CPatch::getLandscape  )  const
+
+ + + + + +
+   + + +

+Get the landscape in which is placed this patch. +

+ +

+Definition at line 2186 of file patch.cpp. +

+References NL3D::CZone::getLandscape(). +

+Referenced by addRefDLMContext(), addRefTessBlocks(), NL3D::CTessFace::allocTileUv(), appendFaceToTileRenderList(), appendTileMaterialToRenderList(), NL3D::CTessFace::buildTileFaces(), clearTessBlocks(), NL3D::CPatchDLMContext::computeTextureFar(), computeTileLightmap(), computeTileLightmapEdge(), computeTileLightmapEdgePrecomputed(), computeTileLightmapPixel(), computeTileLightmapPixelAutomatic(), computeTileLightmapPixelPrecomputed(), computeTileLightmapPrecomputed(), computeVertex(), createFaceVectorFar0OrTile(), createFaceVectorFar1(), createVegetableBlock(), deleteFaceVectorFar0OrTile(), deleteFaceVectorFar1(), NL3D::CTessFace::deleteTileFaces(), NL3D::CTessFace::deleteTileUv(), dirtTessBlockFaceVector(), NL3D::CTessFace::doMerge(), generateTileVegetable(), makeRoots(), recreateAllVegetableIgs(), recreateTessBlockFaceVector(), release(), NL3D::CTessFace::releaseTileMaterial(), releaseVegetableBlock(), removeFaceFromTileRenderList(), removeTileMaterialFromRenderList(), NL3D::CTessFace::split(), NL3D::CTessFace::splitRectangular(), NL3D::CTessFace::unbind(), NL3D::CTessFace::updateBindAndSplit(), NL3D::CTessFace::updateRefineMerge(), and NL3D::CTessFace::updateRefineSplit(). +

+

02187 {
+02188         return Zone->getLandscape();
+02189 }
+
+

+ + + + +
+ + + + + + + + + + +
uint8 NL3D::CPatch::getLumel const CUV uv  )  const
+
+ + + + + +
+   + + +

+Get the lumel under the position. +

+ +

+Definition at line 1499 of file patch_lightmap.cpp. +

+References NLMISC::clamp(), getTileLumelmapPixelPrecomputed(), NL_LUMEL_BY_TILE, NL_LUMEL_BY_TILE_SHIFT, NLMISC::OptFastFloor(), sint, NLMISC::CUV::U, uint8, NLMISC::CUV::V, and w. +

+Referenced by NL3D::CLandscape::getLumel(). +

+

01500 {
+01501         // compute tile coord and lumel coord.
+01502         sint    ts, tt;
+01503         // get in lumel coord.
+01504         sint    w= (OrderS<<NL_LUMEL_BY_TILE_SHIFT);
+01505         sint    h= (OrderT<<NL_LUMEL_BY_TILE_SHIFT);
+01506         // fastFloor: use a precision of 256 to avoid doing OptFastFloorBegin.
+01507         // add 128, to round and get cneter of lumel.
+01508         ts= NLMISC::OptFastFloor(uv.U* (w<<8) + 128);   ts>>=8;
+01509         tt= NLMISC::OptFastFloor(uv.V* (h<<8) + 128);   tt>>=8;
+01510         clamp(ts, 0, w-1);
+01511         clamp(tt, 0, h-1);
+01512         // get the lumel
+01513         uint8   ret;
+01514         getTileLumelmapPixelPrecomputed(ts>>NL_LUMEL_BY_TILE_SHIFT, tt>>NL_LUMEL_BY_TILE_SHIFT, 
+01515                 ts&(NL_LUMEL_BY_TILE-1), tt&(NL_LUMEL_BY_TILE-1), ret);
+01516 
+01517         return ret;
+01518 }
+
+

+ + + + +
+ + + + + + + + + +
CPatch* NL3D::CPatch::getNextFar0ToRdr  )  const [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 465 of file patch.h. +

+References _NextRdrFar0. +

+Referenced by NL3D::CLandscape::render(). +

+

00465 {return _NextRdrFar0;}
+
+

+ + + + +
+ + + + + + + + + +
CPatch* NL3D::CPatch::getNextFar1ToRdr  )  const [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 467 of file patch.h. +

+References _NextRdrFar1. +

+Referenced by NL3D::CLandscape::render(). +

+

00467 {return _NextRdrFar1;}
+
+

+ + + + +
+ + + + + + + + + +
CPatch* NL3D::CPatch::getNextNearUL  )  const [inline]
+
+ + + + + +
+   + + +

+For lighting update, get Next (CiruclarList). If ==this, then list is empty. +

+ +

+Definition at line 750 of file patch.h. +

+References _ULNearNext. +

+Referenced by NL3D::CLandscape::unlinkPatchFromNearUL(), and NL3D::CLandscape::updateLightingTextureNear(). +

+

00750 {return _ULNearNext;}
+
+

+ + + + +
+ + + + + + + + + +
uint NL3D::CPatch::getNumNearTessBlocks  )  const [inline]
+
+ + + + + +
+   + + +

+get the number of Near TessBlocks. Actually OrderS/2*OrderT/2. +

+ +

+Definition at line 753 of file patch.h. +

+References NLMISC::CObjectVector< CTessBlock >::size(), TessBlocks, and uint. +

+Referenced by NL3D::CLandscape::updateLightingTextureNear(). +

+

00753 {return TessBlocks.size();}
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::getNumTessBlock CParamCoord  pc,
TFarVertType type,
uint numtb
[private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 738 of file patch.cpp. +

+References FVMasterBlock, FVTessBlock, FVTessBlockEdge, NL3D::CParamCoord::S, NL3D::CParamCoord::T, type, and uint. +

+

00739 {
+00740         uint    tboS= (uint)(OrderS>>1);
+00741         uint    tboT= (uint)(OrderT>>1);
+00742 
+00743         // Coordinate of the tessblock (2*2 a tile!! so the >>1).
+00744         uint ts= ((uint)pc.S * tboS) / 0x8000;
+00745         uint tt= ((uint)pc.T * tboT) / 0x8000;
+00746         numtb= tt*tboS + ts;
+00747 
+00748         bool    edgeS= (ts*0x8000) == ((uint)pc.S * tboS);
+00749         bool    edgeT= (tt*0x8000) == ((uint)pc.T * tboT);
+00750 
+00751         // Does this vertex lies on a corner of a TessBlock?
+00752         if(edgeS && edgeT)
+00753                 type= FVMasterBlock;
+00754         // Does this vertex lies on a edge of a TessBlock?
+00755         else if(edgeS || edgeT)
+00756                 type= FVTessBlockEdge;
+00757         // Else it lies exclusively IN a TessBlock.
+00758         else
+00759                 type= FVTessBlock;
+00760 
+00761 }
+
+

+ + + + +
+ + + + + + + + + + +
uint NL3D::CPatch::getNumTessBlock CTessFace face  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 722 of file patch.cpp. +

+References NL3D::CTessFace::PVBase, NL3D::CTessFace::PVLeft, NL3D::CTessFace::PVRight, NL3D::CParamCoord::S, NL3D::CParamCoord::T, and uint. +

+Referenced by appendFaceToRenderList(), appendFaceToTileRenderList(), appendFarVertexToRenderList(), extendTessBlockWithEndPos(), removeFaceFromRenderList(), removeFaceFromTileRenderList(), and removeFarVertexFromRenderList(). +

+

00723 {
+00724         // To which tessBlocks link the face?
+00725         // compute an approx middle of the face.
+00726         CParamCoord     edgeMid(face->PVLeft, face->PVRight);
+00727         CParamCoord     middle(edgeMid, face->PVBase);
+00728         // Coordinate of the tessblock (2*2 a tile!! so the >>1).
+00729         uint ts= ((uint)middle.S * (uint)(OrderS>>1)) / 0x8000;
+00730         uint tt= ((uint)middle.T * (uint)(OrderT>>1)) / 0x8000;
+00731         uint numtb= tt*(uint)(OrderS>>1) + ts;
+00732 
+00733         return numtb;
+00734 }
+
+

+ + + + +
+ + + + + + + + + + +
uint8 NL3D::CPatch::getOrderForEdge sint8  edge  )  const
+
+ + + + + +
+   + + +

+ +

+Definition at line 2196 of file patch.cpp. +

+References sint, sint8, uint, and uint8. +

+Referenced by NL3D::CPatchUVLocator::build(). +

+

02197 {
+02198         uint    e= ((sint)edge + 256)&3;
+02199         // If an horizontal edge.
+02200         if( e&1 )       return OrderS;
+02201         else            return OrderT;
+02202 }
+
+

+ + + + +
+ + + + + + + + + +
uint8 NL3D::CPatch::getOrderS  )  const [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 392 of file patch.h. +

+References uint8. +

+Referenced by NL3D::CTextureFar::allocatePatch(), NL3D::CPatchUVLocator::build(), NL3D::CLandscape::buildCollideFaces(), NL3D::CZoneLighter::buildZoneInformation(), computeContinousVertex(), computeNormalCornerSmooth(), computeNormalEdgeSmooth(), computeNormalOnNeighbor(), NL3D::CPatchDLMContext::computeTextureFar(), NL3D::CLandscapeVegetableBlockCreateContext::eval(), NL3D::CLandscape::freeFarRenderPass(), NL3D::CPatchDLMContext::generate(), NL3D::CLandscape::getFarRenderPass(), NL3D::CZoneLighter::getNormal(), NL3D::CLandscapeVegetableBlock::init(), NL3D::CZoneLighter::isLumelOnEdgeMustBeOversample(), NL3D::CTextureFar::rebuildPatch(), NL3D::CTextureFar::removePatch(), NL3D::CPatchUVLocator::selectPatch(), NL3D::CTextureFar::touchPatchULAndNext(), and NL3D::CTextureFar::tryAllocatePatch(). +

+

00392 {return OrderS;}
+
+

+ + + + +
+ + + + + + + + + +
uint8 NL3D::CPatch::getOrderT  )  const [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 393 of file patch.h. +

+References uint8. +

+Referenced by NL3D::CTextureFar::allocatePatch(), NL3D::CPatchUVLocator::build(), NL3D::CLandscape::buildCollideFaces(), NL3D::CZoneLighter::buildZoneInformation(), computeContinousVertex(), computeNormalCornerSmooth(), computeNormalEdgeSmooth(), computeNormalOnNeighbor(), NL3D::CPatchDLMContext::computeTextureFar(), NL3D::CLandscapeVegetableBlockCreateContext::eval(), NL3D::CLandscape::freeFarRenderPass(), NL3D::CPatchDLMContext::generate(), NL3D::CLandscape::getFarRenderPass(), NL3D::CZoneLighter::getNormal(), NL3D::CLandscapeVegetableBlock::init(), NL3D::CTextureFar::rebuildPatch(), NL3D::CTextureFar::removePatch(), NL3D::CPatchUVLocator::selectPatch(), NL3D::CTextureFar::touchPatchULAndNext(), and NL3D::CTextureFar::tryAllocatePatch(). +

+

00393 {return OrderT;}
+
+

+ + + + +
+ + + + + + + + + +
uint16 NL3D::CPatch::getPatchId  )  const [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 398 of file patch.h. +

+References uint16. +

+Referenced by NL3D::CZoneLighter::buildZoneInformation(), NL3D::CLandscape::computeDynamicLighting(), NL3D::CZoneLighter::getNormal(), and NL3D::CZoneLighter::isLumelOnEdgeMustBeOversample(). +

+

00398 {return PatchId;}
+
+

+ + + + +
+ + + + + + + + + + +
CTessFace * NL3D::CPatch::getRootFaceForEdge sint  edge  )  const [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1751 of file patch.cpp. +

+References nlassert, sint, Son0, and Son1. +

+Referenced by bind(). +

+

01752 {
+01753         nlassert(edge>=0 && edge<=3);
+01754 
+01755         // See tessellation rules.
+01756         if(OrderS>=OrderT)
+01757         {
+01758                 if(edge==0 || edge==1)
+01759                         return Son0;
+01760                 else
+01761                         return Son1;
+01762         }
+01763         else
+01764         {
+01765                 if(edge==0 || edge==3)
+01766                         return Son0;
+01767                 else
+01768                         return Son1;
+01769         }
+01770 }
+
+

+ + + + +
+ + + + + + + + + + +
CTessVertex * NL3D::CPatch::getRootVertexForEdge sint  edge  )  const [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1773 of file patch.cpp. +

+References nlassert, sint, Son0, Son1, NL3D::CTessFace::VBase, NL3D::CTessFace::VLeft, and NL3D::CTessFace::VRight. +

+Referenced by bind(). +

+

01774 {
+01775         // Return the vertex which is the start of edge.
+01776         nlassert(edge>=0 && edge<=3);
+01777 
+01778         // See tessellation rules.
+01779         if(OrderS>=OrderT)
+01780         {
+01781                 switch(edge)
+01782                 {
+01783                         case 0: return Son0->VRight;
+01784                         case 1: return Son0->VBase;
+01785                         case 2: return Son0->VLeft;
+01786                         case 3: return Son1->VBase;
+01787                         default: return NULL;
+01788                 }
+01789         }
+01790         else
+01791         {
+01792                 switch(edge)
+01793                 {
+01794                         case 0: return Son0->VBase;
+01795                         case 1: return Son0->VLeft;
+01796                         case 2: return Son1->VBase;
+01797                         case 3: return Son0->VRight;
+01798                         default: return NULL;
+01799                 }
+01800         }
+01801 }
+
+

+ + + + +
+ + + + + + + + + + +
bool NL3D::CPatch::getSmoothFlag uint  edge  )  const [inline]
+
+ + + + + +
+   + + +

+Get the smooth flag for the n-th edge. Return true if this edge must by smoothed, false else. +

+Definition at line 579 of file patch.h. +

+References NL_PATCH_SMOOTH_FLAG_SHIFT, and uint. +

+Referenced by NL3D::CZoneCornerSmoother::buildPatchBindInfo(), computeNearBlockLightmap(), computeNormalEdgeSmooth(), and NL3D::CZoneLighter::getNormal(). +

+

00580         {
+00581                 // Test it
+00582                 return ((Flags&(1<<(edge+NL_PATCH_SMOOTH_FLAG_SHIFT)))!=0);
+00583         }
+
+

+ + + + +
+ + + + + + + + + + +
CVector NL3D::CPatch::getTesselatedPos CUV  uv  )  const
+
+ + + + + +
+   + + +

+From the current tesselation of this patch, and a UV in this patch, return tesselated position. +

+Definition at line 579 of file patch.cpp. +

+References NLMISC::clamp(), NL3D::CTessFace::getTesselatedPos(), Son0, Son1, NLMISC::CUV::U, and NLMISC::CUV::V. +

+Referenced by NL3D::CLandscape::getTesselatedPos(). +

+

00580 {
+00581         // clamp values.
+00582         clamp(uv.U, 0, 1);
+00583         clamp(uv.V, 0, 1);
+00584         // recurs down the 2 sons.
+00585         CVector         ret= CVector::Null;
+00586         Son0->getTesselatedPos(uv, true, ret);
+00587         Son1->getTesselatedPos(uv, true, ret);
+00588 
+00589         return ret;
+00590 }
+
+

+ + + + +
+ + + + + + + + + + +
CTileElement * NL3D::CPatch::getTileElement const CUV uv  ) 
+
+ + + + + +
+   + + +

+Get the lumel under the position. +

+ +

+Definition at line 2265 of file patch.cpp. +

+References NLMISC::clamp(), NLMISC::OptFastFloor(), sint, Tiles, NLMISC::CUV::U, and NLMISC::CUV::V. +

+Referenced by NL3D::CLandscape::getTileElement(). +

+

02266 {
+02267         // compute tile coord and lumel coord.
+02268         sint    ts, tt;
+02269 
+02270         // fastFloor: use a precision of 256 to avoid doing OptFastFloorBegin.
+02271         // add 128, to round and get cneter of lumel.
+02272         ts= NLMISC::OptFastFloor(uv.U* (OrderS<<8) + 128);      ts>>=8;
+02273         tt= NLMISC::OptFastFloor(uv.V* (OrderT<<8) + 128);      tt>>=8;
+02274         clamp(ts, 0, OrderS-1);
+02275         clamp(tt, 0, OrderT-1);
+02276 
+02277         // get the lumel
+02278         return &(Tiles[ts+tt*OrderS]);
+02279 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::getTileLightMap uint  ts,
uint  tt,
CPatchRdrPass *&  rdrpass
[private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1191 of file patch_lightmap.cpp. +

+References computeNearBlockLightmap(), computeTbTm(), NL3D::CLandscape::getTileLightMap(), NL3D::CZone::Landscape, NL3D::CTessBlock::LightMapId, NL3D::CTessBlock::LightMapRdrPass, NL3D::CTessBlock::LightMapRefCount, NL_TILE_LIGHTMAP_SIZE, nlassert, NLMISC::CObjectVector< CTessBlock >::size(), TessBlocks, and uint. +

+

01192 {
+01193         // TessBlocks must have been allocated.
+01194         nlassert(TessBlocks.size()!=0);
+01195 
+01196         // get what tessBlock to use.
+01197         uint    numtb, numtm;
+01198         computeTbTm(numtb, numtm, ts, tt);
+01199         CTessBlock      &tessBlock= TessBlocks[numtb];
+01200 
+01201         // If the lightmap Id has not been computed, compute it.
+01202         if(tessBlock.LightMapRefCount==0)
+01203         {
+01204                 // Compute the lightmap texture, with help of TileColors, with neighboring info etc...
+01205                 CRGBA   lightText[NL_TILE_LIGHTMAP_SIZE*NL_TILE_LIGHTMAP_SIZE];
+01206                 computeNearBlockLightmap(ts&(~1), tt&(~1), lightText);
+01207 
+01208                 // Create a rdrPass with this texture, donlod to Driver etc...
+01209                 tessBlock.LightMapId= Zone->Landscape->getTileLightMap(lightText, rdrpass);
+01210 
+01211                 // store this rdrpass ptr.
+01212                 tessBlock.LightMapRdrPass= rdrpass;
+01213         }
+01214 
+01215         // We are using this 2x2 tiles lightmap.
+01216         tessBlock.LightMapRefCount++;
+01217 
+01218 
+01219         // get the rdrpass ptr of the tessBlock lightmap
+01220         rdrpass= tessBlock.LightMapRdrPass;
+01221 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::getTileLightMapUvInfo uint  ts,
uint  tt,
CVector uvScaleBias
[private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1225 of file patch_lightmap.cpp. +

+References computeTbTm(), NL3D::CLandscape::getTileLightMapUvInfo(), NL3D::CZone::Landscape, NL3D::CTessBlock::LightMapId, nlassert, NLMISC::CObjectVector< CTessBlock >::size(), TessBlocks, uint, NLMISC::CVector::x, NLMISC::CVector::y, and NLMISC::CVector::z. +

+Referenced by NL3D::CTessFace::initTileUvLightmap(). +

+

01226 {
+01227         // TessBlocks must have been allocated.
+01228         nlassert(TessBlocks.size()!=0);
+01229 
+01230         // get what tessBlock to use.
+01231         uint    numtb, numtm;
+01232         computeTbTm(numtb, numtm, ts, tt);
+01233         CTessBlock      &tessBlock= TessBlocks[numtb];
+01234 
+01235         // Get the uvScaleBias for the tile 0,0  of the block.
+01236         Zone->Landscape->getTileLightMapUvInfo(tessBlock.LightMapId, uvScaleBias);
+01237 
+01238         // Must increment the bias, for the good tile in the 2x2 block Lightmap.
+01239         uint    tsDec= ts & 1;
+01240         uint    ttDec= tt & 1;
+01241         uvScaleBias.x+= tsDec * uvScaleBias.z;
+01242         uvScaleBias.y+= ttDec * uvScaleBias.z;
+01243 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::getTileLumelmapPixelPrecomputed uint  ts,
uint  tt,
uint  s,
uint  t,
uint8 dest
const [private]
+
+ + + + + +
+   + + +

+same as computeTileLightmapPixelPrecomputed, but brut result, not modified by colorTable. Actually used for Lightmap get interface. +

+Definition at line 670 of file patch_lightmap.cpp. +

+References CompressedLumels, NL3D::getUnpackLumelBlock(), NL_BLOCK_LUMEL_COMPRESSED_SIZE, s, t, uint, and uint8. +

+Referenced by getLumel(). +

+

00671 {
+00672         // Return the lumel
+00673         dest= getUnpackLumelBlock (&(CompressedLumels[(ts + (tt*OrderS))*NL_BLOCK_LUMEL_COMPRESSED_SIZE]), s+(t<<2));
+00674 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::getTileLumelmapPrecomputed uint  ts,
uint  tt,
uint8 dest,
uint  stride
[private]
+
+ + + + + +
+   + + +

+Create / init the vegetableBlock in the corresponding TessBlock. TessBlocks must exist. +

+ +

+Definition at line 650 of file patch_lightmap.cpp. +

+References buffer, CompressedLumels, NL_BLOCK_LUMEL_COMPRESSED_SIZE, NL_LUMEL_BY_TILE, NL_LUMEL_BY_TILE_SHIFT, stride, uint, uint8, unpackLumelBlock(), x, and y. +

+Referenced by generateTileVegetable(). +

+

00651 {
+00652         // Unpack the lumels
+00653         uint8 buffer[NL_LUMEL_BY_TILE*NL_LUMEL_BY_TILE];
+00654         unpackLumelBlock (buffer, &(CompressedLumels[(ts + (tt*OrderS))*NL_BLOCK_LUMEL_COMPRESSED_SIZE]));
+00655 
+00656         // Retrun it
+00657         uint    x, y;
+00658         for(y=0; y<NL_LUMEL_BY_TILE; y++)
+00659         {
+00660                 for(x=0; x<NL_LUMEL_BY_TILE; x++)
+00661                 {
+00662                         // lumel
+00663                         dest[y*stride + x]= buffer[x+(y<<NL_LUMEL_BY_TILE_SHIFT)];
+00664                 }
+00665         }
+00666 }
+
+

+ + + + +
+ + + + + + + + + +
uint NL3D::CPatch::getTileMaterialRefCount  )  const [inline]
+
+ + + + + +
+   + + +

+Get number of TileMaterial created in this Patch. +

+ +

+Definition at line 788 of file patch.h. +

+References MasterBlock, NL3D::CTessBlock::TileMaterialRefCount, and uint. +

+Referenced by NL3D::CLandscape::render(). +

+

00788 {return MasterBlock.TileMaterialRefCount;}
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
CPatchRdrPass * NL3D::CPatch::getTileRenderPass sint  tileId,
sint  pass
[private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 2040 of file patch.cpp. +

+References NL3D::CLandscape::getTileRenderPass(), NL3D::CZone::Landscape, NL3D_TILE_PASS_ADD, NL3D_TILE_PASS_RGB0, NL3D_TILE_PASS_RGB1, NL3D_TILE_PASS_RGB2, nlassert, sint, and Tiles. +

+

02041 {
+02042         // All but lightmap.
+02043         nlassert(pass==NL3D_TILE_PASS_RGB0 || pass==NL3D_TILE_PASS_RGB1 || pass==NL3D_TILE_PASS_RGB2 || 
+02044                 pass==NL3D_TILE_PASS_ADD);
+02045 
+02046         bool    additive= (pass==NL3D_TILE_PASS_ADD);
+02047         sint    passNum= pass-NL3D_TILE_PASS_RGB0;
+02048         // If additive, take the additve tile of bigger existing pass.
+02049         if(additive)
+02050         {
+02051                 // Default: take addtive of pass 0.
+02052                 passNum= 0;
+02053                 // If the pass1 is not empty, may take its tile.
+02054                 if(Tiles[tileId].Tile[1]!=0xFFFF)
+02055                 {
+02056                         passNum= 1;
+02057                         // If the pass2 is not empty, take its tile.
+02058                         if(Tiles[tileId].Tile[2]!=0xFFFF)
+02059                                 passNum= 2;
+02060                 }
+02061         }
+02062 
+02063         sint    tileNumber= Tiles[tileId].Tile[passNum];
+02064         if(tileNumber==0xFFFF)
+02065         {
+02066                 // Display a "fake" only if pass 0.
+02067                 if(pass==NL3D_TILE_PASS_RGB0)
+02068                         return Zone->Landscape->getTileRenderPass(0xFFFF, false);
+02069                 // Else, this tile do not have such a pass (not a transition).
+02070                 return NULL;
+02071         }
+02072         else
+02073         {
+02074                 // return still may be NULL, in additive case.
+02075                 return Zone->Landscape->getTileRenderPass(tileNumber, additive);
+02076         }
+02077 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::getTileTileColors uint  ts,
uint  tt,
NLMISC::CRGBA  corners[4]
[private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 345 of file patch_lightmap.cpp. +

+References NL3D::CTileColor::Color565, NLMISC::CRGBA::set565(), sint, TileColors, and uint. +

+Referenced by modulateTileLightmapEdgeWithTileColors(), modulateTileLightmapPixelWithTileColors(), and modulateTileLightmapWithTileColors(). +

+

00346 {
+00347         for(sint i=0;i<4;i++)
+00348         {
+00349                 CTileColor      &tcol= TileColors[ (tt+(i>>1))*(OrderS+1) + (ts+(i&1)) ];
+00350                 CRGBA           &col= corners[i];
+00351                 col.set565 (tcol.Color565);
+00352         }
+00353 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::getTileUvInfo sint  tileId,
sint  pass,
bool  alpha,
uint8 orient,
CVector uvScaleBias,
bool &  is256x256,
uint8 uvOff
[private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 2080 of file patch.cpp. +

+References alpha, NL3D::CLandscape::getTileUvScaleBiasRot(), NL3D::CZone::Landscape, NL3D_TILE_PASS_ADD, NL3D_TILE_PASS_RGB0, NL3D_TILE_PASS_RGB1, NL3D_TILE_PASS_RGB2, nlassert, sint, Tiles, type, uint8, NLMISC::CVector::x, NLMISC::CVector::y, and NLMISC::CVector::z. +

+Referenced by NL3D::CTessFace::initTileUvRGBA(). +

+

02081 {
+02082         // All but lightmap.
+02083         nlassert(pass==NL3D_TILE_PASS_RGB0 || pass==NL3D_TILE_PASS_RGB1 || pass==NL3D_TILE_PASS_RGB2 || 
+02084                 pass==NL3D_TILE_PASS_ADD);
+02085 
+02086         bool    additive= (pass==NL3D_TILE_PASS_ADD);
+02087         sint    passNum= pass-NL3D_TILE_PASS_RGB0;
+02088         // If additive, take the additve tile of bigger existing pass.
+02089         if(additive)
+02090         {
+02091                 // Default: take addtive of pass 0.
+02092                 passNum= 0;
+02093                 // If the pass1 is not empty, may take its tile.
+02094                 if(Tiles[tileId].Tile[1]!=0xFFFF)
+02095                 {
+02096                         passNum= 1;
+02097                         // If the pass2 is not empty, take its tile.
+02098                         if(Tiles[tileId].Tile[2]!=0xFFFF)
+02099                                 passNum= 2;
+02100                 }
+02101         }
+02102 
+02103         sint    tileNumber= Tiles[tileId].Tile[passNum];
+02104         if(tileNumber==0xFFFF)
+02105         {
+02106                 // dummy... Should not be called here.
+02107                 orient= 0;
+02108                 uvScaleBias.x=0;
+02109                 uvScaleBias.y=0;
+02110                 uvScaleBias.z=1;
+02111                 is256x256=false;
+02112                 uvOff=0;
+02113         }
+02114         else
+02115         {
+02116                 orient= Tiles[tileId].getTileOrient(passNum);
+02117                 Tiles[tileId].getTile256Info(is256x256, uvOff);
+02118                 CTile::TBitmap type;
+02119                 // If alpha wanted, return its UV info (works either for Alpha in Diffuse Pass and Alpha in Additive Pass)
+02120                 if(alpha)
+02121                         type= CTile::alpha;
+02122                 else
+02123                 {
+02124                         if(additive)
+02125                                 type= CTile::additive;
+02126                         else
+02127                                 type= CTile::diffuse;
+02128                 }
+02129 
+02130                 uint8   rotalpha;
+02131                 Zone->Landscape->getTileUvScaleBiasRot(tileNumber, type, uvScaleBias, rotalpha);
+02132 
+02133                 // Add the special rotation of alpha.
+02134                 if(alpha)
+02135                         orient= (orient+rotalpha)&3;
+02136         }
+02137 
+02138 }
+
+

+ + + + +
+ + + + + + + + + +
CZone* NL3D::CPatch::getZone  )  const [inline]
+
+ + + + + +
+   + + +

+ +

+Definition at line 391 of file patch.h. +

+Referenced by appendTileLightInfluences(), NL3D::CZoneLighter::buildZoneInformation(), computeDisplaceRawInteger(), NL3D::CLandscape::computeDynamicLighting(), getBindNeighbor(), getCurrentTileTLIColors(), NL3D::CZoneLighter::getNormal(), and NL3D::CTextureFar::rebuildPatch(). +

+

00391 {return Zone;}
+
+

+ + + + +
+ + + + + + + + + +
bool NL3D::CPatch::isRenderClipped  )  const
+
+ + + + + +
+   + + +

+ +

+Definition at line 594 of file patch.cpp. +

+References NL3D::CZone::isPatchRenderClipped(). +

+Referenced by addRefDLMContext(), beginDLMLighting(), checkCreateVertexVBFar(), checkCreateVertexVBNear(), checkDeleteVertexVBFar(), checkDeleteVertexVBNear(), checkFillVertexVBFar(), checkFillVertexVBNear(), computeSoftwareGeomorphAndAlpha(), decRefDLMContext(), dirtTessBlockFaceVector(), fillVBIfVisible(), makeRoots(), processDLMLight(), recreateTessBlockFaceVector(), release(), NL3D::CLandscape::render(), renderFar0(), renderFar1(), and resetMasterBlock(). +

+

00595 {
+00596         if(Zone)
+00597                 return Zone->isPatchRenderClipped(PatchId);
+00598         else
+00599                 return true;
+00600 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::linkBeforeNearUL CPatch patchNext  ) 
+
+ + + + + +
+   + + +

+For lighting update, insert this before patchNext (CiruclarList). textNext must be !NULL. +

+ +

+Definition at line 1880 of file patch_lightmap.cpp. +

+References _ULNearNext, _ULNearPrec, and nlassert. +

+Referenced by NL3D::CLandscape::linkPatchToNearUL(). +

+

01881 {
+01882         nlassert(patchNext);
+01883 
+01884         // first, unlink others from me. NB: works even if _ULNearPrec==_ULNearNext==this.
+01885         _ULNearNext->_ULNearPrec= _ULNearPrec;
+01886         _ULNearPrec->_ULNearNext= _ULNearNext;
+01887         // link to igNext.
+01888         _ULNearNext= patchNext;
+01889         _ULNearPrec= patchNext->_ULNearPrec;
+01890         // link others to me.
+01891         _ULNearNext->_ULNearPrec= this;
+01892         _ULNearPrec->_ULNearNext= this;
+01893 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + +
CTessFace * NL3D::CPatch::linkTessFaceWithEdge const NLMISC::CVector2f uv0,
const NLMISC::CVector2f uv1,
CTessFace linkTo
[private]
+
+ + + + + +
+   + + +

+Used by bind(). Search in the tesselation the first face which own the edge uv0-uv1. link it with linkTo, and return it. NULL if not found (obviously because not so tesselated) +

+Definition at line 1834 of file patch.cpp. +

+References NL3D::CTessFace::linkTessFaceWithEdge(), nlassert, Son0, and Son1. +

+Referenced by bind(). +

+

01835 {
+01836         nlassert(Son0 && Son1);
+01837         // Try to link with Root Son0
+01838         CTessFace       *face= Son0->linkTessFaceWithEdge(uv0, uv1, linkTo);
+01839         // if Failed Try to link with Root Son1
+01840         if(!face)
+01841                 face= Son1->linkTessFaceWithEdge(uv0, uv1, linkTo);
+01842         return face;
+01843 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CPatch::makeRoots  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1124 of file patch.cpp. +

+References appendFaceToRenderList(), appendFarVertexToRenderList(), BaseFarVertices, BaseVertices, clearTessBlocks(), NL3D::CTessFace::computeSplitPoint(), computeVertex(), NL3D::CTessVertex::EndPos, ErrorSize, NL3D::CTessFace::FBase, NL3D::CTessFace::FLeft, NL3D::CTessFace::FRight, NL3D::CTessFace::FVBase, NL3D::CTessFace::FVLeft, NL3D::CTessFace::FVRight, getLandscape(), isRenderClipped(), NL3D::CTessFace::Level, NL3D::CTessVertex::MaxFaceSize, NL3D::CTessVertex::MaxNearLimit, NL3D::CLandscape::newTessFace(), nlassert, NL3D::CTessFace::Patch, NL3D::CTessFarVertex::PCoord, NL3D::CTessVertex::Pos, NL3D::CTessFace::PVBase, NL3D::CTessFace::PVLeft, NL3D::CTessFace::PVRight, resetMasterBlock(), NL3D::CParamCoord::setST(), NL3D::CTessFace::Size, Son0, Son1, NL3D::CTessFarVertex::Src, NL3D::CTessVertex::StartPos, NL3D::CTessFace::VBase, NL3D::CTessFace::VLeft, and NL3D::CTessFace::VRight. +

+Referenced by compile(). +

+

01125 {
+01126         CTessVertex *a= BaseVertices[0];
+01127         CTessVertex *b= BaseVertices[1];
+01128         CTessVertex *c= BaseVertices[2];
+01129         CTessVertex *d= BaseVertices[3];
+01130 
+01131         // Set positions.
+01132         a->Pos= a->StartPos= a->EndPos= computeVertex(0,0);
+01133         b->Pos= b->StartPos= b->EndPos= computeVertex(0,1);
+01134         c->Pos= c->StartPos= c->EndPos= computeVertex(1,1);
+01135         d->Pos= d->StartPos= d->EndPos= computeVertex(1,0);
+01136 
+01137         // Init Far vetices.
+01138         CTessFarVertex *fa= &BaseFarVertices[0];
+01139         CTessFarVertex *fb= &BaseFarVertices[1];
+01140         CTessFarVertex *fc= &BaseFarVertices[2];
+01141         CTessFarVertex *fd= &BaseFarVertices[3];
+01142         fa->Src= a;
+01143         fa->PCoord.setST(0,0);
+01144         fb->Src= b;
+01145         fb->PCoord.setST(0,1);
+01146         fc->Src= c;
+01147         fc->PCoord.setST(1,1);
+01148         fd->Src= d;
+01149         fd->PCoord.setST(1,0);
+01150 
+01151         // We don't have to fill the Far vertices VB here, because this patch is still not visible.
+01152         // NB: we can't because we don't have any driver here.
+01153         nlassert(isRenderClipped()==true);
+01154 
+01155 
+01156         // Make Roots.
+01157         /*
+01158                 Tesselation layout. For Square Face, and if OrderS>=OrderT.
+01159 
+01160                 A-------D
+01161                 |\ Son1 |
+01162                 |  \    |
+01163                 |    \  |
+01164                 | Son0 \|
+01165                 B-------C
+01166 
+01167                 For rectangles whith OrderT>OrderS. It is VERY IMPORTANT, for splitRectangular() reasons.
+01168 
+01169                 A-------D
+01170                 | Son0 /|
+01171                 |    /  |
+01172                 |  /    |
+01173                 |/ Son1 |
+01174                 B-------C
+01175 
+01176         */
+01177         nlassert(Son0==NULL);
+01178         nlassert(Son1==NULL);
+01179         Son0= getLandscape()->newTessFace();
+01180         Son1= getLandscape()->newTessFace();
+01181 
+01182         // Son0.
+01183         Son0->Patch= this;
+01184         Son0->Level= 0;
+01185         if(OrderS>=OrderT)
+01186         {
+01187                 Son0->VBase= b;
+01188                 Son0->VLeft= c;
+01189                 Son0->VRight= a;
+01190                 Son0->FVBase= fb;
+01191                 Son0->FVLeft= fc;
+01192                 Son0->FVRight= fa;
+01193                 Son0->PVBase.setST(0, 1);
+01194                 Son0->PVLeft.setST(1, 1);
+01195                 Son0->PVRight.setST(0, 0);
+01196         }
+01197         else
+01198         {
+01199                 Son0->VBase= a;
+01200                 Son0->VLeft= b;
+01201                 Son0->VRight= d;
+01202                 Son0->FVBase= fa;
+01203                 Son0->FVLeft= fb;
+01204                 Son0->FVRight= fd;
+01205                 Son0->PVBase.setST(0, 0);
+01206                 Son0->PVLeft.setST(0, 1);
+01207                 Son0->PVRight.setST(1, 0);
+01208         }
+01209         Son0->FBase= Son1;
+01210         Son0->FLeft= NULL;
+01211         Son0->FRight= NULL;
+01212         // No tile info.
+01213         Son0->Size= ErrorSize/2;
+01214         Son0->computeSplitPoint();
+01215 
+01216         // Son1.
+01217         Son1->Patch= this;
+01218         Son1->Level= 0;
+01219         if(OrderS>=OrderT)
+01220         {
+01221                 Son1->VBase= d;
+01222                 Son1->VLeft= a;
+01223                 Son1->VRight= c;
+01224                 Son1->FVBase= fd;
+01225                 Son1->FVLeft= fa;
+01226                 Son1->FVRight= fc;
+01227                 Son1->PVBase.setST(1, 0);
+01228                 Son1->PVLeft.setST(0, 0);
+01229                 Son1->PVRight.setST(1, 1);
+01230         }
+01231         else
+01232         {
+01233                 Son1->VBase= c;
+01234                 Son1->VLeft= d;
+01235                 Son1->VRight= b;
+01236                 Son1->FVBase= fc;
+01237                 Son1->FVLeft= fd;
+01238                 Son1->FVRight= fb;
+01239                 Son1->PVBase.setST(1, 1);
+01240                 Son1->PVLeft.setST(1, 0);
+01241                 Son1->PVRight.setST(0, 1);
+01242         }
+01243         Son1->FBase= Son0;
+01244         Son1->FLeft= NULL;
+01245         Son1->FRight= NULL;
+01246         // No tile info.
+01247         Son1->Size= ErrorSize/2;
+01248         Son1->computeSplitPoint();
+01249 
+01250 
+01251         // Prepare the render list...
+01252         clearTessBlocks();
+01253         resetMasterBlock();
+01254         appendFarVertexToRenderList(fa);
+01255         appendFarVertexToRenderList(fb);
+01256         appendFarVertexToRenderList(fc);
+01257         appendFarVertexToRenderList(fd);
+01258         appendFaceToRenderList(Son0);
+01259         appendFaceToRenderList(Son1);
+01260 
+01261         // Usefull for geomorph: Init 2 root faces MaxNearLimit, and MaxFaceSize
+01262         // NB: since no geomorph is made on endpoints (StartPos==EndPos) of patchs, this is not usefull.
+01263         // but it is important to ensure the VP or software geomorph won't crash with bad float values.
+01264         // Init MaxFaceSize.
+01265         Son0->VBase->MaxFaceSize= 1;
+01266         Son0->VLeft->MaxFaceSize= 1;
+01267         Son0->VRight->MaxFaceSize= 1;
+01268         Son1->VBase->MaxFaceSize= 1;
+01269         Son1->VLeft->MaxFaceSize= 1;
+01270         Son1->VRight->MaxFaceSize= 1;
+01271         // Init MaxNearLimit.
+01272         Son0->VBase->MaxNearLimit= 1;
+01273         Son0->VLeft->MaxNearLimit= 1;
+01274         Son0->VRight->MaxNearLimit= 1;
+01275         Son1->VBase->MaxNearLimit= 1;
+01276         Son1->VLeft->MaxNearLimit= 1;
+01277         Son1->VRight->MaxNearLimit= 1;
+01278 
+01279 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::modulateTileLightmapEdgeWithTileColors uint  ts,
uint  tt,
uint  edge,
NLMISC::CRGBA dest,
uint  stride,
bool  inverse
[private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 508 of file patch_lightmap.cpp. +

+References NL3D::bilinearColorAndModulatex2(), getTileTileColors(), NL_LUMEL_BY_TILE, stride, uint, x, and y. +

+Referenced by computeTileLightmapEdge(). +

+

00509 {
+00510         // Get the tileColors around this tile
+00511         CRGBA   corners[4];
+00512         getTileTileColors(ts, tt, corners);
+00513 
+00514         // get coordinate according to edge.
+00515         uint    x=0,y=0;
+00516         switch(edge)
+00517         {
+00518         case 0: x= 0; break;
+00519         case 1: y= NL_LUMEL_BY_TILE-1; break;
+00520         case 2: x= NL_LUMEL_BY_TILE-1; break;
+00521         case 3: y= 0; break;
+00522         };
+00523 
+00524         // For all lumel of the edge, bilinear.
+00525         uint    i;
+00526         for(i=0; i<NL_LUMEL_BY_TILE; i++)
+00527         {
+00528                 // if vertical edge
+00529                 if( (edge&1)==0 )       y= i;
+00530                 // else horizontal edge
+00531                 else                            x= i;
+00532 
+00533                 // manage inverse.
+00534                 uint    where;
+00535                 if(inverse)             where= (NL_LUMEL_BY_TILE-1)-i;
+00536                 else                    where= i;
+00537                 // compute this pixel, and modulate
+00538                 bilinearColorAndModulatex2(corners, x, y, dest[where*stride]);
+00539         }
+00540 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::modulateTileLightmapPixelWithTileColors uint  ts,
uint  tt,
uint  s,
uint  t,
NLMISC::CRGBA dest
[private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 544 of file patch_lightmap.cpp. +

+References NL3D::bilinearColorAndModulatex2(), getTileTileColors(), s, t, and uint. +

+Referenced by computeTileLightmapPixel(). +

+

00545 {
+00546         // Get the tileColors around this tile
+00547         CRGBA   corners[4];
+00548         getTileTileColors(ts, tt, corners);
+00549 
+00550         // compute this pixel, and modulate
+00551         bilinearColorAndModulatex2(corners, s, t, *dest);
+00552 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::modulateTileLightmapWithTileColors uint  ts,
uint  tt,
NLMISC::CRGBA dest,
uint  stride
[private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 488 of file patch_lightmap.cpp. +

+References NL3D::bilinearColorAndModulatex2(), getTileTileColors(), NL_LUMEL_BY_TILE, stride, uint, x, and y. +

+Referenced by computeTileLightmap(). +

+

00489 {
+00490         // Get the tileColors around this tile
+00491         CRGBA   corners[4];
+00492         getTileTileColors(ts, tt, corners);
+00493 
+00494         // For all lumel, bilinear.
+00495         uint    x, y;
+00496         for(y=0; y<NL_LUMEL_BY_TILE; y++)
+00497         {
+00498                 for(x=0; x<NL_LUMEL_BY_TILE; x++)
+00499                 {
+00500                         // compute this pixel, and modulate
+00501                         bilinearColorAndModulatex2(corners, x, y, dest[y*stride + x]);
+00502                 }
+00503         }
+00504 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::packLumelBlock uint8 dest,
const uint8 source,
uint8  alpha0,
uint8  alpha1
[private]
+
+ + + + + +
+   + + +

+Pack a 4x4 lumel block

+

See also:
packShadowMap(), unpackShadowMap()
+ +

+Definition at line 261 of file patch_lightmap.cpp. +

+References NL3D::NL3DDecompressLumelFactor0Case0, NL3D::NL3DDecompressLumelFactor0Case1, NL3D::NL3DDecompressLumelFactor1Case0, NL3D::NL3DDecompressLumelFactor1Case1, sint, uint, uint8, and value. +

+Referenced by packShadowMap(). +

+

00262 {
+00263         // Precalc the height values..
+00264         uint8 value[8];
+00265 
+00266         // For each value
+00267         uint i;
+00268         for (i=0; i<8; i++)
+00269         {
+00270                 // Case 0 or 1 ?
+00271                 if (alpha0>alpha1)
+00272                         // Case 0
+00273                         value[i]=(NL3DDecompressLumelFactor0Case0[i]*alpha0+NL3DDecompressLumelFactor1Case0[i]*alpha1)/7;
+00274                 else
+00275                 {
+00276                         if (i<6)
+00277                                 value[i]=(NL3DDecompressLumelFactor0Case1[i]*alpha0+NL3DDecompressLumelFactor1Case1[i]*alpha1)/5;
+00278                         else if (i==6)
+00279                                 value[i]=0;
+00280                         else
+00281                                 value[i]=255;
+00282                 }
+00283         }
+00284 
+00285         // Store alpha value
+00286         dest[0]=alpha0;
+00287         dest[1]=alpha1;
+00288 
+00289         // Clear dest codes
+00290         for (i=0; i<6; i++)
+00291         {
+00292                 // Clear the code
+00293                 dest[2+i]=0;
+00294         }
+00295 
+00296         // For each original select the best
+00297         uint codeOffset=2;
+00298         sint codeShift=5;
+00299         for (i=0; i<16; i++)
+00300         {
+00301                 // Best dist and code
+00302                 uint bestDist=10000;
+00303                 uint8 bestCode=0;
+00304 
+00305                 // Calc distance
+00306                 for (uint code=0; code<8; code++)
+00307                 {
+00308                         // Distance from original value
+00309                         uint dist=abs ((sint)(source[i])-(sint)(value[code]));
+00310 
+00311                         // The best ?
+00312                         if (dist<bestDist)
+00313                         {
+00314                                 // New best
+00315                                 bestDist=dist;
+00316                                 bestCode=code;
+00317                         }
+00318 
+00319                         // Perfect, stop searching
+00320                         if (dist==0)
+00321                                 break;
+00322                 }
+00323 
+00324                 // Store the best
+00325                 if (codeShift>=0)
+00326                         dest[codeOffset]|=bestCode<<codeShift;
+00327                 else
+00328                 {
+00329                         dest[codeOffset]|=bestCode>>(-codeShift);
+00330                         dest[codeOffset+1]|=bestCode<<(8+codeShift);
+00331                 }
+00332 
+00333 
+00334                 // Next shift
+00335                 codeShift-=3;
+00336                 if (codeShift<=-3)
+00337                 {
+00338                         codeOffset++;
+00339                         codeShift+=8;
+00340                 }
+00341         }
+00342 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::packShadowMap const uint8 pLumel  ) 
+
+ + + + + +
+   + + +

+Pack the lumels of the patches. Lumels are classes that describe the lighting environnement at a given texel of the lightmap. It is used to compute the shadow map of the patch, compress it and uncompress it. This method compress the lumels passed in parameter and stored them in its Lumels member.

+

Parameters:
+ + +
pShadow is a pointer on the destination lumel buffer. Size must be (OrderS*4+1)*(OrderS*4+1).
+
+
See also:
unpackShadowMap(), resetCompressedLumels()
+ +

+Definition at line 1267 of file patch_lightmap.cpp. +

+References CompressedLumels, evalLumelBlock(), NL_BLOCK_LUMEL_COMPRESSED_SIZE, NL_LUMEL_BY_TILE, nlassert, packLumelBlock(), uint, uint8, unpackLumelBlock(), and v. +

+Referenced by NL3D::CZone::build(). +

+

01268 {
+01269         // Number of lumel by lines
+01270         uint lumelCount=OrderS*NL_LUMEL_BY_TILE;
+01271 
+01272         // Number of block in a line
+01273         nlassert ((lumelCount&0x3)==0);
+01274         uint numLumelBlock=lumelCount>>2;
+01275 
+01276         // Number of line
+01277         uint lineCount=OrderT*NL_LUMEL_BY_TILE;
+01278 
+01279         // Number of block line
+01280         nlassert ((lineCount&0x3)==0);
+01281         uint numLineBlock=lineCount>>2;
+01282 
+01283         // Resize the compressed buffer
+01284         CompressedLumels.resize (numLumelBlock*numLineBlock*NL_BLOCK_LUMEL_COMPRESSED_SIZE);
+01285 
+01286         // Input of compresed data
+01287         uint8 *compressedData=&CompressedLumels[0];
+01288 
+01289         // Each line block
+01290         for (uint lineBlock=0; lineBlock<numLineBlock; lineBlock++)
+01291         {
+01292                 // Block pointer
+01293                 const uint8 *blockLine=pLumelSrc;
+01294 
+01295                 // Each lumel block
+01296                 for (uint lumelBlock=0; lumelBlock<numLumelBlock; lumelBlock++)
+01297                 {
+01298                         // *** Unpack the block
+01299                         uint countU;
+01300 
+01301                         // Last block ?
+01302                         if (lumelBlock==numLumelBlock-1)
+01303                                 countU=lumelCount&3;
+01304                         else
+01305                                 countU=4;
+01306 
+01307                         // Destination lumel
+01308                         const uint8 *blockSrc=blockLine;
+01309 
+01310                         // Temp block
+01311                         uint8 originalBlock[4*4];
+01312 
+01313                         // Copy the lumels in the bloc
+01314                         for (uint v=0; v<NL_LUMEL_BY_TILE; v++)
+01315                         {
+01316                                 for (uint u=0; u<NL_LUMEL_BY_TILE; u++)
+01317                                 {
+01318                                         // Copy the lumel
+01319                                         originalBlock[(v<<2)+u]=blockSrc[u];
+01320                                 }
+01321 
+01322                                 // Next line
+01323                                 blockSrc+=lumelCount;
+01324                         }
+01325 
+01326                         // Get min and max alpha
+01327                         uint8 alphaMin=255;
+01328                         uint8 alphaMax=0;
+01329 
+01330                         // Scan
+01331                         for (uint i=0; i<16; i++)
+01332                         {
+01333                                 // Min ?
+01334                                 if (originalBlock[i]<alphaMin)
+01335                                         alphaMin=originalBlock[i];
+01336                                 if (originalBlock[i]>alphaMax)
+01337                                         alphaMax=originalBlock[i];
+01338                         }
+01339 
+01340                         // *** Try to compress by 2 methods
+01341 
+01342                         // Blcok uncompressed
+01343                         uint8 uncompressedBlock[4*4];
+01344         
+01345                         // Pack the block
+01346                         packLumelBlock (compressedData, originalBlock, alphaMin, alphaMax);
+01347 
+01348                         // Unpack the block
+01349                         unpackLumelBlock (uncompressedBlock, compressedData);
+01350 
+01351                         // Eval error
+01352                         uint firstMethod=evalLumelBlock (originalBlock, uncompressedBlock, NL_LUMEL_BY_TILE, NL_LUMEL_BY_TILE);
+01353 
+01354                         // second compression
+01355                         uint8 secondCompressedBlock[NL_BLOCK_LUMEL_COMPRESSED_SIZE];
+01356                         packLumelBlock (secondCompressedBlock, originalBlock, alphaMax, alphaMin);
+01357 
+01358                         // Unpack the block
+01359                         unpackLumelBlock (uncompressedBlock, secondCompressedBlock);
+01360 
+01361                         // Eval error
+01362                         uint secondMethod=evalLumelBlock (originalBlock, uncompressedBlock, NL_LUMEL_BY_TILE, NL_LUMEL_BY_TILE);
+01363 
+01364                         // Second best ?
+01365                         if (secondMethod<firstMethod)
+01366                         {
+01367                                 // Copy compressed data
+01368                                 memcpy (compressedData, secondCompressedBlock, NL_BLOCK_LUMEL_COMPRESSED_SIZE);
+01369                         }
+01370 
+01371                         // Next source block
+01372                         compressedData+=NL_BLOCK_LUMEL_COMPRESSED_SIZE;
+01373 
+01374                         // Next block on the line
+01375                         blockLine+=4;
+01376                 }
+01377 
+01378                 // Next line of block
+01379                 pLumelSrc+=lumelCount*4;
+01380         }
+01381 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::preRender const NLMISC::CBSphere patchSphere  ) 
+
+ + + + + +
+   + + +

+preRender this patch. Build Max faces / pass etc... +

+ +

+Definition at line 249 of file patch_render.cpp. +

+References _PatchRdrPassFar0, _PatchRdrPassFar1, allocateVBAndFaceVector(), allocateVBAndFaceVectorFar1Only(), NL3D::CPatchRdrPass::appendRdrPatchFar0(), NL3D::CPatchRdrPass::appendRdrPatchFar1(), NL3D::CTileMaterial::appendTileToEachRenderPass(), NL3D::CTessBlock::clip(), NL3D::CTessBlock::clipFar(), computeNewFar(), deleteVBAndFaceVector(), deleteVBAndFaceVectorFar1Only(), NL3D::CTessBlock::FaceTileMaterialRefCount, NL3D::CTessBlock::FarVertexList, fillFar0VertexListVB(), fillFar1VertexListVB(), fillTileVertexListVB(), fillVB(), fillVBFar0Only(), fillVBFar1Only(), NL3D::CTessBlock::forceClip(), NL3D::CTessBlock::NearVertexList, NL3D_TESSBLOCK_TILESIZE, NumRenderableFaces, NL3D::CTessBlock::RdrTileRoot, NL3D::CTessBlock::refillFaceVectorFar0(), NL3D::CTessBlock::refillFaceVectorFar1(), NL3D::CTessBlock::refillFaceVectorTile(), NL3D::CTessBlock::resetClip(), sint, NLMISC::CObjectVector< CTessBlock >::size(), TessBlocks, uint, updateFar0VBAlloc(), updateFar1VBAlloc(), updateTileVBAlloc(), NL3D::CTessBlock::visibleFar0(), NL3D::CTessBlock::visibleFar1(), and NL3D::CTessBlock::visibleTile(). +

+

00250 {
+00251         // 0. Classify the patch, and update TextureInfo.
+00252         //=======================
+00253         sint    newFar0,newFar1;
+00254         // compute new Far0 and new Far1.
+00255         computeNewFar(patchSphere, newFar0, newFar1);
+00256 
+00257 
+00258         // 2. Update vertices in VB
+00259         //========================
+00260         sint    oldFar0= Far0, oldFar1= Far1;
+00261 
+00262         // Test if go in or go out tileMode.
+00263         bool    changeTileMode;
+00264         // this is true if a change is made, and if old or current is in TileMode.
+00265         changeTileMode= (newFar0!=oldFar0) && (newFar0==0 || oldFar0==0);
+00266         // Or this is true if Far0 / Far1 was invalid before.
+00267         changeTileMode= changeTileMode || oldFar0==-1 || oldFar1==-1;
+00268 
+00269         // Pre VB change.
+00270         //------------------
+00271         // In this case, major change: delete all VB, then recreate after.
+00272         if(changeTileMode)
+00273         {
+00274                 // delete the old VB (NB: isRenderClipped()==false here). 
+00275                 // NB: Far0 and Far1 are still unmodified, so deleteVB() will do the good job.
+00276                 deleteVBAndFaceVector();
+00277         }
+00278         else
+00279         {
+00280                 // minor change: Far0 UV, or Far1.
+00281                 // Far0 UV: do nothing here.
+00282                 // If change in Far1, must delete Far1
+00283                 if(newFar1!=oldFar1)
+00284                 {
+00285                         // NB: Far1 is still unmodified, so deleteVB() will do the good job.
+00286                         deleteVBAndFaceVectorFar1Only();
+00287                 }
+00288         }
+00289 
+00290         // Far change.
+00291         //------------------
+00292         // Set new far values
+00293         Far0= newFar0;
+00294         Far1= newFar1;
+00295 
+00296 
+00297         // Post VB change.
+00298         //------------------
+00299         if(changeTileMode)
+00300         {
+00301                 // major change: recreate all the VB.
+00302                 allocateVBAndFaceVector();
+00303                 // Then try to refill if possible.
+00304                 fillVB();
+00305         }
+00306         else
+00307         {
+00308                 // minor change: Far0 UV, or Far1.
+00309                 // If change in Far0
+00310                 if(newFar0!=oldFar0)
+00311                 {
+00312                         // Then must recompute VB with good UVs.
+00313                         // An optimisation is to check if UVs had really change (see UScale ...)
+00314                         // but the case they don't change is very rare: 1/16.
+00315                         fillVBFar0Only();
+00316                 }
+00317 
+00318                 // If change in Far1, must allcoate and recompute UVs.
+00319                 if(newFar1!=oldFar1)
+00320                 {
+00321                         allocateVBAndFaceVectorFar1Only();
+00322                         // try to fill if no reallocation problem
+00323                         fillVBFar1Only();
+00324                 }
+00325         }
+00326 
+00327 
+00328         // 3. Append patch to renderList.
+00329         //=====================
+00330         // This patch is visible. So if good far, append.
+00331         if(Far0>0)
+00332         {
+00333                 _PatchRdrPassFar0->appendRdrPatchFar0(this);
+00334         }
+00335         // Same for Far1.
+00336         if(Far1>0)
+00337         {
+00338                 _PatchRdrPassFar1->appendRdrPatchFar1(this);
+00339         }
+00340 
+00341 
+00342         // 4. Clip tess blocks.
+00343         //=====================
+00344         // If we are in Tile/FarTransition
+00345         bool    doClipFar= Far0==0 && Far1==1;
+00346         // Parse all TessBlocks.
+00347         uint                    nTessBlock= TessBlocks.size();
+00348         CTessBlock              *pTessBlock= nTessBlock>0? &TessBlocks[0]: NULL ;
+00349         for(; nTessBlock>0; pTessBlock++, nTessBlock--)
+00350         {
+00351                 CTessBlock              &tblock= *pTessBlock;
+00352 
+00353                 // bkup the old result for clipping
+00354                 bool    oldVisibleFar0= tblock.visibleFar0();
+00355                 bool    oldVisibleTile= tblock.visibleTile();
+00356                 bool    oldVisibleFar1= tblock.visibleFar1();
+00357 
+00358                 // If this TessBlock is empty, do not need to clip
+00359                 if(tblock.FaceTileMaterialRefCount==0)
+00360                 {
+00361                         // Simply force the clip.
+00362                         tblock.forceClip();
+00363                 }
+00364                 else
+00365                 {
+00366                         // clip the tessBlock.
+00367                         tblock.resetClip();
+00368                         tblock.clip();
+00369                         // If we are in Tile/FarTransition
+00370                         if(doClipFar)
+00371                                 tblock.clipFar(CLandscapeGlobals::RefineCenter, CLandscapeGlobals::TileDistNear, CLandscapeGlobals::FarTransition);
+00372 
+00373                         // If TileMode, and if tile visible
+00374                         if(Far0==0 && tblock.visibleTile() )
+00375                         {
+00376                                 // Append all tiles (if any) to the renderPass list!
+00377                                 for(uint j=0;j<NL3D_TESSBLOCK_TILESIZE; j++)
+00378                                 {
+00379                                         // If tile exist
+00380                                         if(tblock.RdrTileRoot[j])
+00381                                                 // add it to the renderList
+00382                                                 tblock.RdrTileRoot[j]->appendTileToEachRenderPass(NumRenderableFaces);
+00383                                 }
+00384                         }       
+00385                 }
+00386 
+00387                 // If change of clip in tessBlock, must update the tessBlock
+00388                 if( Far0> 0 && oldVisibleFar0 != tblock.visibleFar0() )
+00389                 {
+00390                         if( tblock.visibleFar0() )
+00391                         {
+00392                                 // allocate
+00393                                 updateFar0VBAlloc(tblock.FarVertexList, true);
+00394                                 // fill only if possible.
+00395                                 if(!CLandscapeGlobals::CurrentFar0VBAllocator->reallocationOccurs())
+00396                                         fillFar0VertexListVB(tblock.FarVertexList);
+00397                                 // rebuild triangles index list.
+00398                                 tblock.refillFaceVectorFar0();
+00399                         }
+00400                         else
+00401                         {
+00402                                 // delete
+00403                                 updateFar0VBAlloc(tblock.FarVertexList, false);
+00404                         }
+00405                 }
+00406                 if( Far0==0 && oldVisibleTile != tblock.visibleTile() )
+00407                 {
+00408                         if( tblock.visibleTile() )
+00409                         {
+00410                                 // allocate
+00411                                 updateTileVBAlloc(tblock.NearVertexList, true);
+00412                                 // fill only if possible.
+00413                                 if(!CLandscapeGlobals::CurrentTileVBAllocator->reallocationOccurs())
+00414                                         fillTileVertexListVB(tblock.NearVertexList);
+00415                                 // rebuild triangles index list.
+00416                                 tblock.refillFaceVectorTile();
+00417                         }
+00418                         else
+00419                         {
+00420                                 // delete
+00421                                 updateTileVBAlloc(tblock.NearVertexList, false);
+00422                         }
+00423                 }
+00424                 if( Far1> 0 && oldVisibleFar1 != tblock.visibleFar1() )
+00425                 {
+00426                         if( tblock.visibleFar1() )
+00427                         {
+00428                                 // allocate
+00429                                 updateFar1VBAlloc(tblock.FarVertexList, true);
+00430                                 // fill only if possible.
+00431                                 if(!CLandscapeGlobals::CurrentFar1VBAllocator->reallocationOccurs())
+00432                                         fillFar1VertexListVB(tblock.FarVertexList);
+00433                                 // rebuild triangles index list.
+00434                                 tblock.refillFaceVectorFar1();
+00435                         }
+00436                         else
+00437                         {
+00438                                 // delete
+00439                                 updateFar1VBAlloc(tblock.FarVertexList, false);
+00440                         }
+00441                 }
+00442         }
+00443 
+00444 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::processDLMLight CPatchDLMPointLight pl  ) 
+
+ + + + + +
+   + + +

+Process a Dynamic light, creating the DLMContext if necessary. Increment RefCount. Called by CLandscape. +

+Definition at line 2021 of file patch_lightmap.cpp. +

+References _DLMContext, NL3D::CPatchDLMContext::addPointLightInfluence(), addRefDLMContext(), NL3D::CPatchDLMContext::CurPointLightCount, and isRenderClipped(). +

+

02022 {
+02023         // add reference to currentLight, creating DLMContext if needed
+02024         addRefDLMContext();
+02025 
+02026         // add curLight counter
+02027         _DLMContext->CurPointLightCount++;
+02028 
+02029         // compute lighting, only if patch is visible
+02030         if(!isRenderClipped())
+02031                 _DLMContext->addPointLightInfluence(pl);
+02032 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CPatch::recreateAllVegetableIgs  ) 
+
+ + + + + +
+   + + +

+Recreate any vegetable block (as possible) in this patch. (usefull for edition). +

+ +

+Definition at line 260 of file patch_vegetable.cpp. +

+References createVegetableBlock(), getLandscape(), NL3D::CLandscape::isVegetableActive(), NLMISC::CObjectVector< CTessBlock >::size(), TessBlocks, and uint. +

+Referenced by NL3D::CLandscape::enableVegetable(). +

+

00261 {
+00262         // For all TessBlocks, try to release their VegetableBlock
+00263         for(uint numtb=0; numtb<TessBlocks.size(); numtb++)
+00264         {
+00265                 // if the vegetableBlock is deleted, and if there is at least one Material in the tessBlock, and if possible
+00266                 if( TessBlocks[numtb].VegetableBlock==NULL && TessBlocks[numtb].TileMaterialRefCount>0
+00267                         && getLandscape()->isVegetableActive())
+00268                 {
+00269                         // compute tessBlock coordinate
+00270                         uint tbWidth= OrderS>>1;
+00271                         uint ts= numtb&(tbWidth-1);
+00272                         uint tt= numtb/tbWidth;
+00273                         // crate the vegetable with tilecooridante (ie tessBlock coord *2);
+00274                         createVegetableBlock(numtb, ts*2, tt*2);
+00275                 }
+00276         }
+00277 
+00278 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::recreateTessBlockFaceVector CTessBlock block  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 705 of file patch_render.cpp. +

+References NL3D::CTessBlock::createFaceVectorFar0(), NL3D::CTessBlock::createFaceVectorFar1(), NL3D::CTessBlock::createFaceVectorTile(), getLandscape(), isRenderClipped(), and MasterBlock. +

+Referenced by NL3D::CLandscape::updateTessBlocksFaceVector(). +

+

00706 {
+00707         // Do it Only if patch is visible.
+00708         if(!isRenderClipped())
+00709         {
+00710                 // Far0.
+00711                 // If Far Mode.
+00712                 if(Far0>0)
+00713                 {
+00714                         // Create the face for this TessBlock only.
+00715                         block.createFaceVectorFar0(getLandscape()->_FaceVectorManager);
+00716                 }
+00717                 // Or If Tile Mode.
+00718                 else if(Far0==0)
+00719                 {
+00720                         // No tiles in MasterBlock! So no need to call createFaceVectorTile(), if this block is the MasterBlock.
+00721                         if(&block != &MasterBlock)
+00722                                 block.createFaceVectorTile(getLandscape()->_FaceVectorManager);
+00723                 }
+00724 
+00725                 // Far1.
+00726                 if(Far1>0)
+00727                 {
+00728                         // Create the face for this TessBlock only.
+00729                         block.createFaceVectorFar1(getLandscape()->_FaceVectorManager);
+00730                 }
+00731         }
+00732 
+00733 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CPatch::recreateTileUvs  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 2150 of file patch.cpp. +

+References NL3D::CTessList< CTileFace >::clear(), NLMISC::CObjectVector< CTessBlock >::clear(), NL3D_MAX_TILE_FACE, NL3D_TESSBLOCK_TILESIZE, NL3D::CTessFace::recreateTileUvs(), sint, NLMISC::CObjectVector< CTessBlock >::size(), Son0, Son1, TessBlocks, and NL3D::CTileMaterial::TileFaceList. +

+

02151 {
+02152         // Reset the Tile rdr list.
+02153         for(sint tb=0; tb<(sint)TessBlocks.size();tb++)
+02154         {
+02155                 // Vertices must all be reseted.
+02156                 TessBlocks[tb].NearVertexList.clear();
+02157                 for(sint i=0;i<NL3D_TESSBLOCK_TILESIZE;i++)
+02158                 {
+02159                         CTileMaterial   *tm= TessBlocks[tb].RdrTileRoot[i];
+02160                         if(tm)
+02161                         {
+02162                                 for(sint pass=0;pass<NL3D_MAX_TILE_FACE;pass++)
+02163                                 {
+02164                                         tm->TileFaceList[pass].clear();
+02165                                 }
+02166                         }
+02167                 }
+02168         }
+02169 
+02170         Son0->recreateTileUvs();
+02171         Son1->recreateTileUvs();
+02172 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CPatch::refineAll  ) 
+
+ + + + + +
+   + + +

+Refine this patch. Even if clipped. Refine all nodes. +

+ +

+Definition at line 1493 of file patch.cpp. +

+References nlassert, NL3D::CTessFace::refineAll(), Son0, and Son1. +

+Referenced by NL3D::CZone::refineAll(). +

+

01494 {
+01495         // refineAll.
+01496         nlassert(Son0);
+01497         nlassert(Son1);
+01498         Son0->refineAll();
+01499         Son1->refineAll();
+01500 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CPatch::refreshTesselationGeometry  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 1531 of file patch.cpp. +

+References BaseVertices, computeVertex(), NL3D::CTessVertex::EndPos, nlassert, NL3D::CTessVertex::Pos, NL3D::CTessFace::refreshTesselationGeometry(), Son0, Son1, and NL3D::CTessVertex::StartPos. +

+

01532 {
+01533         nlassert(Son0);
+01534         nlassert(Son1);
+01535 
+01536         // Recompute the BaseVertices.
+01537         CTessVertex *a= BaseVertices[0];
+01538         CTessVertex *b= BaseVertices[1];
+01539         CTessVertex *c= BaseVertices[2];
+01540         CTessVertex *d= BaseVertices[3];
+01541         // Set positions.
+01542         a->Pos= a->StartPos= a->EndPos= computeVertex(0,0);
+01543         b->Pos= b->StartPos= b->EndPos= computeVertex(0,1);
+01544         c->Pos= c->StartPos= c->EndPos= computeVertex(1,1);
+01545         d->Pos= d->StartPos= d->EndPos= computeVertex(1,0);
+01546 
+01547 
+01548         // refresh the tesselation of sons.
+01549         Son0->refreshTesselationGeometry();
+01550         Son1->refreshTesselationGeometry();
+01551 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CPatch::release  ) 
+
+ + + + + +
+   + + +

+Un-compile a patch. Tesselation is deleted. if patch is not compiled, no - op. +

+ +

+Definition at line 115 of file patch.cpp. +

+References _DLMContext, _DLMContextRefCount, NL3D::CZone::_PatchOldRenderClipped, NL3D::CZone::_PatchRenderClipped, _ULNearNext, _ULNearPrec, clearTessBlocks(), NL3D::CLandscape::deleteTessFace(), deleteVBAndFaceVector(), NL3D::CTessFace::FLeft, NL3D::CTessFace::FRight, getLandscape(), NL3D::CTessFace::isLeaf(), isRenderClipped(), nlassert, resetMasterBlock(), resetRenderFar(), NLMISC::CBitSet::set(), Son0, and Son1. +

+Referenced by NL3D::CZone::release(), and ~CPatch(). +

+

00116 {
+00117         if(Zone)
+00118         {
+00119                 // First, delete the VB if the zone was removed while the patch is visible.
+00120                 if(!isRenderClipped())
+00121                 {
+00122                         // release VertexBuffer.
+00123                         deleteVBAndFaceVector();
+00124                         // Flag RenderClipped in Zone
+00125                         Zone->_PatchRenderClipped.set(PatchId, true);
+00126                 }
+00127 
+00128                 // THIS PATCH MSUT BE UNBOUND FIRST!!!!!
+00129                 nlassert(Son0 && Son1);
+00130                 nlassert(Son0->isLeaf() && Son1->isLeaf());
+00131                 nlassert(Son0->FLeft == NULL);
+00132                 nlassert(Son0->FRight == NULL);
+00133                 nlassert(Son1->FLeft == NULL);
+00134                 nlassert(Son1->FRight == NULL);
+00135 
+00136                 // Free renderPass of landscape, and maybe force computation of texture info on next preRender().
+00137                 // Must do it here, before deletion of Zone, OrderS/T etc...
+00138                 resetRenderFar();
+00139 
+00140                 getLandscape()->deleteTessFace(Son0);
+00141                 getLandscape()->deleteTessFace(Son1);
+00142                 // Vertices are smartptr/deleted in zone.
+00143         }
+00144 
+00145         // Flag the fact that this patch can't be rendered.
+00146         OrderS=0;
+00147         OrderT=0;
+00148         Son0=NULL;
+00149         Son1=NULL;
+00150         clearTessBlocks();
+00151         resetMasterBlock();
+00152         // Flag RenderClipped in Zone
+00153         if(Zone)
+00154         {
+00155                 Zone->_PatchRenderClipped.set( PatchId, true);
+00156                 Zone->_PatchOldRenderClipped.set( PatchId, true);
+00157         }
+00158 
+00159         // the pathc is uncompiled. must do it after clearTessBlocks(), because may use it 
+00160         // for vegetable manager, and for updateLighting
+00161         Zone= NULL;
+00162 
+00163         // uncompile: reset UpdateLighting circular list to NULL.
+00164         if(_ULNearPrec!= NULL)
+00165         {
+00166                 // verify the patch is correctly unlinked from any ciruclar list.
+00167                 nlassert(_ULNearPrec==this && _ULNearNext==this);
+00168         }
+00169         _ULNearPrec= NULL;
+00170         _ULNearNext= NULL;
+00171 
+00172         // DynamciLightMap: release the _DLMContext if still exist.
+00173         if(_DLMContext)
+00174                 delete _DLMContext;
+00175         // reset
+00176         _DLMContext= NULL;
+00177         _DLMContextRefCount= 0;
+00178 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::releaseTileLightMap uint  ts,
uint  tt
[private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1247 of file patch_lightmap.cpp. +

+References computeTbTm(), NL3D::CZone::Landscape, NL3D::CTessBlock::LightMapId, NL3D::CTessBlock::LightMapRefCount, nlassert, NL3D::CLandscape::releaseTileLightMap(), NLMISC::CObjectVector< CTessBlock >::size(), TessBlocks, and uint. +

+Referenced by NL3D::CTessFace::releaseTileMaterial(). +

+

01248 {
+01249         // TessBlocks must have been allocated.
+01250         nlassert(TessBlocks.size()!=0);
+01251 
+01252         // get what tessBlock to use.
+01253         uint    numtb, numtm;
+01254         computeTbTm(numtb, numtm, ts, tt);
+01255         CTessBlock      &tessBlock= TessBlocks[numtb];
+01256 
+01257         // If no more tileMaterial use this lightmap, release it.
+01258         nlassert(tessBlock.LightMapRefCount>0);
+01259         tessBlock.LightMapRefCount--;
+01260         if(tessBlock.LightMapRefCount==0)
+01261         {
+01262                 Zone->Landscape->releaseTileLightMap(tessBlock.LightMapId);
+01263         }
+01264 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::releaseVegetableBlock uint  numTb  )  [private]
+
+ + + + + +
+   + + +

+release the vegetableBlock in the corresponding TessBlock. TessBlocks must exist +

+ +

+Definition at line 326 of file patch_vegetable.cpp. +

+References getLandscape(), TessBlocks, and uint. +

+Referenced by deleteAllVegetableIgs(), and removeTileMaterialFromRenderList(). +

+

00327 {
+00328         // if exist, must delete the VegetableBlock.
+00329         if(TessBlocks[numTb].VegetableBlock)
+00330         {
+00331                 // delete Igs, and remove from list.
+00332                 TessBlocks[numTb].VegetableBlock->release(getLandscape()->_VegetableManager, getLandscape()->_VegetableBlockList);
+00333                 // delete.
+00334                 delete TessBlocks[numTb].VegetableBlock;
+00335                 TessBlocks[numTb].VegetableBlock= NULL;
+00336         }
+00337 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::removeFaceFromRenderList CTessFace face  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 848 of file patch.cpp. +

+References decRefTessBlocks(), dirtTessBlockFaceVector(), NL3D::CTessBlock::FaceTileMaterialRefCount, NL3D::CTessBlock::FarFaceList, getNumTessBlock(), NL3D::CTessFace::Level, MasterBlock, nlassert, NumRenderableFaces, NL3D::CTessList< CTessFace >::remove(), removeFaceFromTileRenderList(), TessBlockLimitLevel, TessBlocks, and uint. +

+Referenced by NL3D::CTessFace::doMerge(), NL3D::CTessFace::split(), and NL3D::CTessFace::splitRectangular(). +

+

00849 {
+00850         // Update the number of renderable Faces
+00851         NumRenderableFaces--;
+00852         nlassert(NumRenderableFaces>=0);
+00853 
+00854         // Update Gnal render.
+00855         //====================
+00856         if(face->Level<TessBlockLimitLevel)
+00857         {
+00858                 MasterBlock.FarFaceList.remove(face);
+00859                 MasterBlock.FaceTileMaterialRefCount--;
+00860 
+00861                 // The facelist is modified, so we must update the faceVector, if visible.
+00862                 dirtTessBlockFaceVector(MasterBlock);
+00863         }
+00864         else
+00865         {
+00866                 // link the face to the good tessblock.
+00867                 uint    numtb= getNumTessBlock(face);
+00868                 TessBlocks[numtb].FarFaceList.remove(face);
+00869                 TessBlocks[numtb].FaceTileMaterialRefCount--;
+00870 
+00871                 // The facelist is modified, so we must update the faceVector, if visible.
+00872                 dirtTessBlockFaceVector(TessBlocks[numtb]);
+00873 
+00874                 // Update Tile render (no need to do it if face not at least at tessblock level).
+00875                 removeFaceFromTileRenderList(face);
+00876 
+00877                 // Destroy if necessary the TessBlocks.
+00878                 decRefTessBlocks();
+00879         }
+00880 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::removeFaceFromTileRenderList CTessFace face  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 913 of file patch.cpp. +

+References dirtTessBlockFaceVector(), getLandscape(), getNumTessBlock(), NL3D_MAX_TILE_FACE, nlassert, NL3D::CTileMaterial::Pass, NL3D::CRdrTileId::PatchRdrPass, NL3D::CTessList< CTileFace >::remove(), NL3D::CLandscape::removeFromShadowPolyReceiver(), sint, TessBlocks, NL3D::CTileMaterial::TileFaceList, NL3D::CTessFace::TileFaces, NL3D::CTessFace::TileMaterial, and uint. +

+Referenced by NL3D::CTessFace::deleteTileUvs(), and removeFaceFromRenderList(). +

+

00914 {
+00915         if(face->TileMaterial)
+00916         {
+00917                 // For all valid faces, update their links.
+00918                 // Do not do this for lightmap, since it use same face from RGB0 pass.
+00919                 for(sint i=0;i<NL3D_MAX_TILE_FACE;i++)
+00920                 {
+00921                         CPatchRdrPass   *tilePass= face->TileMaterial->Pass[i].PatchRdrPass;
+00922                         // If tile i enabled.
+00923                         if(tilePass)
+00924                         {
+00925                                 // a face should have created for this pass.
+00926                                 nlassert(face->TileFaces[i]);
+00927                                 face->TileMaterial->TileFaceList[i].remove(face->TileFaces[i]);
+00928                         }
+00929                 }
+00930 
+00931                 // The facelist is modified, so we must update the faceVector, if visible.
+00932                 uint    numtb= getNumTessBlock(face);
+00933                 dirtTessBlockFaceVector(TessBlocks[numtb]);
+00934 
+00935                 // Shadow: remove it from the Shadow Triangles.
+00936                 getLandscape()->removeFromShadowPolyReceiver(face);
+00937         }
+00938 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::removeFarVertexFromRenderList CTessFarVertex fv  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1062 of file patch.cpp. +

+References decRefTessBlocks(), NL3D::CTessBlock::FarVertexList, FVMasterBlock, FVTessBlockEdge, getNumTessBlock(), MasterBlock, NL3D::CTessFarVertex::OwnerBlock, NL3D::CTessFarVertex::PCoord, NL3D::CTessList< CTessFarVertex >::remove(), TessBlocks, TFarVertType, type, and uint. +

+Referenced by NL3D::CTessFace::doMerge(). +

+

01063 {
+01064         TFarVertType    type;
+01065         uint                    numtb;
+01066         getNumTessBlock(fv->PCoord, type, numtb);
+01067         
+01068         
+01069         if(type==FVMasterBlock || type==FVTessBlockEdge)
+01070         {
+01071                 MasterBlock.FarVertexList.remove(fv);
+01072                 fv->OwnerBlock= NULL;
+01073         }
+01074         else 
+01075         {
+01076                 TessBlocks[numtb].FarVertexList.remove(fv);
+01077                 fv->OwnerBlock= NULL;
+01078 
+01079                 // Destroy if necessary the TessBlocks.
+01080                 decRefTessBlocks();
+01081         }
+01082 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::removeNearVertexFromRenderList CTileMaterial tileMat,
CTessNearVertex nv
[private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1099 of file patch.cpp. +

+References computeTbTm(), decRefTessBlocks(), nlassert, NL3D::CTessNearVertex::OwnerBlock, TessBlocks, NL3D::CTileMaterial::TileS, NL3D::CTileMaterial::TileT, and uint. +

+Referenced by NL3D::CTessFace::deleteTileUv(). +

+

01100 {
+01101         nlassert(tileMat);
+01102 
+01103         uint    numtb, numtm;
+01104         computeTbTm(numtb, numtm, tileMat->TileS, tileMat->TileT);
+01105         TessBlocks[numtb].NearVertexList.remove(nv);
+01106         nv->OwnerBlock= NULL;
+01107 
+01108         // Destroy if necessary the TessBlocks.
+01109         decRefTessBlocks();
+01110 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::removeTileMaterialFromRenderList CTileMaterial tm  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 1002 of file patch.cpp. +

+References computeTbTm(), decRefDLMContext(), decRefTessBlocks(), getLandscape(), NL3D::CLandscape::getTileCallback(), MasterBlock, nlassert, releaseVegetableBlock(), TessBlocks, NL3D::CTessBlock::TileMaterialRefCount, NL3D::ULandscapeTileCallback::tileRemoved(), NL3D::CTileMaterial::TileS, NL3D::CTileMaterial::TileT, uint, and uint64. +

+Referenced by NL3D::CTessFace::releaseTileMaterial(). +

+

01003 {
+01004         nlassert(tm);
+01005 
+01006         uint    numtb, numtm;
+01007         computeTbTm(numtb, numtm, tm->TileS, tm->TileT);
+01008         TessBlocks[numtb].RdrTileRoot[numtm]= NULL;
+01009         TessBlocks[numtb].FaceTileMaterialRefCount--;
+01010         TessBlocks[numtb].TileMaterialRefCount--;
+01011         // The master block contains the whole patch TileMaterialRefCount
+01012         MasterBlock.TileMaterialRefCount--;
+01013 
+01014         // if no more tiles in this tessBlock, delete the vegetable Block.
+01015         //==========
+01016         // if no more tiles in this tessBlock
+01017         if( TessBlocks[numtb].TileMaterialRefCount==0 )
+01018         {
+01019                 // release the vegetableBlock (if any)
+01020                 releaseVegetableBlock(numtb);
+01021         }
+01022 
+01023         // Destroy if necessary the TessBlocks.
+01024         decRefTessBlocks();
+01025 
+01026         // DynamicLighting. When in near, must compute the context, to have good UVs.
+01027         //==========
+01028         // dec ref the context, deleting it if needed.
+01029         decRefDLMContext();
+01030 
+01031         ULandscapeTileCallback *tileCallback = getLandscape()->getTileCallback();
+01032         if (tileCallback)
+01033         {
+01034                 tileCallback->tileRemoved((uint64) tm); // pointer to tile material serves as a unique identifier
+01035         }
+01036 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CPatch::renderFar0  ) 
+
+ + + + + +
+   + + +

+Render this patch, if not clipped. Call PatchCurrentDriver->renderSimpleTriangles(). +

+ +

+Definition at line 528 of file patch_render.cpp. +

+References _PatchRdrPassFar0, NL3D::CTessBlock::Far0FaceVector, isRenderClipped(), MasterBlock, NL3D_PROFILE_LAND_ADD, NL3D_PROFILE_LAND_ADD_FACE_VECTOR, nlassert, NL3D::ProfNPatchRdrFar0, NL3D::ProfNRdrFar0, NL3D::renderFaceVector(), NLMISC::CObjectVector< CTessBlock >::size(), TessBlocks, uint, and NL3D::CTessBlock::visibleFar0(). +

+Referenced by NL3D::CLandscape::render(). +

+

00529 {
+00530         NL3D_PROFILE_LAND_ADD(ProfNPatchRdrFar0, 1);
+00531 
+00532 #ifdef NL_DEBUG
+00533         // Must be visible, and must be called only if the RdrPass is enabled.
+00534         nlassert(!isRenderClipped() && _PatchRdrPassFar0);
+00535 #endif
+00536 
+00537         // Render tris of MasterBlock.
+00538         renderFaceVector(MasterBlock.Far0FaceVector);
+00539         // profile
+00540         NL3D_PROFILE_LAND_ADD_FACE_VECTOR(ProfNRdrFar0, MasterBlock.Far0FaceVector);
+00541 
+00542         // Render tris of TessBlocks.
+00543         uint                    nTessBlock= TessBlocks.size();
+00544         CTessBlock              *pTessBlock= nTessBlock>0? &TessBlocks[0]: NULL ;
+00545         for(; nTessBlock>0; pTessBlock++, nTessBlock--)
+00546         {
+00547                 CTessBlock              &tblock= *pTessBlock;
+00548                 // if block visible, render
+00549                 if( tblock.visibleFar0() )
+00550                 {
+00551                         renderFaceVector(tblock.Far0FaceVector);
+00552                         // profile
+00553                         NL3D_PROFILE_LAND_ADD_FACE_VECTOR(ProfNRdrFar0, tblock.Far0FaceVector);
+00554                 }
+00555         }
+00556 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CPatch::renderFar1  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 560 of file patch_render.cpp. +

+References _PatchRdrPassFar1, NL3D::CTessBlock::Far1FaceVector, isRenderClipped(), MasterBlock, NL3D_PROFILE_LAND_ADD, NL3D_PROFILE_LAND_ADD_FACE_VECTOR, nlassert, NL3D::ProfNPatchRdrFar1, NL3D::ProfNRdrFar1, NL3D::renderFaceVector(), NLMISC::CObjectVector< CTessBlock >::size(), TessBlocks, uint, and NL3D::CTessBlock::visibleFar1(). +

+Referenced by NL3D::CLandscape::render(). +

+

00561 {
+00562         NL3D_PROFILE_LAND_ADD(ProfNPatchRdrFar1, 1);
+00563 
+00564 #ifdef NL_DEBUG
+00565         // Must be visible, and must be called only if the RdrPass is enabled.
+00566         nlassert(!isRenderClipped() && _PatchRdrPassFar1);
+00567 #endif
+00568 
+00569         // Render tris of MasterBlock.
+00570         renderFaceVector(MasterBlock.Far1FaceVector);
+00571         // profile.
+00572         NL3D_PROFILE_LAND_ADD_FACE_VECTOR(ProfNRdrFar1, MasterBlock.Far1FaceVector);
+00573 
+00574         // Render tris of TessBlocks.
+00575         uint                    nTessBlock= TessBlocks.size();
+00576         CTessBlock              *pTessBlock= nTessBlock>0? &TessBlocks[0]: NULL ;
+00577         for(; nTessBlock>0; pTessBlock++, nTessBlock--)
+00578         {
+00579                 CTessBlock              &tblock= *pTessBlock;
+00580                 // if block visible, render
+00581                 if( tblock.visibleFar1() )
+00582                 {
+00583                         renderFaceVector(tblock.Far1FaceVector);
+00584                         // profile.
+00585                         NL3D_PROFILE_LAND_ADD_FACE_VECTOR(ProfNRdrFar1, tblock.Far1FaceVector);
+00586                 }
+00587         }
+00588 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CPatch::resetCompressedLumels  ) 
+
+ + + + + +
+   + + +

+Rebuild the packed lumels without shadow. Only the interpolated color will be used.

+

See also:
packShadowMap(), unpackShadowMap()
+ +

+Definition at line 1384 of file patch_lightmap.cpp. +

+References CompressedLumels, NL_LUMEL_BY_TILE, nlassert, size, and uint. +

+Referenced by NL3D::CZone::build(). +

+

01385 {
+01386         // Number of lumel by lines
+01387         uint lumelCount=OrderS*NL_LUMEL_BY_TILE;
+01388 
+01389         // Number of block in a line
+01390         nlassert ((lumelCount&0x3)==0);
+01391         uint numLumelBlock=lumelCount>>2;
+01392 
+01393         // Number of line
+01394         uint lineCount=OrderT*NL_LUMEL_BY_TILE;
+01395 
+01396         // Number of block line
+01397         nlassert ((lineCount&0x3)==0);
+01398         uint numLineBlock=lineCount>>2;
+01399 
+01400         // Size of the lumel array
+01401         uint size=numLineBlock*numLumelBlock*8;
+01402 
+01403         // 4 bits per lumel
+01404         CompressedLumels.resize (size);
+01405 
+01406         // No line have shadows.
+01407         memset (&CompressedLumels[0], 0, size);
+01408 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CPatch::resetMasterBlock  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 709 of file patch.cpp. +

+References NL3D::CTessList< CTessFace >::clear(), NL3D::CTessList< CTessFarVertex >::clear(), NL3D::CTessBlock::FarFaceList, NL3D::CTessBlock::FarVertexList, isRenderClipped(), MasterBlock, NL3D::CTessBlock::NearVertexList, nlassert, NumRenderableFaces, and NL3D::CTessList< CTessNearVertex >::size(). +

+Referenced by makeRoots(), and release(). +

+

00710 {
+00711         // We should be not visible so FaceVector no more exist.
+00712         nlassert(isRenderClipped());
+00713 
+00714         MasterBlock.FarVertexList.clear();
+00715         MasterBlock.FarFaceList.clear();
+00716         NumRenderableFaces= 0;
+00717         // no tiles should be here!!
+00718         nlassert(MasterBlock.NearVertexList.size()==0);
+00719 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CPatch::resetRenderFar  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 1555 of file patch.cpp. +

+References _PatchRdrPassFar0, _PatchRdrPassFar1, NL3D::CLandscape::freeFarRenderPass(), and NL3D::CZone::Landscape. +

+Referenced by release(). +

+

01556 {
+01557         if (_PatchRdrPassFar0)
+01558         {
+01559                 // free the render pass.
+01560                 Zone->Landscape->freeFarRenderPass (this, _PatchRdrPassFar0, Far0);
+01561                 _PatchRdrPassFar0= NULL;
+01562         }
+01563         if (_PatchRdrPassFar1)
+01564         {
+01565                 // free the render pass.
+01566                 Zone->Landscape->freeFarRenderPass (this, _PatchRdrPassFar1, Far1);
+01567                 _PatchRdrPassFar1= NULL;
+01568         }
+01569 
+01570         Far0= -1;
+01571         Far1= -1;
+01572 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CPatch::resetTileLightInfluences  ) 
+
+ + + + + +
+   + + +

+make a valid empty array of TileLightInfluences (ie resized to good size, but with empty light influences +

+Definition at line 1529 of file patch_lightmap.cpp. +

+References TileLightInfluences, and uint. +

+Referenced by NL3D::CZone::build(), NL3D::CLandscape::removeAllPointLights(), and serial(). +

+

01530 {
+01531         // Fill default.
+01532         TileLightInfluences.resize((OrderS/2 +1) * (OrderT/2 +1));
+01533         // Disable All light influence on all points
+01534         for(uint i=0;i <TileLightInfluences.size(); i++)
+01535         {
+01536                 // Disable all light influence on this point.
+01537                 TileLightInfluences[i].Light[0]= 0xFF;
+01538         }
+01539 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::serial NLMISC::IStream f  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 1576 of file patch.cpp. +

+References _CornerSmoothFlag, _Version, NL3D::CTileColor::Color565, CompressedLumels, NLMISC::IStream::isReading(), NL_PATCH_SMOOTH_FLAG_MASK, nlassert, NoiseRotation, resetTileLightInfluences(), NLMISC::IStream::serial(), NLMISC::IStream::serialCont(), NLMISC::IStream::serialVersion(), size, TileColors, TileLightInfluences, Tiles, uint, NLMISC::IStream::xmlPop(), NLMISC::IStream::xmlPush(), and NLMISC::IStream::xmlSerial(). +

+

01577 {
+01578         /*
+01579         Version 7:
+01580                 - remove unused information from CTileColor. just keep 565 color
+01581         Version 6:
+01582                 - default UnderWater flags for tileElements before version 6.
+01583         Version 5:
+01584                 - TileLightInfluences serialized.
+01585         Version 4:
+01586                 - Smooth flag serialized
+01587         Version 3:
+01588                 - NoiseRotation.
+01589                 - NoiseSmooth.
+01590         Version 2:
+01591                 - Lumels.
+01592         Version 1:
+01593                 - Tile color.
+01594         Version 0:
+01595                 - base version.
+01596         */
+01597         uint    ver= f.serialVersion(_Version);
+01598 
+01599         // No more compatibility before version 2, because OrderS / OrderT not serialized in preceding version
+01600         // Doens't matter since CZone::serial() do not support it too.
+01601         if (ver<2)
+01602         {
+01603                 throw EOlderStream(f);
+01604         }
+01605 
+01606         f.xmlSerial (Vertices[0], Vertices[1], Vertices[2], Vertices[3], "VERTICIES");
+01607 
+01608         f.xmlPush ("TANGENTS");
+01609         f.serial (Tangents[0], Tangents[1], Tangents[2], Tangents[3]);
+01610         f.serial (Tangents[4], Tangents[5], Tangents[6], Tangents[7]);
+01611         f.xmlPop ();
+01612         
+01613         f.xmlSerial (Interiors[0], Interiors[1], Interiors[2], Interiors[3], "INTERIORS");
+01614 
+01615         f.xmlPush ("TILES");
+01616         f.serialCont(Tiles);
+01617         f.xmlPop ();
+01618 
+01619         if(ver>=1)
+01620         {
+01621                 // Read/Write TileColors.
+01622                 if(ver<=6)
+01623                 {
+01624                         nlassert(f.isReading());
+01625 
+01626                         // read old version of tilesColors (ie with LightX/LightY/LightZ, which are deprecated now)
+01627                         vector<CTileColorOldPatchVersion6>      tmpArray;
+01628                         f.xmlPush ("TILE_COLORS");
+01629                         f.serialCont(tmpArray);
+01630                         f.xmlPop ();
+01631 
+01632                         // then just copy to TileColors.
+01633                         TileColors.resize(tmpArray.size());
+01634                         if(TileColors.size()>0)
+01635                         {
+01636                                 memcpy(&TileColors[0], &tmpArray[0], TileColors.size()*sizeof(CTileColor));
+01637                         }
+01638                 }
+01639                 else
+01640                 {
+01641                         // version >=7, just serial array of TileColors (16 bits TileColor only)
+01642                         f.xmlPush ("TILE_COLORS");
+01643                         f.serialCont(TileColors);
+01644 #ifdef NEL_FORCE_NO_USER_COLOR
+01645                         CTileColor color;
+01646                         color.Color565 = 0xffff;
+01647                         uint size = TileColors.size ();
+01648                         TileColors.resize (0);
+01649                         TileColors.resize (size, color);
+01650 #endif // NEL_FORCE_NO_USER_COLOR
+01651                         f.xmlPop ();
+01652                 }
+01653         }
+01654         if(ver>=2)
+01655         {
+01656                 f.xmlSerial (OrderS, "ORDER_S");
+01657                 f.xmlSerial (OrderT, "ORDER_T");
+01658 
+01659                 f.xmlPush ("COMPRESSED_LUMELS");
+01660                         f.serialCont(CompressedLumels);
+01661                 f.xmlPop ();
+01662         }
+01663         // Else cannot create here the TileColors, because we need the OrderS/OrderT information... Done into CZone serial.
+01664         if(ver>=3)
+01665         {
+01666                 f.xmlSerial (NoiseRotation, "NOISE_ROTATION");
+01667                 f.xmlSerial (_CornerSmoothFlag, "CORNER_SMOOTH_FLAG");
+01668         }
+01669         else
+01670         {
+01671                 // No Rotation / not smooth by default.
+01672                 NoiseRotation= 0;
+01673                 _CornerSmoothFlag= 0;
+01674         }
+01675         if(ver>=4)
+01676         {
+01677                 f.xmlSerial(Flags, "FLAGS");
+01678         }
+01679         else
+01680         {
+01681                 Flags=NL_PATCH_SMOOTH_FLAG_MASK;
+01682         }
+01683 
+01684         // Serialize TileLightInfluences
+01685         if(ver>=5)
+01686         {
+01687                 f.xmlPush ("TILE_LIGHT_INFLUENCES");
+01688                 f.serialCont(TileLightInfluences);
+01689                 f.xmlPop ();
+01690         }
+01691         else
+01692         {
+01693                 if(f.isReading())
+01694                 {
+01695                         // Fill default.
+01696                         resetTileLightInfluences();
+01697                 }
+01698         }
+01699 
+01700         // if read a too old version, 
+01701         if(ver<6 && f.isReading())
+01702         {
+01703                 // reset tileElements vegetableState to AboveWater.
+01704                 for(uint i=0; i<Tiles.size(); i++)
+01705                 {
+01706                         Tiles[i].setVegetableState(CTileElement::AboveWater);
+01707                 }
+01708         }
+01709 
+01710 
+01711 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::setCornerSmoothFlag uint  corner,
bool  smooth
+
+ + + + + +
+   + + +

+setup Smooth flags for Noise on corner: used for Noise geometry and for lighting. NB: convention: corner0==A, corner1==B ... +

+Definition at line 951 of file patch_noise.cpp. +

+References _CornerSmoothFlag, nlassert, and uint. +

+Referenced by NL3D::CZone::build(), and NL3D::CZoneCornerSmoother::computeAllCornerSmoothFlags(). +

+

00952 {
+00953         nlassert(corner<=3);
+00954         uint    mask= 1<<corner;
+00955         if(smooth)
+00956                 _CornerSmoothFlag|= mask;
+00957         else
+00958                 _CornerSmoothFlag&= ~mask;
+00959 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::setSmoothFlag uint  edge,
bool  flag
[inline]
+
+ + + + + +
+   + + +

+Set the smooth flag for the n-th edge. flag is false if this edge must by smoothed, true else. +

+Definition at line 567 of file patch.h. +

+References NL_PATCH_SMOOTH_FLAG_SHIFT, and uint. +

+

00568         {
+00569                 // Erase it
+00570                 Flags&=~(1<<(edge+NL_PATCH_SMOOTH_FLAG_SHIFT));
+00571                 
+00572                 // Set it
+00573                 Flags|=(((uint)flag)<<(edge+NL_PATCH_SMOOTH_FLAG_SHIFT));
+00574         }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::setupColorsFromTileFlags const NLMISC::CRGBA  colors[4]  ) 
+
+ + + + + +
+   + + +

+debug coloring +

+Debug purpose only : setup the colors of this patch so that it shows which tiles have vegetable disabled, or are above, below water. User provides a table with 4 colors for each state : color 0 = above water color 1 = underwater color 2 = intersect water color 3 = vegetable disabled +

+Definition at line 2231 of file patch.cpp. +

+References NLMISC::CRGBA::get565(), index, min, s, t, TileColors, Tiles, and uint. +

+

02232 {
+02233         for (uint s = 0; s <= OrderS; ++s)
+02234         {
+02235                 for (uint t = 0; t <= OrderT; ++t)
+02236                 {
+02237                         uint index = std::min(t, (uint) (OrderT - 1)) * OrderS 
+02238                                          + std::min(s, (uint) (OrderS - 1));
+02239                         TileColors[s + t * (OrderS + 1)].Color565 = colors[(uint) (Tiles[index].getVegetableState())].get565();                                 
+02240                 }
+02241         }
+02242 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CPatch::unbind  ) 
+
+ + + + + +
+   + + +

+unbind the patch from All neighbors. neighbors patchs links are modified too. The tesselation is forcemerged. +

+Definition at line 1724 of file patch.cpp. +

+References _BindZoneNeighbor, NL3D::CTessFace::FLeft, NL3D::CTessFace::forceMerge(), NL3D::CTessFace::FRight, NL3D::CTessFace::isLeaf(), nlassert, Son0, Son1, and NL3D::CTessFace::unbind(). +

+Referenced by NL3D::CZone::bindPatch(), and NL3D::CZone::unbindPatch(). +

+

01725 {
+01726         nlassert(Son0 && Son1);
+01727 
+01728         Son0->unbind();
+01729         Son1->unbind();
+01730         Son0->forceMerge();
+01731         Son1->forceMerge();
+01732         // forcemerge should have be completed.
+01733         nlassert(Son0->isLeaf() && Son1->isLeaf());
+01734         // unbind should have be completed.
+01735         nlassert(Son0->FLeft == NULL);
+01736         nlassert(Son0->FRight == NULL);
+01737         nlassert(Son1->FLeft == NULL);
+01738         nlassert(Son1->FRight == NULL);
+01739 
+01740 
+01741         // unbind Noise.
+01742         _BindZoneNeighbor[0]= NULL;
+01743         _BindZoneNeighbor[1]= NULL;
+01744         _BindZoneNeighbor[2]= NULL;
+01745         _BindZoneNeighbor[3]= NULL;
+01746 
+01747 }
+
+

+ + + + +
+ + + + + + + + + +
void NL3D::CPatch::unlinkNearUL  ) 
+
+ + + + + +
+   + + +

+For lighting update, unlink (CiruclarList). +

+ +

+Definition at line 1897 of file patch_lightmap.cpp. +

+References _ULNearNext, and _ULNearPrec. +

+Referenced by NL3D::CLandscape::unlinkPatchFromNearUL(). +

+

01898 {
+01899         // first, unlink others from me. NB: works even if _ULNearPrec==_ULNearNext==this.
+01900         _ULNearNext->_ULNearPrec= _ULNearPrec;
+01901         _ULNearPrec->_ULNearNext= _ULNearNext;
+01902         // reset
+01903         _ULNearPrec= this;
+01904         _ULNearNext= this;
+01905 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::unpack CBezierPatch p  )  const
+
+ + + + + +
+   + + +

+ +

+Definition at line 192 of file patch.cpp. +

+References NL3D::CZone::getPatchBias(), NL3D::CZone::getPatchScale(), NL3D::CBezierPatch::Interiors, sint, NL3D::CBezierPatch::Tangents, NL3D::CVector3s::unpack(), and NL3D::CBezierPatch::Vertices. +

+Referenced by unpackIntoCache(). +

+

00193 {
+00194         sint    i;
+00195         const   CVector &bias= Zone->getPatchBias();
+00196         float   scale= Zone->getPatchScale();
+00197 
+00198         for(i=0;i<4;i++)
+00199                 Vertices[i].unpack(p.Vertices[i], bias, scale);
+00200         for(i=0;i<8;i++)
+00201                 Tangents[i].unpack(p.Tangents[i], bias, scale);
+00202         for(i=0;i<4;i++)
+00203                 Interiors[i].unpack(p.Interiors[i], bias, scale);
+00204 }
+
+

+ + + + +
+ + + + + + + + + +
CBezierPatch * NL3D::CPatch::unpackIntoCache  )  const
+
+ + + + + +
+   + + +

+ +

+Definition at line 182 of file patch.cpp. +

+References CachePatch, LastPatch, and unpack(). +

+Referenced by addPatchBlocksInBBox(), addTrianglesInBBox(), appendTileMaterialToRenderList(), buildBBox(), NL3D::CZoneLighter::buildZoneInformation(), computeDefaultErrorSize(), computeNoise(), computeNormalCornerSmooth(), computeNormalEdgeSmooth(), computeNormalOnNeighbor(), computeVertex(), createVegetableBlock(), NL3D::CPatchDLMContext::generate(), generateTileVegetable(), NL3D::CLandscapeVegetableBlock::init(), and NL3D::CZoneLighter::processZonePointLightRT(). +

+

00183 {
+00184         if(LastPatch!=this)
+00185         {
+00186                 unpack(CachePatch);
+00187                 LastPatch=this;
+00188         }
+00189         return &CachePatch;
+00190 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::unpackLumelBlock uint8 dest,
const uint8 src
[private]
+
+ + + + + +
+   + + +

+Unpack a 4x4 lumel block

+

See also:
packShadowMap(), unpackShadowMap()
+ +

+Definition at line 70 of file patch_lightmap.cpp. +

+References src, uint, and uint8. +

+Referenced by computeTileLightmapPrecomputed(), getTileLumelmapPrecomputed(), packShadowMap(), and unpackShadowMap(). +

+

00071 {
+00072         // Take the two alpha values
+00073         uint alpha0=src[0];
+00074         uint alpha1=src[1];
+00075 
+00076         // precompute the 8 possible values, for each possible code.
+00077         // ------------------
+00078         uint8   values[8];
+00079         // Case 0
+00080         if (alpha0>alpha1)
+00081         {
+00082                 // unrolled, and hardcoded for faster compute
+00083                 values[0]= alpha0;
+00084                 values[1]= alpha1;
+00085                 values[2]= (uint8) ( (alpha0*219 + alpha1*37 ) >>8 ) ;  // 6*256/7
+00086                 values[3]= (uint8) ( (alpha0*183 + alpha1*73 ) >>8 ) ;  // 5*256/7
+00087                 values[4]= (uint8) ( (alpha0*146 + alpha1*110) >>8 ) ;  // 4*256/7
+00088                 values[5]= (uint8) ( (alpha0*110 + alpha1*146) >>8 ) ;  // 3*256/7
+00089                 values[6]= (uint8) ( (alpha0*73  + alpha1*183) >>8 ) ;  // 2*256/7
+00090                 values[7]= (uint8) ( (alpha0*37  + alpha1*219) >>8 ) ;  // 1*256/7
+00091         }
+00092         // Case 1
+00093         else
+00094         {
+00095                 // unrolled, and hardcoded for faster compute
+00096                 values[0]= alpha0;
+00097                 values[1]= alpha1;
+00098                 values[2]= (uint8) ( (alpha0*205 + alpha1*51 ) >>8 ) ;  // 4*256/5
+00099                 values[3]= (uint8) ( (alpha0*154 + alpha1*102) >>8 ) ;  // 3*256/5
+00100                 values[4]= (uint8) ( (alpha0*102 + alpha1*154) >>8 ) ;  // 2*256/5
+00101                 values[5]= (uint8) ( (alpha0*51  + alpha1*205) >>8 ) ;  // 1*256/5
+00102                 values[6]= 0;
+00103                 values[7]= 255;
+00104         }
+00105 
+00106 
+00107         // For each pixel, set the value according to the code
+00108         // ------------------
+00109         uint    block8Pixs[2];
+00110         // Split the 48 bits data in 2 24 bits pass.
+00111         block8Pixs[0]= ((uint)src[2]<<16) + ((uint)src[3]<<8) + ((uint)src[4]) ;
+00112         block8Pixs[1]= ((uint)src[5]<<16) + ((uint)src[6]<<8) + ((uint)src[7]) ;
+00113 
+00114         // write all lumels
+00115         for(uint i=0; i<2; i++)
+00116         {
+00117                 uint    blockPix= block8Pixs[i];
+00118                 // parse the 8 pixs, and write seq to dest
+00119                 for(uint n=8; n>0; n--, dest++)
+00120                 {
+00121                         uint code= (blockPix>>21)&0x7;
+00122 
+00123                         // read LUT, and store
+00124                         *dest= values[code];
+00125 
+00126                         // shift the block
+00127                         blockPix<<= 3;
+00128                 }
+00129         }
+00130 
+00131 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::unpackShadowMap uint8 pShadow  ) 
+
+ + + + + +
+   + + +

+Unpack the lumels of the patches. Lumels are classes that describe the lighting environnement at a given texel of the lightmap. It is used to compute the shadow map of the patch, compress it and uncompress it. This method uncompress the lumels stored in its Lumels member.

+

Parameters:
+ + + +
pShadow is a pointer on the destination lumel buffer. Size must be ((OrderS*4/ratio)+1)*((OrderT*4/ratio)+1).
ratio is the one over the ratio of the texture destination. Must be 1 or 2.
+
+
See also:
packShadowMap(), resetCompressedLumels()
+ +

+Definition at line 170 of file patch_lightmap.cpp. +

+References CompressedLumels, NL_BLOCK_LUMEL_COMPRESSED_SIZE, NL_LUMEL_BY_TILE, nlassert, uint, uint8, unpackLumelBlock(), and v. +

+Referenced by NL3D::CTextureFar::rebuildPatch(), and NL3D::CZone::retrieve(). +

+

00171 {
+00172         // Input of compresed data
+00173         uint8 *compressedData=&CompressedLumels[0];
+00174 
+00175         // Number of lumel by lines
+00176         uint lumelCount=OrderS*NL_LUMEL_BY_TILE;
+00177 
+00178         // Number of block in a line
+00179         nlassert ((lumelCount&0x3)==0);
+00180         uint numLumelBlock=lumelCount>>2;
+00181 
+00182         // Number of line
+00183         uint lineCount=OrderT*NL_LUMEL_BY_TILE;
+00184 
+00185         // Number of block line
+00186         nlassert ((lineCount&0x3)==0);
+00187         uint numLineBlock=lineCount>>2;
+00188 
+00189         // Destination lumel block size
+00190         uint lumelDestBlockSize=4;
+00191 
+00192         // Destination lumel line block size
+00193         uint lumelDestLineBlockSize=lumelCount*lumelDestBlockSize;
+00194 
+00195         // Each line block
+00196         for (uint lineBlock=0; lineBlock<numLineBlock; lineBlock++)
+00197         {
+00198                 uint countVx4=16;
+00199 
+00200                 // Block pointer
+00201                 uint8 *blockLine=pLumelDest;
+00202 
+00203                 // Each lumel block
+00204                 for (uint lumelBlock=0; lumelBlock<numLumelBlock; lumelBlock++)
+00205                 {
+00206                         // *** Unpack the block
+00207                         uint countU=4;
+00208 
+00209                         // Destination lumel
+00210                         uint8 *blockDest=blockLine;
+00211 
+00212                         // Temp block
+00213                         uint8 block[4*4];
+00214 
+00215                         // Block unpacking...
+00216                         unpackLumelBlock (block, compressedData);
+00217 
+00218                         // Copy the lumels
+00219                         for (uint v=0; v<countVx4; v+=4)
+00220                         {
+00221                                 for (uint u=0; u<countU; u++)
+00222                                 {
+00223                                         // Copy the lumel
+00224                                         blockDest[u]=block[v+u];
+00225                                 }
+00226 
+00227                                 // Next line
+00228                                 blockDest+=lumelCount;
+00229                         }
+00230 
+00231                         // Next source block
+00232                         compressedData+=NL_BLOCK_LUMEL_COMPRESSED_SIZE;
+00233 
+00234                         // Next block on the line
+00235                         blockLine+=lumelDestBlockSize;
+00236                 }
+00237 
+00238                 // Next line of block
+00239                 pLumelDest+=lumelDestLineBlockSize;
+00240         }
+00241 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::updateClipPatchVB bool  renderClipped  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 1464 of file patch_render.cpp. +

+References allocateVBAndFaceVector(), deleteVBAndFaceVector(), NLMISC::CObjectVector< CTessBlock >::empty(), fillVB(), NL3D::CTessBlock::forceClip(), NLMISC::CObjectVector< CTessBlock >::size(), TessBlocks, and uint. +

+

01465 {
+01466         // If now the patch is invisible
+01467         if(renderClipped)
+01468         {
+01469                 // Then delete vertices.
+01470                 deleteVBAndFaceVector();
+01471 
+01472                 // Now, all vertices in VB are deleted.
+01473                 // Force clip state of all TessBlocks, so no allocation will be done on Vertices in VB.
+01474                 if(!TessBlocks.empty())
+01475                 {
+01476                         for(uint i=0; i<TessBlocks.size();i++)
+01477                         {
+01478                                 CTessBlock      &tblock= TessBlocks[i];
+01479                                 tblock.forceClip();
+01480                         }
+01481                 }
+01482         }
+01483         else
+01484         {
+01485                 // else allocate / fill them.
+01486                 allocateVBAndFaceVector();
+01487                 // NB: fillVB() test if any reallocation occurs.
+01488                 fillVB();
+01489         }
+01490 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::updateFar0VBAlloc CTessList< CTessFarVertex > &  vertList,
bool  alloc
[private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 744 of file patch_render.cpp. +

+References NL3D::CTessList< T >::begin(), NL3D::CTessFarVertex::Index0, and NL3D::CTessNodeList::Next. +

+Referenced by preRender(), and updateVBAlloc(). +

+

00745 {
+00746         // Traverse the vertList.
+00747         CTessFarVertex  *pVert;
+00748         for(pVert= vertList.begin(); pVert; pVert= (CTessFarVertex*)pVert->Next)
+00749         {
+00750                 if(alloc)
+00751                         pVert->Index0= CLandscapeGlobals::CurrentFar0VBAllocator->allocateVertex();
+00752                 else
+00753                         CLandscapeGlobals::CurrentFar0VBAllocator->deleteVertex(pVert->Index0);
+00754         }
+00755 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::updateFar1VBAlloc CTessList< CTessFarVertex > &  vertList,
bool  alloc
[private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 759 of file patch_render.cpp. +

+References NL3D::CTessList< T >::begin(), NL3D::CTessFarVertex::Index1, and NL3D::CTessNodeList::Next. +

+Referenced by allocateVBAndFaceVectorFar1Only(), deleteVBAndFaceVectorFar1Only(), preRender(), and updateVBAlloc(). +

+

00760 {
+00761         // Traverse the vertList.
+00762         CTessFarVertex  *pVert;
+00763         for(pVert= vertList.begin(); pVert; pVert= (CTessFarVertex*)pVert->Next)
+00764         {
+00765                 if(alloc)
+00766                         pVert->Index1= CLandscapeGlobals::CurrentFar1VBAllocator->allocateVertex();
+00767                 else
+00768                         CLandscapeGlobals::CurrentFar1VBAllocator->deleteVertex(pVert->Index1);
+00769         }
+00770 }
+
+

+ + + + +
+ + + + + + + + + + +
uint NL3D::CPatch::updateTessBlockLighting uint  numTb  ) 
+
+ + + + + +
+   + + +

+recompute the near lightmap of tessBlock "numTb". return the number of pixels updated by computing of this tessBlock. Actually 0 if the tessBlock lightmap is not computed, or 100 (NL_TILE_LIGHTMAP_SIZE*NL_TILE_LIGHTMAP_SIZE) pixels. +

+Definition at line 1909 of file patch_lightmap.cpp. +

+References computeNearBlockLightmap(), NL3D::CZone::Landscape, NL3D::CTessBlock::LightMapId, NL3D::CTessBlock::LightMapRefCount, NL_TILE_LIGHTMAP_SIZE, nlassert, NL3D::CLandscape::refillTileLightMap(), NLMISC::CObjectVector< CTessBlock >::size(), TessBlocks, and uint. +

+Referenced by NL3D::CLandscape::updateLightingTextureNear(). +

+

01910 {
+01911         // TessBlocks must have been allocated and tessBlockId must be ok.
+01912         nlassert(numTb<TessBlocks.size());
+01913 
+01914         // compute tessBlock coordinate
+01915         uint tbWidth= OrderS>>1;
+01916         uint ts= numTb&(tbWidth-1);
+01917         uint tt= numTb/tbWidth;
+01918         // expand to tile coordinate.
+01919         ts*= 2;
+01920         tt*= 2;
+01921 
+01922         // get what tessBlock to use.
+01923         CTessBlock      &tessBlock= TessBlocks[numTb];
+01924 
+01925         // If the lightmap Id has not been computed, quit
+01926         if(tessBlock.LightMapRefCount==0)
+01927                 return 0;
+01928         else
+01929         {
+01930                 // Recompute the lightmap texture, with help of TileColors, with neighboring info etc...
+01931                 CRGBA   lightText[NL_TILE_LIGHTMAP_SIZE*NL_TILE_LIGHTMAP_SIZE];
+01932                 computeNearBlockLightmap(ts&(~1), tt&(~1), lightText);
+01933 
+01934                 // donlod this texture to Driver etc...
+01935                 Zone->Landscape->refillTileLightMap(tessBlock.LightMapId, lightText);
+01936 
+01937                 // return number of pixels computed.
+01938                 return  NL_TILE_LIGHTMAP_SIZE*NL_TILE_LIGHTMAP_SIZE;
+01939         }
+01940 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::updateTextureFarOnly const NLMISC::CBSphere patchSphere  ) 
+
+ + + + + +
+   + + +

+ +

+Definition at line 226 of file patch_render.cpp. +

+References computeNewFar(), and sint. +

+

00227 {
+00228         sint    newFar0,newFar1;
+00229         // compute new Far0 and new Far1.
+00230         computeNewFar(patchSphere, newFar0, newFar1);
+00231 
+00232         // Far change.
+00233         //------------------
+00234         // Set new far values
+00235         Far0= newFar0;
+00236         Far1= newFar1;
+00237 }
+
+

+ + + + +
+ + + + + + + + + + + + + + + + + + + +
void NL3D::CPatch::updateTileVBAlloc CTessList< CTessNearVertex > &  vertList,
bool  alloc
[private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 774 of file patch_render.cpp. +

+References NL3D::CTessList< T >::begin(), NL3D::CTessNearVertex::Index, and NL3D::CTessNodeList::Next. +

+Referenced by preRender(), and updateVBAlloc(). +

+

00775 {
+00776         // Traverse the vertList.
+00777         CTessNearVertex *pVert;
+00778         for(pVert= vertList.begin(); pVert; pVert= (CTessNearVertex*)pVert->Next)
+00779         {
+00780                 if(alloc)
+00781                         pVert->Index= CLandscapeGlobals::CurrentTileVBAllocator->allocateVertex();
+00782                 else
+00783                         CLandscapeGlobals::CurrentTileVBAllocator->deleteVertex(pVert->Index);
+00784         }
+00785 }
+
+

+ + + + +
+ + + + + + + + + + +
void NL3D::CPatch::updateVBAlloc bool  alloc  )  [private]
+
+ + + + + +
+   + + +

+ +

+Definition at line 789 of file patch_render.cpp. +

+References NL3D::CTessBlock::FarVertexList, MasterBlock, NL3D::CTessBlock::NearVertexList, sint, NLMISC::CObjectVector< CTessBlock >::size(), TessBlocks, updateFar0VBAlloc(), updateFar1VBAlloc(), updateTileVBAlloc(), NL3D::CTessBlock::visibleFar0(), NL3D::CTessBlock::visibleFar1(), and NL3D::CTessBlock::visibleTile(). +

+Referenced by allocateVBAndFaceVector(), and deleteVBAndFaceVector(). +

+

00790 {
+00791         // update Far0.
+00792         //=======
+00793         if(Far0>0)
+00794         {
+00795                 // alloc Far0 VB.
+00796                 updateFar0VBAlloc(MasterBlock.FarVertexList, alloc);
+00797                 for(sint i=0; i<(sint)TessBlocks.size(); i++)
+00798                 {
+00799                         CTessBlock      &tblock= TessBlocks[i];
+00800                         // need update VB only if tessBlock is visible.
+00801                         if( tblock.visibleFar0() )
+00802                                 updateFar0VBAlloc(tblock.FarVertexList, alloc);
+00803                 }
+00804         }
+00805         else if (Far0==0)
+00806         {
+00807                 // alloc Tile VB.
+00808                 // No Tiles in MasterBlock!!
+00809                 // Traverse the TessBlocks to add vertices.
+00810                 for(sint i=0; i<(sint)TessBlocks.size(); i++)
+00811                 {
+00812                         CTessBlock      &tblock= TessBlocks[i];
+00813                         // Add the vertices.
+00814                         // need update VB only if tessBlock is visible.
+00815                         if( tblock.visibleTile() )
+00816                                 updateTileVBAlloc(tblock.NearVertexList, alloc);
+00817                 }
+00818         }
+00819 
+00820         // update Far1.
+00821         //=======
+00822         if(Far1>0)
+00823         {
+00824                 // alloc VB.
+00825                 updateFar1VBAlloc(MasterBlock.FarVertexList, alloc);
+00826                 for(sint i=0; i<(sint)TessBlocks.size(); i++)
+00827                 {
+00828                         CTessBlock      &tblock= TessBlocks[i];
+00829                         // need update VB only if tessBlock is visible.
+00830                         if( tblock.visibleFar1() )
+00831                                 updateFar1VBAlloc(tblock.FarVertexList, alloc);
+00832                 }
+00833         }
+00834 }
+
+


Friends And Related Function Documentation

+

+ + + + +
+ + +
friend class CLandscapeVegetableBlock [friend] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 796 of file patch.h.

+

+ + + + +
+ + +
friend class CPatchRdrPass [friend] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 797 of file patch.h.

+

+ + + + +
+ + +
friend class CTessFace [friend] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 794 of file patch.h.

+

+ + + + +
+ + +
friend class CZone [friend] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 795 of file patch.h.

+


Field Documentation

+

+ + + + +
+ + +
CZone* NL3D::CPatch::_BindZoneNeighbor[4] [private] +
+
+ + + + + +
+   + + +

+The 4 neighbors zone of this patch (setuped at bind() time). NB: NULL if zone not loaded, or if no patch near us. +

+ +

+Definition at line 1110 of file patch.h. +

+Referenced by bind(), CPatch(), getBindNeighbor(), and unbind().

+

+ + + + +
+ + +
uint8 NL3D::CPatch::_CornerSmoothFlag [private] +
+
+ + + + + +
+   + + +

+Put here for packing with NoiseRotation. +

+ +

+Definition at line 362 of file patch.h. +

+Referenced by CPatch(), getCornerSmoothFlag(), serial(), and setCornerSmoothFlag().

+

+ + + + +
+ + +
CPatchDLMContext* NL3D::CPatch::_DLMContext [private] +
+
+ + + + + +
+   + + +

+The Dynamic LightMap context. created only when compiled, AND (when in Near OR (when in Far AND touched by pointLight)) else NULL. +

+Definition at line 1214 of file patch.h. +

+Referenced by addRefDLMContext(), beginDLMLighting(), CPatch(), decRefDLMContext(), endDLMLighting(), fillFar0DLMUvOnlyVertexListVB(), fillFar0VertexVB(), fillFar1DLMUvOnlyVertexListVB(), fillFar1VertexVB(), generateTileVegetable(), NL3D::CTessFace::initTileUvDLM(), processDLMLight(), and release().

+

+ + + + +
+ + +
sint NL3D::CPatch::_DLMContextRefCount [private] +
+
+ + + + + +
+   + + +

+The reference count for DLMContext. Each TileMaterial created add a reference. Each pointLight wich touch the patch too. +

+Definition at line 1219 of file patch.h. +

+Referenced by addRefDLMContext(), CPatch(), decRefDLMContext(), and release().

+

+ + + + +
+ + +
CPatch* NL3D::CPatch::_NextRdrFar0 [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 872 of file patch.h. +

+Referenced by NL3D::CPatchRdrPass::appendRdrPatchFar0(), CPatch(), and getNextFar0ToRdr().

+

+ + + + +
+ + +
CPatch* NL3D::CPatch::_NextRdrFar1 [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 874 of file patch.h. +

+Referenced by NL3D::CPatchRdrPass::appendRdrPatchFar1(), CPatch(), and getNextFar1ToRdr().

+

+ + + + +
+ + +
CPatchRdrPass* NL3D::CPatch::_PatchRdrPassFar0 [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 871 of file patch.h. +

+Referenced by computeNewFar(), CPatch(), preRender(), renderFar0(), and resetRenderFar().

+

+ + + + +
+ + +
CPatchRdrPass* NL3D::CPatch::_PatchRdrPassFar1 [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 873 of file patch.h. +

+Referenced by computeNewFar(), CPatch(), preRender(), renderFar1(), and resetRenderFar().

+

+ + + + +
+ + +
CPatch* NL3D::CPatch::_ULNearNext [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 1203 of file patch.h. +

+Referenced by compile(), CPatch(), getNextNearUL(), linkBeforeNearUL(), release(), and unlinkNearUL().

+

+ + + + +
+ + +
CPatch* NL3D::CPatch::_ULNearPrec [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 1202 of file patch.h. +

+Referenced by compile(), CPatch(), linkBeforeNearUL(), release(), and unlinkNearUL().

+

+ + + + +
+ + +
uint32 NL3D::CPatch::_Version = 7 [static, private] +
+
+ + + + + +
+   + + +

+Stream version of the class. +

+Definition at line 57 of file patch.cpp. +

+Referenced by serial().

+

+ + + + +
+ + +
CTessFarVertex NL3D::CPatch::BaseFarVertices[4] [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 822 of file patch.h. +

+Referenced by makeRoots().

+

+ + + + +
+ + +
CTessVertex* NL3D::CPatch::BaseVertices[4] [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 820 of file patch.h. +

+Referenced by averageTesselationVertices(), bind(), compile(), computeContinousVertex(), computeVertexButCorner(), getCornerVertex(), makeRoots(), and refreshTesselationGeometry().

+

+ + + + +
+ + +
CBezierPatch NL3D::CPatch::CachePatch [static, private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 55 of file patch.cpp. +

+Referenced by unpackIntoCache().

+

+ + + + +
+ + +
std::vector<uint8> NL3D::CPatch::CompressedLumels +
+
+ + + + + +
+   + + +

+ +

+Definition at line 337 of file patch.h. +

+Referenced by computeTileLightmapEdgePrecomputed(), computeTileLightmapPixelPrecomputed(), computeTileLightmapPrecomputed(), getTileLumelmapPixelPrecomputed(), getTileLumelmapPrecomputed(), packShadowMap(), resetCompressedLumels(), serial(), and unpackShadowMap().

+

+ + + + +
+ + +
float NL3D::CPatch::ErrorSize [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 816 of file patch.h. +

+Referenced by compile(), computeDefaultErrorSize(), getErrorSize(), and makeRoots().

+

+ + + + +
+ + +
bool NL3D::CPatch::ExcludeFromRefineAll [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 807 of file patch.h. +

+Referenced by CPatch(), and NL3D::CZone::refineAll().

+

+ + + + +
+ + +
sint NL3D::CPatch::Far0 [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 867 of file patch.h.

+

+ + + + +
+ + +
float NL3D::CPatch::Far0UBias [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 827 of file patch.h. +

+Referenced by computeNewFar(), and fillFar0VertexVB().

+

+ + + + +
+ + +
float NL3D::CPatch::Far0UScale [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 827 of file patch.h. +

+Referenced by computeNewFar(), and fillFar0VertexVB().

+

+ + + + +
+ + +
float NL3D::CPatch::Far0VBias [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 827 of file patch.h. +

+Referenced by computeNewFar(), and fillFar0VertexVB().

+

+ + + + +
+ + +
float NL3D::CPatch::Far0VScale [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 827 of file patch.h. +

+Referenced by computeNewFar(), and fillFar0VertexVB().

+

+ + + + +
+ + +
sint NL3D::CPatch::Far1 [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 868 of file patch.h.

+

+ + + + +
+ + +
float NL3D::CPatch::Far1UBias [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 828 of file patch.h. +

+Referenced by computeNewFar(), and fillFar1VertexVB().

+

+ + + + +
+ + +
float NL3D::CPatch::Far1UScale [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 828 of file patch.h. +

+Referenced by computeNewFar(), and fillFar1VertexVB().

+

+ + + + +
+ + +
float NL3D::CPatch::Far1VBias [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 828 of file patch.h. +

+Referenced by computeNewFar(), and fillFar1VertexVB().

+

+ + + + +
+ + +
float NL3D::CPatch::Far1VScale [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 828 of file patch.h. +

+Referenced by computeNewFar(), and fillFar1VertexVB().

+

+ + + + +
+ + +
uint8 NL3D::CPatch::Flags [private] +
+
+ + + + + +
+   + + +

+Flags NL_PATCH_FAR0_ROTATED and NL_PATCH_FAR1_ROTATED NL_PATCH_FAR0_ROTATED for Far0, NL_PATCH_FAR1_ROTATED for Far1 If the flag is set, the far texture of the patch is rotated of 1 (to the left of course)

+Flags NL_PATCH_SMOOTH_FLAG_MASK 4 flag for smooth edge. Same as CPatchInfo::CBindInfo shifted by (<<NL_PATCH_SMOOTH_FLAG_SHIFT). See CPatchInfo::CBindInfo::Flags for details. +

+Definition at line 840 of file patch.h. +

+Referenced by NL3D::CZone::build(), and NL3D::CZone::retrieve().

+

+ + + + +
+ + +
CVector3s NL3D::CPatch::Interiors[4] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 329 of file patch.h. +

+Referenced by NL3D::CZone::applyHeightField(), NL3D::CZone::build(), and NL3D::CZone::retrieve().

+

+ + + + +
+ + +
const CPatch * NL3D::CPatch::LastPatch = NULL [static, private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 56 of file patch.cpp. +

+Referenced by unpackIntoCache().

+

+ + + + +
+ + +
CTessBlock NL3D::CPatch::MasterBlock [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 884 of file patch.h. +

+Referenced by allocateVBAndFaceVectorFar1Only(), appendFaceToRenderList(), appendFarVertexToRenderList(), appendTileMaterialToRenderList(), compile(), computeSoftwareGeomorphAndAlpha(), CPatch(), createFaceVectorFar0OrTile(), createFaceVectorFar1(), debugAllocationMarkIndices(), deleteFaceVectorFar0OrTile(), deleteFaceVectorFar1(), deleteVBAndFaceVectorFar1Only(), fillVB(), fillVBFar0Only(), fillVBFar1Only(), fillVBFarsDLMUvOnly(), getTileMaterialRefCount(), recreateTessBlockFaceVector(), removeFaceFromRenderList(), removeFarVertexFromRenderList(), removeTileMaterialFromRenderList(), renderFar0(), renderFar1(), resetMasterBlock(), and updateVBAlloc().

+

+ + + + +
+ + +
uint8 NL3D::CPatch::NoiseRotation +
+
+ + + + + +
+   + + +

+The orientation of the NoiseMap. 0,1,2,3. This represent a CCW rotation of the NoiseMap. +

+ +

+Definition at line 352 of file patch.h. +

+Referenced by NL3D::CZone::build(), computeDisplaceRawCoordinates(), CPatch(), NL3D::CZone::retrieve(), and serial().

+

+ + + + +
+ + +
sint NL3D::CPatch::NumRenderableFaces [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 879 of file patch.h. +

+Referenced by appendFaceToRenderList(), NL3D::CPatchRdrPass::appendRdrPatchFar0(), NL3D::CPatchRdrPass::appendRdrPatchFar1(), CPatch(), preRender(), removeFaceFromRenderList(), and resetMasterBlock().

+

+ + + + +
+ + +
float NL3D::CPatch::OOTransitionSqrDelta [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 845 of file patch.h. +

+Referenced by computeGeomorphAlphaFar1VertexListVB(), computeNewFar(), and fillFar1VertexVB().

+

+ + + + +
+ + +
uint8 NL3D::CPatch::OrderS [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 804 of file patch.h. +

+Referenced by bind(), NL3D::CZone::build(), NL3D::CZone::compile(), NL3D::CTessFace::computeTileMaterial(), and NL3D::CZone::retrieve().

+

+ + + + +
+ + +
uint8 NL3D::CPatch::OrderT [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 804 of file patch.h. +

+Referenced by bind(), NL3D::CZone::build(), NL3D::CZone::compile(), NL3D::CTessFace::computeTileMaterial(), and NL3D::CZone::retrieve().

+

+ + + + +
+ + +
uint16 NL3D::CPatch::PatchId [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 802 of file patch.h.

+

+ + + + +
+ + +
CTessFace* NL3D::CPatch::Son0 [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 818 of file patch.h. +

+Referenced by appendTessellationLeaves(), averageTesselationVertices(), bind(), changeEdgeNeighbor(), CPatch(), deleteTileUvs(), forceMergeAtTileLevel(), getRootFaceForEdge(), getRootVertexForEdge(), getTesselatedPos(), linkTessFaceWithEdge(), makeRoots(), recreateTileUvs(), refineAll(), refreshTesselationGeometry(), release(), and unbind().

+

+ + + + +
+ + +
CTessFace * NL3D::CPatch::Son1 [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 818 of file patch.h. +

+Referenced by appendTessellationLeaves(), averageTesselationVertices(), bind(), changeEdgeNeighbor(), CPatch(), deleteTileUvs(), forceMergeAtTileLevel(), getRootFaceForEdge(), getRootVertexForEdge(), getTesselatedPos(), linkTessFaceWithEdge(), makeRoots(), recreateTileUvs(), refineAll(), refreshTesselationGeometry(), release(), and unbind().

+

+ + + + +
+ + +
sint NL3D::CPatch::SquareLimitLevel [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 814 of file patch.h. +

+Referenced by compile(), and NL3D::CTessFace::isRectangular().

+

+ + + + +
+ + +
CVector3s NL3D::CPatch::Tangents[8] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 328 of file patch.h. +

+Referenced by NL3D::CZone::applyHeightField(), NL3D::CZone::build(), and NL3D::CZone::retrieve().

+

+ + + + +
+ + +
sint NL3D::CPatch::TessBlockLimitLevel [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 810 of file patch.h. +

+Referenced by appendFaceToRenderList(), compile(), extendTessBlockWithEndPos(), and removeFaceFromRenderList().

+

+ + + + +
+ + +
sint NL3D::CPatch::TessBlockRefCount [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 886 of file patch.h. +

+Referenced by addRefTessBlocks(), clearTessBlocks(), CPatch(), and decRefTessBlocks().

+

+ + + + +
+ + +
NLMISC::CObjectVector<CTessBlock> NL3D::CPatch::TessBlocks [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 882 of file patch.h. +

+Referenced by addRefTessBlocks(), allocateVBAndFaceVectorFar1Only(), appendFaceToRenderList(), appendFaceToTileRenderList(), appendFarVertexToRenderList(), appendNearVertexToRenderList(), appendTileMaterialToRenderList(), clearTessBlocks(), computeSoftwareGeomorphAndAlpha(), createFaceVectorFar0OrTile(), createFaceVectorFar1(), createVegetableBlock(), debugAllocationMarkIndices(), deleteAllVegetableIgs(), deleteFaceVectorFar0OrTile(), deleteFaceVectorFar1(), deleteVBAndFaceVectorFar1Only(), extendTessBlockWithEndPos(), fillVB(), fillVBFar0Only(), fillVBFar1Only(), fillVBFarsDLMUvOnly(), getNumNearTessBlocks(), getTileLightMap(), getTileLightMapUvInfo(), preRender(), recreateAllVegetableIgs(), recreateTileUvs(), releaseTileLightMap(), releaseVegetableBlock(), removeFaceFromRenderList(), removeFaceFromTileRenderList(), removeFarVertexFromRenderList(), removeNearVertexFromRenderList(), removeTileMaterialFromRenderList(), renderFar0(), renderFar1(), updateClipPatchVB(), updateTessBlockLighting(), and updateVBAlloc().

+

+ + + + +
+ + +
std::vector<CTileColor> NL3D::CPatch::TileColors +
+
+ + + + + +
+   + + +

+ +

+Definition at line 343 of file patch.h. +

+Referenced by NL3D::CZone::build(), NL3D::CPatchDLMContext::compileLighting(), NL3D::CPatchDLMContext::computeTextureFar(), NL3D::CPatchDLMContext::generate(), getTileTileColors(), NL3D::CTextureFar::rebuildPatch(), NL3D::CZone::retrieve(), serial(), and setupColorsFromTileFlags().

+

+ + + + +
+ + +
std::vector<CTileLightInfluence> NL3D::CPatch::TileLightInfluences +
+
+ + + + + +
+   + + +

+ +

+Definition at line 346 of file patch.h. +

+Referenced by appendTileLightInfluences(), NL3D::CZone::build(), resetTileLightInfluences(), NL3D::CZone::retrieve(), and serial().

+

+ + + + +
+ + +
sint NL3D::CPatch::TileLimitLevel [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 812 of file patch.h. +

+Referenced by compile(), NL3D::CTessFace::computeNearLimit(), NL3D::CTessFace::computeTileMaterial(), NL3D::CTessFace::deleteTileUvs(), NL3D::CTessFace::doMerge(), NL3D::CTessFace::forceMergeAtTileLevel(), NL3D::CTessFace::recreateTileUvs(), NL3D::CTessFace::refineAll(), NL3D::CTessFace::releaseTileMaterial(), NL3D::CTessFace::split(), NL3D::CTessFace::splitRectangular(), NL3D::CTessFace::updateErrorMetric(), NL3D::CTessFace::updateRefineMerge(), and NL3D::CTessFace::updateRefineSplit().

+

+ + + + +
+ + +
std::vector<CTileElement> NL3D::CPatch::Tiles +
+
+ + + + + +
+   + + +

+ +

+Definition at line 340 of file patch.h. +

+Referenced by NL3D::CZone::build(), computeDisplaceRawInteger(), NL3D::CPatchDLMContext::computeTextureFar(), copyTileFlagsFromPatch(), generateTileVegetable(), getTileElement(), getTileRenderPass(), getTileUvInfo(), NL3D::CTextureFar::rebuildPatch(), NL3D::CZone::retrieve(), serial(), and setupColorsFromTileFlags().

+

+ + + + +
+ + +
float NL3D::CPatch::TransitionSqrMin [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 844 of file patch.h. +

+Referenced by computeGeomorphAlphaFar1VertexListVB(), computeNewFar(), and fillFar1VertexVB().

+

+ + + + +
+ + +
std::vector<CVegetableClipBlock*> NL3D::CPatch::VegetableClipBlocks [private] +
+
+ + + + + +
+   + + +

+list of vegetable clipBlocks, created/destroyed at same time as TessBlocks. +

+ +

+Definition at line 893 of file patch.h. +

+Referenced by addRefTessBlocks(), clearTessBlocks(), and createVegetableBlock().

+

+ + + + +
+ + +
CVector3s NL3D::CPatch::Vertices[4] +
+
+ + + + + +
+   + + +

+The patch coordinates (see CBezierPatch). +

+ +

+Definition at line 327 of file patch.h. +

+Referenced by NL3D::CZone::applyHeightField(), NL3D::CZone::build(), and NL3D::CZone::retrieve().

+

+ + + + +
+ + +
CZone* NL3D::CPatch::Zone [private] +
+
+ + + + + +
+   + + +

+ +

+Definition at line 799 of file patch.h.

+


The documentation for this class was generated from the following files: +
Generated on Tue Mar 16 07:00:40 2004 for NeL by + +doxygen +1.3.6
+ + -- cgit v1.2.1