00001
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #ifndef NL_PATCH_H
00031 #define NL_PATCH_H
00032
00033 #include "nel/misc/types_nl.h"
00034 #include "nel/misc/vector.h"
00035 #include "nel/misc/vector_2f.h"
00036 #include "3d/tessellation.h"
00037 #include "nel/misc/aabbox.h"
00038 #include "nel/misc/bsphere.h"
00039 #include "nel/misc/triangle.h"
00040 #include "nel/misc/geom_ext.h"
00041 #include "3d/tile_element.h"
00042 #include "3d/tile_color.h"
00043 #include "3d/tess_block.h"
00044 #include "3d/tile_light_influence.h"
00045 #include "nel/3d/point_light_influence.h"
00046
00047
00048 namespace NL3D {
00049
00050 #define NL_MAX_TILES_BY_PATCH_EDGE_SHIFT 4 // max 16x16 tiles by patch (shift version)
00051 #define NL_MAX_TILES_BY_PATCH_EDGE (1<<NL_MAX_TILES_BY_PATCH_EDGE_SHIFT) // max 16x16 tiles by patch
00052 #define NL_PATCH_FAR0_ROTATED 0x1 // Flags far0 rotated
00053 #define NL_PATCH_FAR1_ROTATED 0x2 // Flags far1 rotated
00054 #define NL_PATCH_SMOOTH_FLAG_SHIFT 0x2 // Smooth flags shift
00055 #define NL_PATCH_SMOOTH_FLAG_MASK 0x3c // Smooth flags mask
00056
00057 #define NL_LUMEL_BY_TILE_SHIFT 2 // 4 lumels by tile
00058 #define NL_LUMEL_BY_TILE (1<<NL_LUMEL_BY_TILE_SHIFT) // 4 lumels by tile
00059 #define NL_BLOCK_LUMEL_COMPRESSED_SIZE 8 // Compressed block size 8 bytes
00060
00061
00062 #define NL_PATCH_BLOCK_MAX_QUAD 4 // Max quad per CPatchQuadBlock.
00063 #define NL_PATCH_BLOCK_MAX_VERTEX (NL_PATCH_BLOCK_MAX_QUAD+1) // Max vertex per CPatchQuadBlock.
00064
00065
00066 using NLMISC::CVector;
00067 using NLMISC::CPlane;
00068 using NLMISC::CAABBox;
00069 using NLMISC::CBSphere;
00070
00071
00072 class CLandscape;
00073 class CZone;
00074 class CBezierPatch;
00075 class ITexture;
00076 class CVegetableClipBlock;
00077 class CVegetableManager;
00078 class CVegetableInstanceGroup;
00079 class CLandscapeVegetableBlock;
00080 class CLandscapeVegetableBlockCreateContext;
00081 class CPatchDLMContext;
00082 class CPatchDLMPointLight;
00083
00084
00085
00086 #define NL3D_NOISE_MAX 1
00087
00088
00089
00090
00091
00092
00093
00094 #define NL3D_PATCH_VEGETABLE_NUM_TESSBLOCK_PER_CLIPBLOCK_SHIFT 1
00095 #define NL3D_PATCH_VEGETABLE_NUM_TESSBLOCK_PER_CLIPBLOCK (1<<NL3D_PATCH_VEGETABLE_NUM_TESSBLOCK_PER_CLIPBLOCK_SHIFT)
00096
00097
00098
00099 class CVector3s
00100 {
00101 public:
00102 sint16 x,y,z;
00103
00104 public:
00105 void pack(const CVector &v, const CVector &bias, float scale)
00106 {
00107 float xr,yr,zr;
00108 xr= (v.x - bias.x)/scale;
00109 yr= (v.y - bias.y)/scale;
00110 zr= (v.z - bias.z)/scale;
00111 NLMISC::clamp(xr, -32768, 32767);
00112 NLMISC::clamp(yr, -32768, 32767);
00113 NLMISC::clamp(zr, -32768, 32767);
00114 x= (sint16)xr;
00115 y= (sint16)yr;
00116 z= (sint16)zr;
00117 }
00118 void unpack(CVector &v, const CVector &bias, float scale) const
00119 {
00120 v.x= x*scale + bias.x;
00121 v.y= y*scale + bias.y;
00122 v.z= z*scale + bias.z;
00123 }
00124 void serial(NLMISC::IStream &f)
00125 {
00126 f.serial(x,y,z);
00127 }
00128 };
00129
00130
00131
00139 struct CPatchIdent
00140 {
00141 sint32 ZoneId;
00142 uint16 PatchId;
00143
00144
00145 CPatchIdent() {}
00146
00147 CPatchIdent(sint32 zoneId, uint16 patchId) : ZoneId(zoneId), PatchId(patchId) {}
00148 public:
00149 bool operator<(const CPatchIdent &p) const
00150 {
00151 if(ZoneId!=p.ZoneId) return ZoneId<p.ZoneId;
00152 return PatchId<p.PatchId;
00153 }
00154
00155 bool operator==(const CPatchIdent &p) const
00156 {
00157 return ZoneId==p.ZoneId && PatchId==p.PatchId;
00158 }
00159 bool operator!=(const CPatchIdent &p) const
00160 {
00161 return !(*this==p);
00162 }
00163
00164 };
00165
00166
00167
00175 struct CTrianglePatch : public NLMISC::CTriangleUV
00176 {
00178 CPatchIdent PatchId;
00179 };
00180
00181
00182
00190 class CPatchBlockIdent
00191 {
00192 public:
00194 CPatchIdent PatchId;
00196 uint8 OrderS,OrderT;
00198 uint8 S0,S1,T0,T1;
00199
00200 public:
00202
00203 bool operator==(const CPatchBlockIdent &pb) const
00204 {
00205 return PatchId==pb.PatchId &&
00206 S0==pb.S0 && S1==pb.S1 &&
00207 T0==pb.T0 && T1==pb.T1;
00208 }
00209 bool operator!=(const CPatchBlockIdent &pb) const
00210 {
00211 return !(*this==pb);
00212 }
00213
00214 bool operator<(const CPatchBlockIdent &pb) const
00215 {
00216 if(PatchId!=pb.PatchId)
00217 return PatchId<pb.PatchId;
00218 if(S0!=pb.S0) return S0<pb.S0;
00219 if(S1!=pb.S1) return S1<pb.S1;
00220 if(T0!=pb.T0) return T0<pb.T0;
00221 return T1<pb.T1;
00222 }
00223 bool operator<=(const CPatchBlockIdent &pb) const
00224 {
00225 return (*this<pb) || (*this==pb);
00226 }
00227 bool operator>(const CPatchBlockIdent &pb) const
00228 {
00229 return !(*this<=pb);
00230 }
00231 bool operator>=(const CPatchBlockIdent &pb) const
00232 {
00233 return !(*this<pb);
00234 }
00235
00236
00237 };
00238
00239
00240
00248 class CPatchQuadBlock
00249 {
00250 public:
00252 CPatchBlockIdent PatchBlockId;
00253
00255 CVector Vertices[NL_PATCH_BLOCK_MAX_VERTEX*NL_PATCH_BLOCK_MAX_VERTEX];
00256
00257 public:
00258
00262 void buildTileTriangles(uint8 quadId, CTrianglePatch triangles[2]) const;
00263 };
00264
00265
00266
00267
00299 class CPatch
00300 {
00301 public:
00302
00303 struct CBindInfo
00304 {
00305
00306 CZone *Zone;
00307
00308
00309 sint NPatchs;
00310
00311
00312
00313 uint8 MultipleBindNum;
00314
00315 uint8 MultipleBindId;
00316
00317
00318 CPatch *Next[4];
00319 sint Edge[4];
00320 };
00321
00322 public:
00324 CVector3s Vertices[4];
00325 CVector3s Tangents[8];
00326 CVector3s Interiors[4];
00327
00328
00329
00330
00331
00332
00333
00334 std::vector<uint8> CompressedLumels;
00335
00336
00337 std::vector<CTileElement> Tiles;
00338
00339
00340 std::vector<CTileColor> TileColors;
00341
00342
00343 std::vector<CTileLightInfluence> TileLightInfluences;
00344
00345
00347
00349
00350
00354 void setCornerSmoothFlag(uint corner, bool smooth);
00355 bool getCornerSmoothFlag(uint corner) const;
00356
00357 private:
00359 uint8 _CornerSmoothFlag;
00360
00361 public:
00362
00363
00364
00365 public:
00366
00368 CPatch();
00370 ~CPatch();
00371
00381 void compile(CZone *z, uint patchId, uint8 orderS, uint8 orderT, CTessVertex *baseVertices[4], float errorSize=0);
00383 void release();
00384
00385
00387 CLandscape *getLandscape () const;
00388 CZone *getZone() const {return Zone;}
00389 uint8 getOrderS() const {return OrderS;}
00390 uint8 getOrderT() const {return OrderT;}
00391 uint8 getOrderForEdge(sint8 edge) const;
00392 float getErrorSize() const {return ErrorSize;}
00393 sint getFar0() const {return Far0;}
00394 sint getFar1() const {return Far1;}
00395 uint16 getPatchId () const {return PatchId;}
00397 void getBindNeighbor(uint edge, CBindInfo &neighborEdge) const;
00398
00400 CAABBox buildBBox() const;
00401
00403 const CBSphere &getBSphere() const {return BSphere;}
00404
00412 CVector computeVertex(float s, float t) const;
00413
00414
00422 CVector computeContinousVertex(float s, float t) const;
00423
00424
00427 void unbind();
00428
00433 void bind(CBindInfo Edges[4], bool rebind);
00434
00436 void forceMergeAtTileLevel();
00437
00440 void averageTesselationVertices();
00441
00443 void forceNoClip() {Clipped= false;}
00445 void forceClip() {Clipped= true;}
00447 void forceNoRenderClip() {RenderClipped= false;}
00449 void forceRenderClip() {RenderClipped= true;}
00451 void clip(const std::vector<CPlane> &pyramid);
00453 void refineAll();
00454
00455
00457
00458
00460 void preRender();
00461
00462 void updateTextureFarOnly();
00464
00465 void renderFar0();
00466 void renderFar1();
00467
00468
00469 void computeSoftwareGeomorphAndAlpha();
00471
00472
00473
00474 void resetRenderFar();
00475
00476
00477
00478
00479 void deleteTileUvs();
00480 void recreateTileUvs();
00481
00482 void refreshTesselationGeometry();
00483
00484
00485
00486 void serial(NLMISC::IStream &f);
00487
00488
00489 void unpack(CBezierPatch &p) const;
00490
00492
00502 void unpackShadowMap (uint8 *pShadow);
00503
00512 void packShadowMap (const uint8 *pLumel);
00513
00519 void resetCompressedLumels ();
00520
00529 void setupColorsFromTileFlags(const NLMISC::CRGBA colors[4]);
00530
00534 void copyTileFlagsFromPatch(const CPatch *src);
00535
00536 private:
00537
00538
00539
00545 void packLumelBlock (uint8 *dest, const uint8 *source, uint8 alpha0, uint8 alpha1);
00546
00552 uint evalLumelBlock (const uint8 *original, const uint8 *unCompressed, uint width, uint height);
00553
00559 void unpackLumelBlock (uint8 *dest, const uint8 *src);
00560
00561 public:
00562
00564
00568 void setSmoothFlag (uint edge, bool flag)
00569 {
00570
00571 Flags&=~(1<<(edge+NL_PATCH_SMOOTH_FLAG_SHIFT));
00572
00573
00574 Flags|=(((uint)flag)<<(edge+NL_PATCH_SMOOTH_FLAG_SHIFT));
00575 }
00576
00580 bool getSmoothFlag (uint edge) const
00581 {
00582
00583 return ((Flags&(1<<(edge+NL_PATCH_SMOOTH_FLAG_SHIFT)))!=0);
00584 }
00585
00586
00588
00596 void addTrianglesInBBox(CPatchIdent paId, const CAABBox &bbox, std::vector<CTrianglePatch> &triangles, uint8 tileTessLevel) const;
00597
00601 void fillPatchQuadBlock(CPatchQuadBlock &quadBlock) const;
00602
00609 void addPatchBlocksInBBox(CPatchIdent paId, const CAABBox &bbox, std::vector<CPatchBlockIdent> &paBlockIds) const;
00610
00611
00614 CVector getTesselatedPos(CUV uv) const;
00615
00616
00619 void appendTessellationLeaves(std::vector<const CTessFace*> &leaves) const;
00620
00621
00622
00623
00624
00626
00627
00629 uint8 getLumel(const CUV &uv) const;
00630
00632 void appendTileLightInfluences(const CUV &uv,
00633 std::vector<CPointLightInfluence> &pointLightList) const;
00634
00638 void computeCurrentTLILightmap(NLMISC::CRGBA *array) const;
00639
00640
00641
00642
00644
00645
00647 CTileElement *getTileElement(const CUV &uv);
00648
00649
00650
00651 public:
00652
00653
00654 bool isClipped() const {return Clipped;}
00655
00656 bool isRenderClipped() const {return RenderClipped;}
00657
00658
00659
00660 const CTessVertex *getCornerVertex(uint corner)
00661 {
00662 return BaseVertices[corner];
00663 }
00664
00665
00666 public:
00667
00669
00670
00671
00672
00673 void deleteVBAndFaceVector();
00674
00675
00676
00677 void allocateVBAndFaceVector();
00678
00679
00680
00681 void fillVB();
00682
00683
00684 void fillVBIfVisible();
00685
00686
00687
00688 void deleteVBAndFaceVectorFar1Only();
00689
00690
00691
00692 void allocateVBAndFaceVectorFar1Only();
00693
00694
00695
00696 void fillVBFar0Only();
00697
00698 void fillVBFar1Only();
00699
00700
00701
00702
00703 void fillVBFarsDLMUvOnly();
00704 void fillFar0DLMUvOnlyVertexListVB(CTessList<CTessFarVertex> &vertList);
00705 void fillFar1DLMUvOnlyVertexListVB(CTessList<CTessFarVertex> &vertList);
00706
00707
00708
00709 void updateClipPatchVB();
00710
00711
00712
00713 void debugAllocationMarkIndices(uint marker);
00714
00715
00716
00717
00718 void recreateTessBlockFaceVector(CTessBlock &block);
00719
00720
00721
00722
00723
00724 public:
00725
00727
00728
00730 void deleteAllVegetableIgs();
00731
00733 void recreateAllVegetableIgs();
00734
00735
00736
00737
00739
00743 void resetTileLightInfluences();
00744
00745
00746
00748
00749
00751 void linkBeforeNearUL(CPatch *patchNext);
00753 void unlinkNearUL();
00755 CPatch *getNextNearUL() const {return _ULNearNext;}
00756
00758 uint getNumNearTessBlocks() const {return TessBlocks.size();}
00759
00766 uint updateTessBlockLighting(uint numTb);
00767
00768
00769
00770
00772
00773
00778 void beginDLMLighting();
00782 void processDLMLight(CPatchDLMPointLight &pl);
00787 void endDLMLighting();
00788
00789
00790
00791
00793 uint getTileMaterialRefCount() const {return MasterBlock.TileMaterialRefCount;}
00794
00795
00796 private:
00797
00798
00799 friend class CTessFace;
00800 friend class CZone;
00801 friend class CLandscapeVegetableBlock;
00802
00803 CZone *Zone;
00804
00805
00806 uint16 PatchId;
00807
00808 uint8 OrderS, OrderT;
00809
00810
00811 bool ExcludeFromRefineAll;
00812
00813
00814 sint TessBlockLimitLevel;
00815
00816 sint TileLimitLevel;
00817
00818 sint SquareLimitLevel;
00819
00820 float ErrorSize;
00821
00822 CTessFace *Son0, *Son1;
00823
00824 CTessVertex *BaseVertices[4];
00825
00826 CTessFarVertex BaseFarVertices[4];
00827
00828 CBSphere BSphere;
00829
00830
00831
00832
00833 sint Far0;
00834 sint Far1;
00835 float Far0UScale, Far0VScale, Far0UBias, Far0VBias;
00836 float Far1UScale, Far1VScale, Far1UBias, Far1VBias;
00837
00838
00839
00850 uint8 Flags;
00851
00852
00853 bool Clipped;
00854
00855 bool RenderClipped;
00856
00857 bool OldRenderClipped;
00858
00859
00860
00861
00862 CRdrPatchId Pass0, Pass1;
00863
00864 float TransitionSqrMin;
00865 float OOTransitionSqrDelta;
00866
00868
00869
00870 CTessBlock MasterBlock;
00871
00872
00873 std::vector<CTessBlock> TessBlocks;
00874
00875 sint TessBlockRefCount;
00876
00877 sint NumRenderableFaces;
00878
00879
00880
00882
00884
00885
00886
00887
00891 static uint32 _Version;
00892
00893 private:
00894
00895 void computeDefaultErrorSize();
00896
00897 void makeRoots();
00898
00899 CTessFace *getRootFaceForEdge(sint edge) const;
00900
00901 CTessVertex *getRootVertexForEdge(sint edge) const;
00902 void changeEdgeNeighbor(sint edge, CTessFace *to);
00903
00904
00906
00907
00908
00909 void resetMasterBlock();
00910
00911 void clearTessBlocks();
00912
00913 void addRefTessBlocks();
00914
00915 void decRefTessBlocks();
00916
00917
00918
00919
00920 uint getNumTessBlock(CTessFace *face);
00921
00922 enum TFarVertType {FVMasterBlock=0, FVTessBlock, FVTessBlockEdge};
00923
00924 void getNumTessBlock(CParamCoord pc, TFarVertType &type, uint &numtb);
00925
00926
00927
00928 void dirtTessBlockFaceVector(CTessBlock &block);
00929
00930
00931
00932
00933 void appendFaceToRenderList(CTessFace *face);
00934
00935
00936 void removeFaceFromRenderList(CTessFace *face);
00937
00938 void appendFaceToTileRenderList(CTessFace *face);
00939 void removeFaceFromTileRenderList(CTessFace *face);
00940
00941 void extendTessBlockWithEndPos(CTessFace *face);
00942
00943
00944
00945 void appendTileMaterialToRenderList(CTileMaterial *tm);
00946 void removeTileMaterialFromRenderList(CTileMaterial *tm);
00947
00948
00949 void appendFarVertexToRenderList(CTessFarVertex *fv);
00950 void removeFarVertexFromRenderList(CTessFarVertex *fv);
00951
00952 void appendNearVertexToRenderList(CTileMaterial *tileMat, CTessNearVertex *nv);
00953 void removeNearVertexFromRenderList(CTileMaterial *tileMat, CTessNearVertex *nv);
00954
00955
00956
00957
00958
00960
00961
00962
00963 CPatchRdrPass *getTileRenderPass(sint tileId, sint pass);
00964
00965
00966 void getTileUvInfo(sint tileId, sint pass, bool alpha, uint8 &orient, CVector &uvScaleBias, bool &is256x256, uint8 &uvOff);
00967
00968
00969
00970
00971
00972 void getTileLightMap(uint ts, uint tt, CPatchRdrPass *&rdrpass);
00973
00974 void getTileLightMapUvInfo(uint ts, uint tt, CVector &uvScaleBias);
00975
00976 void releaseTileLightMap(uint ts, uint tt);
00977
00978
00979 void computeNearBlockLightmap(uint ts, uint tt, NLMISC::CRGBA *lightText);
00980 void computeTileLightmapPixelAroundCorner(const NLMISC::CVector2f &stIn, NLMISC::CRGBA *dest, bool lookAround);
00981
00982
00983 void computeTileLightmap(uint ts, uint tt, NLMISC::CRGBA *dest, uint stride);
00984
00985
00986 void computeTileLightmapEdge(uint ts, uint tt, uint edge, NLMISC::CRGBA *dest, uint stride, bool inverse);
00987
00988 void computeTileLightmapPixel(uint ts, uint tt, uint s, uint t, NLMISC::CRGBA *dest);
00989
00990
00991
00992 void computeTileLightmapAutomatic(uint ts, uint tt, NLMISC::CRGBA *dest, uint stride);
00993 void computeTileLightmapEdgeAutomatic(uint ts, uint tt, uint edge, NLMISC::CRGBA *dest, uint stride, bool inverse);
00994 void computeTileLightmapPixelAutomatic(uint ts, uint tt, uint s, uint t, NLMISC::CRGBA *dest);
00995
00996 void computeTileLightmapPrecomputed(uint ts, uint tt, NLMISC::CRGBA *dest, uint stride);
00997 void computeTileLightmapEdgePrecomputed(uint ts, uint tt, uint edge, NLMISC::CRGBA *dest, uint stride, bool inverse);
00998 void computeTileLightmapPixelPrecomputed(uint ts, uint tt, uint s, uint t, NLMISC::CRGBA *dest);
00999
01000 void modulateTileLightmapWithTileColors(uint ts, uint tt, NLMISC::CRGBA *dest, uint stride);
01001 void modulateTileLightmapEdgeWithTileColors(uint ts, uint tt, uint edge, NLMISC::CRGBA *dest, uint stride, bool inverse);
01002 void modulateTileLightmapPixelWithTileColors(uint ts, uint tt, uint s, uint t, NLMISC::CRGBA *dest);
01003
01004 void getTileTileColors(uint ts, uint tt, NLMISC::CRGBA corners[4]);
01005
01006
01007
01008
01009 CRGBA CPatch::getCurrentTLIColor(uint x, uint y) const;
01010
01011
01012 void getCurrentTileTLIColors(uint ts, uint tt, NLMISC::CRGBA corners[4]);
01013
01014 void addTileLightmapWithTLI(uint ts, uint tt, NLMISC::CRGBA *dest, uint stride);
01015 void addTileLightmapEdgeWithTLI(uint ts, uint tt, uint edge, NLMISC::CRGBA *dest, uint stride, bool inverse);
01016 void addTileLightmapPixelWithTLI(uint ts, uint tt, uint s, uint t, NLMISC::CRGBA *dest);
01017
01018
01019
01020
01021
01022 void computeNewFar(sint &newFar0, sint &newFar1);
01023
01024
01025
01026 void fillFar0VertexVB(CTessFarVertex *pVert);
01027 void fillFar1VertexVB(CTessFarVertex *pVert);
01028 void fillTileVertexVB(CTessNearVertex *pVert);
01029 void fillFar0VertexListVB(CTessList<CTessFarVertex> &vertList);
01030 void fillFar1VertexListVB(CTessList<CTessFarVertex> &vertList);
01031 void fillTileVertexListVB(CTessList<CTessNearVertex> &vertList);
01032
01033 void updateFar0VBAlloc(CTessList<CTessFarVertex> &vertList, bool alloc);
01034 void updateFar1VBAlloc(CTessList<CTessFarVertex> &vertList, bool alloc);
01035 void updateTileVBAlloc(CTessList<CTessNearVertex> &vertList, bool alloc);
01036 void updateVBAlloc(bool alloc);
01037
01038 void debugAllocationMarkIndicesFarList(CTessList<CTessFarVertex> &vertList, uint marker);
01039 void debugAllocationMarkIndicesNearList(CTessList<CTessNearVertex> &vertList, uint marker);
01040
01041 void createFaceVectorFar1();
01042 void deleteFaceVectorFar1();
01043 void createFaceVectorFar0OrTile();
01044 void deleteFaceVectorFar0OrTile();
01045
01046
01047
01048
01049 void checkCreateVertexVBFar(CTessFarVertex *pVert);
01050 void checkCreateVertexVBNear(CTessNearVertex *pVert);
01051
01052 void checkFillVertexVBFar(CTessFarVertex *pVert);
01053 void checkFillVertexVBNear(CTessNearVertex *pVert);
01054
01055 void checkDeleteVertexVBFar(CTessFarVertex *pVert);
01056 void checkDeleteVertexVBNear(CTessNearVertex *pVert);
01057
01058
01059 void computeGeomorphVertexList(CTessList<CTessFarVertex> &vertList);
01060 void computeGeomorphFar0VertexListVB(CTessList<CTessFarVertex> &vertList);
01061 void computeGeomorphAlphaFar1VertexListVB(CTessList<CTessFarVertex> &vertList);
01062 void computeGeomorphTileVertexListVB(CTessList<CTessNearVertex> &vertList);
01063
01065
01067
01073 void addTrianglesInBBoxRecurs(CPatchIdent paId, const CAABBox &bbox, std::vector<CTrianglePatch> &triangles, uint8 tessLevel,
01074 const CBezierPatch &pa, uint8 s0, uint8 s1, uint8 t0, uint8 t1) const;
01079 void addTileTrianglesInBBox(CPatchIdent paId, const CAABBox &bbox, std::vector<CTrianglePatch> &triangles, uint8 tessLevel,
01080 uint8 s0, uint8 t0) const;
01081
01084 void addPatchBlocksInBBoxRecurs(CPatchIdent paId, const CAABBox &bbox, std::vector<CPatchBlockIdent> &paBlockIds,
01085 const CBezierPatch &pa, uint8 s0, uint8 s1, uint8 t0, uint8 t1) const;
01086
01088 CVector computeVertexButCorner(float s, float t, bool &onCorner) const;
01089
01090
01091
01092
01093 private:
01094
01095
01096
01098
01099
01101 CZone *_BindZoneNeighbor[4];
01102
01106 CTessFace *linkTessFaceWithEdge(const NLMISC::CVector2f &uv0, const NLMISC::CVector2f &uv1, CTessFace *linkTo);
01107
01108
01109
01110
01111
01113
01114
01115
01116 float computeDisplaceRawInteger(sint ts, sint tt, sint ms, sint mt) const;
01117 void computeDisplaceRawCoordinates(float sTile, float tTile, float s, float t,
01118 sint &ts, sint &tt, sint &ms, sint &mt) const;
01124 float computeDisplaceRaw(float sTile, float tTile, float s, float t) const;
01128 float computeDisplaceRawOnNeighbor(float sTile, float tTile, float s, float t) const;
01129
01130
01133 float computeDisplaceInteriorSmooth(float s, float t) const;
01136 float computeDisplaceEdgeSmooth(float s, float t, sint8 smoothBorderX, sint8 smoothBorderY) const;
01139 float computeDisplaceCornerSmooth(float s, float t, sint8 smoothBorderX, sint8 smoothBorderY) const;
01140
01141
01144 CVector computeNormalEdgeSmooth(float s, float t, sint8 smoothBorderX, sint8 smoothBorderY) const;
01147 CVector computeNormalCornerSmooth(float s, float t, sint8 smoothBorderX, sint8 smoothBorderY) const;
01150 CVector computeNormalOnNeighbor(float s, float t, uint edgeExclude) const;
01151
01152
01156 void computeNoise(float s, float t, CVector &displace) const;
01157
01158
01159
01160
01161
01162 void computeTbTm(uint &numtb, uint &numtm, uint ts, uint tt);
01163
01164
01166
01167
01169 void createVegetableBlock(uint numTb, uint ts, uint tt);
01171 void releaseVegetableBlock(uint numTb);
01172
01173
01174
01175
01176
01177
01178 void generateTileVegetable(CVegetableInstanceGroup *vegetIg, uint distType, uint ts, uint tt,
01179 CLandscapeVegetableBlockCreateContext &vbCreateCtx);
01180
01181
01182 void getTileLumelmapPrecomputed(uint ts, uint tt, uint8 *dest, uint stride);
01186 void getTileLumelmapPixelPrecomputed(uint ts, uint tt, uint s, uint t, uint8 &dest) const;
01187
01188
01189
01190
01192
01193 CPatch *_ULNearPrec;
01194 CPatch *_ULNearNext;
01195
01196
01197
01199
01200
01205 CPatchDLMContext *_DLMContext;
01206
01210 sint _DLMContextRefCount;
01211
01213 void addRefDLMContext();
01215 void decRefDLMContext(uint count= 1);
01216
01217
01218
01219
01220 private:
01221
01222
01223
01224 static CBezierPatch CachePatch;
01225
01226 static const CPatch *LastPatch;
01227
01228 public:
01229
01230 CBezierPatch *unpackIntoCache() const;
01231
01232 };
01233
01234
01235 }
01236
01237
01238 #endif // NL_PATCH_H
01239
01240