00001
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef NL_PATCH_H
00025 #define NL_PATCH_H
00026
00027 #include "nel/misc/types_nl.h"
00028 #include "nel/misc/vector.h"
00029 #include "nel/misc/vector_2f.h"
00030 #include "nel/misc/rgba.h"
00031 #include "nel/3d/tessellation.h"
00032 #include "nel/misc/aabbox.h"
00033 #include "nel/misc/bsphere.h"
00034 #include "nel/misc/triangle.h"
00035 #include "nel/misc/geom_ext.h"
00036 #include "nel/misc/object_vector.h"
00037 #include "nel/3d/tile_element.h"
00038 #include "nel/3d/tile_color.h"
00039 #include "nel/3d/tess_block.h"
00040 #include "nel/3d/tile_light_influence.h"
00041 #include "nel/3d/point_light_influence.h"
00042
00043
00044 namespace NL3D {
00045
00046 #define NL_MAX_TILES_BY_PATCH_EDGE_SHIFT 4 // max 16x16 tiles by patch (shift version)
00047 #define NL_MAX_TILES_BY_PATCH_EDGE (1<<NL_MAX_TILES_BY_PATCH_EDGE_SHIFT) // max 16x16 tiles by patch
00048 #define NL_PATCH_FAR0_ROTATED 0x1 // Flags far0 rotated
00049 #define NL_PATCH_FAR1_ROTATED 0x2 // Flags far1 rotated
00050 #define NL_PATCH_SMOOTH_FLAG_SHIFT 0x2 // Smooth flags shift
00051 #define NL_PATCH_SMOOTH_FLAG_MASK 0x3c // Smooth flags mask
00052
00053 #define NL_LUMEL_BY_TILE_SHIFT 2 // 4 lumels by tile
00054 #define NL_LUMEL_BY_TILE (1<<NL_LUMEL_BY_TILE_SHIFT) // 4 lumels by tile
00055 #define NL_BLOCK_LUMEL_COMPRESSED_SIZE 8 // Compressed block size 8 bytes
00056
00057
00058 #define NL_PATCH_BLOCK_MAX_QUAD 4 // Max quad per CPatchQuadBlock.
00059 #define NL_PATCH_BLOCK_MAX_VERTEX (NL_PATCH_BLOCK_MAX_QUAD+1) // Max vertex per CPatchQuadBlock.
00060
00061
00062 using NLMISC::CVector;
00063 using NLMISC::CPlane;
00064 using NLMISC::CAABBox;
00065 using NLMISC::CBSphere;
00066 using NLMISC::CRGBA;
00067
00068
00069 class CLandscape;
00070 class CZone;
00071 class CBezierPatch;
00072 class ITexture;
00073 class CVegetableClipBlock;
00074 class CVegetableManager;
00075 class CVegetableInstanceGroup;
00076 class CLandscapeVegetableBlock;
00077 class CLandscapeVegetableBlockCreateContext;
00078 class CPatchDLMContext;
00079 class CPatchDLMPointLight;
00080
00081
00082
00083 #define NL3D_NOISE_MAX 1
00084
00085
00086
00087
00088
00089
00090
00091 #define NL3D_PATCH_VEGETABLE_NUM_TESSBLOCK_PER_CLIPBLOCK_SHIFT 1
00092 #define NL3D_PATCH_VEGETABLE_NUM_TESSBLOCK_PER_CLIPBLOCK (1<<NL3D_PATCH_VEGETABLE_NUM_TESSBLOCK_PER_CLIPBLOCK_SHIFT)
00093
00094
00095
00096 class CVector3s
00097 {
00098 public:
00099 sint16 x,y,z;
00100
00101 public:
00102 void pack(const CVector &v, const CVector &bias, float scale)
00103 {
00104 float xr,yr,zr;
00105 xr= (v.x - bias.x)/scale;
00106 yr= (v.y - bias.y)/scale;
00107 zr= (v.z - bias.z)/scale;
00108 NLMISC::clamp(xr, -32768, 32767);
00109 NLMISC::clamp(yr, -32768, 32767);
00110 NLMISC::clamp(zr, -32768, 32767);
00111 x= (sint16)xr;
00112 y= (sint16)yr;
00113 z= (sint16)zr;
00114 }
00115 void unpack(CVector &v, const CVector &bias, float scale) const
00116 {
00117 v.x= x*scale + bias.x;
00118 v.y= y*scale + bias.y;
00119 v.z= z*scale + bias.z;
00120 }
00121 void serial(NLMISC::IStream &f)
00122 {
00123 f.serial(x,y,z);
00124 }
00125 };
00126
00127
00128
00136 struct CPatchIdent
00137 {
00138 sint32 ZoneId;
00139 uint16 PatchId;
00140
00141
00142 CPatchIdent() {}
00143
00144 CPatchIdent(sint32 zoneId, uint16 patchId) : ZoneId(zoneId), PatchId(patchId) {}
00145 public:
00146 bool operator<(const CPatchIdent &p) const
00147 {
00148 if(ZoneId!=p.ZoneId) return ZoneId<p.ZoneId;
00149 return PatchId<p.PatchId;
00150 }
00151
00152 bool operator==(const CPatchIdent &p) const
00153 {
00154 return ZoneId==p.ZoneId && PatchId==p.PatchId;
00155 }
00156 bool operator!=(const CPatchIdent &p) const
00157 {
00158 return !(*this==p);
00159 }
00160
00161 };
00162
00163
00164
00172 struct CTrianglePatch : public NLMISC::CTriangleUV
00173 {
00175 CPatchIdent PatchId;
00176 };
00177
00178
00179
00187 class CPatchBlockIdent
00188 {
00189 public:
00191 CPatchIdent PatchId;
00193 uint8 OrderS,OrderT;
00195 uint8 S0,S1,T0,T1;
00196
00197 public:
00199
00200 bool operator==(const CPatchBlockIdent &pb) const
00201 {
00202 return PatchId==pb.PatchId &&
00203 S0==pb.S0 && S1==pb.S1 &&
00204 T0==pb.T0 && T1==pb.T1;
00205 }
00206 bool operator!=(const CPatchBlockIdent &pb) const
00207 {
00208 return !(*this==pb);
00209 }
00210
00211 bool operator<(const CPatchBlockIdent &pb) const
00212 {
00213 if(PatchId!=pb.PatchId)
00214 return PatchId<pb.PatchId;
00215 if(S0!=pb.S0) return S0<pb.S0;
00216 if(S1!=pb.S1) return S1<pb.S1;
00217 if(T0!=pb.T0) return T0<pb.T0;
00218 return T1<pb.T1;
00219 }
00220 bool operator<=(const CPatchBlockIdent &pb) const
00221 {
00222 return (*this<pb) || (*this==pb);
00223 }
00224 bool operator>(const CPatchBlockIdent &pb) const
00225 {
00226 return !(*this<=pb);
00227 }
00228 bool operator>=(const CPatchBlockIdent &pb) const
00229 {
00230 return !(*this<pb);
00231 }
00232
00233
00234 };
00235
00236
00237
00245 class CPatchQuadBlock
00246 {
00247 public:
00249 CPatchBlockIdent PatchBlockId;
00250
00252 CVector Vertices[NL_PATCH_BLOCK_MAX_VERTEX*NL_PATCH_BLOCK_MAX_VERTEX];
00253
00254 public:
00255
00259 void buildTileTriangles(uint8 quadId, CTrianglePatch triangles[2]) const;
00260 };
00261
00262
00263
00264
00296 class CPatch
00297 {
00298 public:
00299
00300 struct CBindInfo
00301 {
00302
00303 CZone *Zone;
00304
00305
00306 sint NPatchs;
00307
00308
00309
00310 uint8 MultipleBindNum;
00311
00312 uint8 MultipleBindId;
00313
00314
00315 CPatch *Next[4];
00316 sint Edge[4];
00317 };
00318
00319 public:
00321 CVector3s Vertices[4];
00322 CVector3s Tangents[8];
00323 CVector3s Interiors[4];
00324
00325
00326 std::vector<uint8> CompressedLumels;
00327
00328
00329 std::vector<CTileElement> Tiles;
00330
00331
00332 std::vector<CTileColor> TileColors;
00333
00334
00335 std::vector<CTileLightInfluence> TileLightInfluences;
00336
00337
00339
00341 uint8 NoiseRotation;
00342
00346 void setCornerSmoothFlag(uint corner, bool smooth);
00347 bool getCornerSmoothFlag(uint corner) const;
00348
00349 private:
00351 uint8 _CornerSmoothFlag;
00352
00353 public:
00354
00355
00356
00357 public:
00358
00360 CPatch();
00362 ~CPatch();
00363
00373 void compile(CZone *z, uint patchId, uint8 orderS, uint8 orderT, CTessVertex *baseVertices[4], float errorSize=0);
00375 void release();
00376
00377
00379 CLandscape *getLandscape () const;
00380 CZone *getZone() const {return Zone;}
00381 uint8 getOrderS() const {return OrderS;}
00382 uint8 getOrderT() const {return OrderT;}
00383 uint8 getOrderForEdge(sint8 edge) const;
00384 float getErrorSize() const {return ErrorSize;}
00385 sint getFar0() const {return Far0;}
00386 sint getFar1() const {return Far1;}
00387 uint16 getPatchId () const {return PatchId;}
00389 void getBindNeighbor(uint edge, CBindInfo &neighborEdge) const;
00390
00392 CAABBox buildBBox() const;
00393
00401 CVector computeVertex(float s, float t) const;
00402
00403
00411 CVector computeContinousVertex(float s, float t) const;
00412
00413
00416 void unbind();
00417
00422 void bind(CBindInfo Edges[4], bool rebind);
00423
00425 void forceMergeAtTileLevel();
00426
00429 void averageTesselationVertices();
00430
00432 void refineAll();
00433
00434
00436
00437
00439 void preRender(const NLMISC::CBSphere &patchSphere);
00440
00441 void updateTextureFarOnly(const NLMISC::CBSphere &patchSphere);
00443
00444 void renderFar0();
00445 void renderFar1();
00446
00447
00448 void computeSoftwareGeomorphAndAlpha();
00449
00450
00451 void updateClipPatchVB(bool renderClipped);
00452
00453
00454 CPatch *getNextFar0ToRdr() const {return _NextRdrFar0;}
00455
00456 CPatch *getNextFar1ToRdr() const {return _NextRdrFar1;}
00457
00459
00460
00461
00462 void resetRenderFar();
00463
00464
00465
00466
00467 void deleteTileUvs();
00468 void recreateTileUvs();
00469
00470 void refreshTesselationGeometry();
00471
00472
00473
00474 void serial(NLMISC::IStream &f);
00475
00476
00477 void unpack(CBezierPatch &p) const;
00478
00480
00490 void unpackShadowMap (uint8 *pShadow);
00491
00500 void packShadowMap (const uint8 *pLumel);
00501
00507 void resetCompressedLumels ();
00508
00517 void setupColorsFromTileFlags(const NLMISC::CRGBA colors[4]);
00518
00522 void copyTileFlagsFromPatch(const CPatch *src);
00523
00524
00525 uint32 countNumTriFar0() const;
00526 uint32 countNumTriFar1() const;
00527
00528 private:
00529
00530
00531
00537 void packLumelBlock (uint8 *dest, const uint8 *source, uint8 alpha0, uint8 alpha1);
00538
00544 uint evalLumelBlock (const uint8 *original, const uint8 *unCompressed, uint width, uint height);
00545
00551 void unpackLumelBlock (uint8 *dest, const uint8 *src);
00552
00553 public:
00554
00556
00560 void setSmoothFlag (uint edge, bool flag)
00561 {
00562
00563 Flags&=~(1<<(edge+NL_PATCH_SMOOTH_FLAG_SHIFT));
00564
00565
00566 Flags|=(((uint)flag)<<(edge+NL_PATCH_SMOOTH_FLAG_SHIFT));
00567 }
00568
00572 bool getSmoothFlag (uint edge) const
00573 {
00574
00575 return ((Flags&(1<<(edge+NL_PATCH_SMOOTH_FLAG_SHIFT)))!=0);
00576 }
00577
00578
00580
00588 void addTrianglesInBBox(CPatchIdent paId, const CAABBox &bbox, std::vector<CTrianglePatch> &triangles, uint8 tileTessLevel) const;
00589
00593 void fillPatchQuadBlock(CPatchQuadBlock &quadBlock) const;
00594
00601 void addPatchBlocksInBBox(CPatchIdent paId, const CAABBox &bbox, std::vector<CPatchBlockIdent> &paBlockIds) const;
00602
00603
00606 CVector getTesselatedPos(CUV uv) const;
00607
00608
00611 void appendTessellationLeaves(std::vector<const CTessFace*> &leaves) const;
00612
00613
00614
00615
00616
00618
00619
00621 uint8 getLumel(const CUV &uv) const;
00622
00626 void appendTileLightInfluences(const CUV &uv,
00627 std::vector<CPointLightInfluence> &pointLightList) const;
00628
00632 void computeCurrentTLILightmapDiv2(NLMISC::CRGBA *array) const;
00633
00634
00635
00636
00638
00639
00641 CTileElement *getTileElement(const CUV &uv);
00642
00643
00644
00645 public:
00646
00647
00648 bool isRenderClipped() const;
00649
00650
00651
00652 const CTessVertex *getCornerVertex(uint corner)
00653 {
00654 return BaseVertices[corner];
00655 }
00656
00657
00658 public:
00659
00661
00662
00663
00664
00665 void deleteVBAndFaceVector();
00666
00667
00668
00669 void allocateVBAndFaceVector();
00670
00671
00672
00673 void fillVB();
00674
00675
00676 void fillVBIfVisible();
00677
00678
00679
00680 void deleteVBAndFaceVectorFar1Only();
00681
00682
00683
00684 void allocateVBAndFaceVectorFar1Only();
00685
00686
00687
00688 void fillVBFar0Only();
00689
00690 void fillVBFar1Only();
00691
00692
00693
00694
00695 void fillVBFarsDLMUvOnly();
00696 void fillFar0DLMUvOnlyVertexListVB(CTessList<CTessFarVertex> &vertList);
00697 void fillFar1DLMUvOnlyVertexListVB(CTessList<CTessFarVertex> &vertList);
00698
00699
00700
00701 void debugAllocationMarkIndices(uint marker);
00702
00703
00704
00705
00706 void recreateTessBlockFaceVector(CTessBlock &block);
00707
00708
00709
00710
00711
00712 public:
00713
00715
00716
00718 void deleteAllVegetableIgs();
00719
00721 void recreateAllVegetableIgs();
00722
00723
00724
00725
00727
00731 void resetTileLightInfluences();
00732
00733
00734
00736
00737
00739 void linkBeforeNearUL(CPatch *patchNext);
00741 void unlinkNearUL();
00743 CPatch *getNextNearUL() const {return _ULNearNext;}
00744
00746 uint getNumNearTessBlocks() const {return TessBlocks.size();}
00747
00754 uint updateTessBlockLighting(uint numTb);
00755
00756
00757
00758
00760
00761
00766 void beginDLMLighting();
00770 void processDLMLight(CPatchDLMPointLight &pl);
00775 void endDLMLighting();
00776
00777
00778
00779
00781 uint getTileMaterialRefCount() const {return MasterBlock.TileMaterialRefCount;}
00782
00783
00784 private:
00785
00786
00787 friend class CTessFace;
00788 friend class CZone;
00789 friend class CLandscapeVegetableBlock;
00790 friend class CPatchRdrPass;
00791
00792 CZone *Zone;
00793
00794
00795 uint16 PatchId;
00796
00797 uint8 OrderS, OrderT;
00798
00799
00800 bool ExcludeFromRefineAll;
00801
00802
00803 sint TessBlockLimitLevel;
00804
00805 sint TileLimitLevel;
00806
00807 sint SquareLimitLevel;
00808
00809 float ErrorSize;
00810
00811 CTessFace *Son0, *Son1;
00812
00813 CTessVertex *BaseVertices[4];
00814
00815 CTessFarVertex BaseFarVertices[4];
00816
00817
00818
00819
00820 float Far0UScale, Far0VScale, Far0UBias, Far0VBias;
00821 float Far1UScale, Far1VScale, Far1UBias, Far1VBias;
00822
00833 uint8 Flags;
00834
00835
00836
00837 float TransitionSqrMin;
00838 float OOTransitionSqrDelta;
00839
00840
00841
00842
00843
00844
00845
00846
00847
00848
00849
00850
00851
00852
00853
00854
00855
00856
00857
00858
00859
00860 sint Far0;
00861 sint Far1;
00862
00863
00864 CPatchRdrPass *_PatchRdrPassFar0;
00865 CPatch *_NextRdrFar0;
00866 CPatchRdrPass *_PatchRdrPassFar1;
00867 CPatch *_NextRdrFar1;
00868
00870
00871
00872 sint NumRenderableFaces;
00873
00874
00875 NLMISC::CObjectVector<CTessBlock> TessBlocks;
00876
00877 public:
00878 CTessBlock MasterBlock;
00879 private:
00880
00881 sint TessBlockRefCount;
00882
00883
00884
00886
00888 std::vector<CVegetableClipBlock*> VegetableClipBlocks;
00889
00890
00891
00895 static uint32 _Version;
00896
00897 private:
00898
00899 void computeDefaultErrorSize();
00900
00901 void makeRoots();
00902
00903 CTessFace *getRootFaceForEdge(sint edge) const;
00904
00905 CTessVertex *getRootVertexForEdge(sint edge) const;
00906 void changeEdgeNeighbor(sint edge, CTessFace *to);
00907
00908
00910
00911
00912
00913 void resetMasterBlock();
00914
00915 void clearTessBlocks();
00916
00917 void addRefTessBlocks();
00918
00919 void decRefTessBlocks();
00920
00921
00922
00923
00924 uint getNumTessBlock(CTessFace *face);
00925
00926 enum TFarVertType {FVMasterBlock=0, FVTessBlock, FVTessBlockEdge};
00927
00928 void getNumTessBlock(CParamCoord pc, TFarVertType &type, uint &numtb);
00929
00930
00931
00932 void dirtTessBlockFaceVector(CTessBlock &block);
00933
00934
00935
00936
00937 void appendFaceToRenderList(CTessFace *face);
00938
00939
00940 void removeFaceFromRenderList(CTessFace *face);
00941
00942 void appendFaceToTileRenderList(CTessFace *face);
00943 void removeFaceFromTileRenderList(CTessFace *face);
00944
00945 void extendTessBlockWithEndPos(CTessFace *face);
00946
00947
00948
00949 void appendTileMaterialToRenderList(CTileMaterial *tm);
00950 void removeTileMaterialFromRenderList(CTileMaterial *tm);
00951
00952
00953 void appendFarVertexToRenderList(CTessFarVertex *fv);
00954 void removeFarVertexFromRenderList(CTessFarVertex *fv);
00955
00956 void appendNearVertexToRenderList(CTileMaterial *tileMat, CTessNearVertex *nv);
00957 void removeNearVertexFromRenderList(CTileMaterial *tileMat, CTessNearVertex *nv);
00958
00959
00960
00961
00962
00964
00965
00966
00967 CPatchRdrPass *getTileRenderPass(sint tileId, sint pass);
00968
00969
00970 void getTileUvInfo(sint tileId, sint pass, bool alpha, uint8 &orient, CVector &uvScaleBias, bool &is256x256, uint8 &uvOff);
00971
00972
00973
00974
00975
00976 void getTileLightMap(uint ts, uint tt, CPatchRdrPass *&rdrpass);
00977
00978 void getTileLightMapUvInfo(uint ts, uint tt, CVector &uvScaleBias);
00979
00980 void releaseTileLightMap(uint ts, uint tt);
00981
00982
00983 void computeNearBlockLightmap(uint ts, uint tt, NLMISC::CRGBA *lightText);
00984 void computeTileLightmapPixelAroundCorner(const NLMISC::CVector2f &stIn, NLMISC::CRGBA *dest, bool lookAround);
00985
00986
00987 void computeTileLightmap(uint ts, uint tt, NLMISC::CRGBA *dest, uint stride);
00988
00989
00990 void computeTileLightmapEdge(uint ts, uint tt, uint edge, NLMISC::CRGBA *dest, uint stride, bool inverse);
00991
00992 void computeTileLightmapPixel(uint ts, uint tt, uint s, uint t, NLMISC::CRGBA *dest);
00993
00994
00995
00996 void computeTileLightmapAutomatic(uint ts, uint tt, NLMISC::CRGBA *dest, uint stride);
00997 void computeTileLightmapEdgeAutomatic(uint ts, uint tt, uint edge, NLMISC::CRGBA *dest, uint stride, bool inverse);
00998 void computeTileLightmapPixelAutomatic(uint ts, uint tt, uint s, uint t, NLMISC::CRGBA *dest);
00999
01000 void computeTileLightmapPrecomputed(uint ts, uint tt, NLMISC::CRGBA *dest, uint stride);
01001 void computeTileLightmapEdgePrecomputed(uint ts, uint tt, uint edge, NLMISC::CRGBA *dest, uint stride, bool inverse);
01002 void computeTileLightmapPixelPrecomputed(uint ts, uint tt, uint s, uint t, NLMISC::CRGBA *dest);
01003
01004 void modulateTileLightmapWithTileColors(uint ts, uint tt, NLMISC::CRGBA *dest, uint stride);
01005 void modulateTileLightmapEdgeWithTileColors(uint ts, uint tt, uint edge, NLMISC::CRGBA *dest, uint stride, bool inverse);
01006 void modulateTileLightmapPixelWithTileColors(uint ts, uint tt, uint s, uint t, NLMISC::CRGBA *dest);
01007
01008 void getTileTileColors(uint ts, uint tt, NLMISC::CRGBA corners[4]);
01009
01010
01011
01012
01013 CRGBA getCurrentTLIColor(uint x, uint y) const;
01014
01015
01016 void getCurrentTileTLIColors(uint ts, uint tt, NLMISC::CRGBA corners[4]);
01017
01018 void addTileLightmapWithTLI(uint ts, uint tt, NLMISC::CRGBA *dest, uint stride);
01019 void addTileLightmapEdgeWithTLI(uint ts, uint tt, uint edge, NLMISC::CRGBA *dest, uint stride, bool inverse);
01020 void addTileLightmapPixelWithTLI(uint ts, uint tt, uint s, uint t, NLMISC::CRGBA *dest);
01021
01022
01023
01024
01025
01026 void computeNewFar(const NLMISC::CBSphere &patchSphere, sint &newFar0, sint &newFar1);
01027
01028
01029
01030 void fillFar0VertexVB(CTessFarVertex *pVert);
01031 void fillFar1VertexVB(CTessFarVertex *pVert);
01032 void fillTileVertexVB(CTessNearVertex *pVert);
01033 void fillFar0VertexListVB(CTessList<CTessFarVertex> &vertList);
01034 void fillFar1VertexListVB(CTessList<CTessFarVertex> &vertList);
01035 void fillTileVertexListVB(CTessList<CTessNearVertex> &vertList);
01036
01037 void updateFar0VBAlloc(CTessList<CTessFarVertex> &vertList, bool alloc);
01038 void updateFar1VBAlloc(CTessList<CTessFarVertex> &vertList, bool alloc);
01039 void updateTileVBAlloc(CTessList<CTessNearVertex> &vertList, bool alloc);
01040 void updateVBAlloc(bool alloc);
01041
01042 void debugAllocationMarkIndicesFarList(CTessList<CTessFarVertex> &vertList, uint marker);
01043 void debugAllocationMarkIndicesNearList(CTessList<CTessNearVertex> &vertList, uint marker);
01044
01045 void createFaceVectorFar1();
01046 void deleteFaceVectorFar1();
01047 void createFaceVectorFar0OrTile();
01048 void deleteFaceVectorFar0OrTile();
01049
01050
01051
01052
01053 void checkCreateVertexVBFar(CTessFarVertex *pVert);
01054 void checkCreateVertexVBNear(CTessNearVertex *pVert);
01055
01056 void checkFillVertexVBFar(CTessFarVertex *pVert);
01057 void checkFillVertexVBNear(CTessNearVertex *pVert);
01058
01059 void checkDeleteVertexVBFar(CTessFarVertex *pVert);
01060 void checkDeleteVertexVBNear(CTessNearVertex *pVert);
01061
01062
01063 void computeGeomorphVertexList(CTessList<CTessFarVertex> &vertList);
01064 void computeGeomorphFar0VertexListVB(CTessList<CTessFarVertex> &vertList);
01065 void computeGeomorphAlphaFar1VertexListVB(CTessList<CTessFarVertex> &vertList);
01066 void computeGeomorphTileVertexListVB(CTessList<CTessNearVertex> &vertList);
01067
01069
01071 void buildBBoxFromBezierPatch(const CBezierPatch &p, CAABBox &ret) const;
01077 void addTrianglesInBBoxRecurs(CPatchIdent paId, const CAABBox &bbox, std::vector<CTrianglePatch> &triangles, uint8 tessLevel,
01078 const CBezierPatch &pa, uint8 s0, uint8 s1, uint8 t0, uint8 t1) const;
01083 void addTileTrianglesInBBox(CPatchIdent paId, const CAABBox &bbox, std::vector<CTrianglePatch> &triangles, uint8 tessLevel,
01084 uint8 s0, uint8 t0) const;
01085
01088 void addPatchBlocksInBBoxRecurs(CPatchIdent paId, const CAABBox &bbox, std::vector<CPatchBlockIdent> &paBlockIds,
01089 const CBezierPatch &pa, uint8 s0, uint8 s1, uint8 t0, uint8 t1) const;
01090
01092 CVector computeVertexButCorner(float s, float t, bool &onCorner) const;
01093
01094
01095
01096
01097 private:
01098
01099
01100
01102
01103
01105 CZone *_BindZoneNeighbor[4];
01106
01110 CTessFace *linkTessFaceWithEdge(const NLMISC::CVector2f &uv0, const NLMISC::CVector2f &uv1, CTessFace *linkTo);
01111
01112
01113
01114
01115
01117
01118
01119
01120 float computeDisplaceRawInteger(sint ts, sint tt, sint ms, sint mt) const;
01121 void computeDisplaceRawCoordinates(float sTile, float tTile, float s, float t,
01122 sint &ts, sint &tt, sint &ms, sint &mt) const;
01128 float computeDisplaceRaw(float sTile, float tTile, float s, float t) const;
01132 float computeDisplaceRawOnNeighbor(float sTile, float tTile, float s, float t) const;
01133
01134
01137 float computeDisplaceInteriorSmooth(float s, float t) const;
01140 float computeDisplaceEdgeSmooth(float s, float t, sint8 smoothBorderX, sint8 smoothBorderY) const;
01143 float computeDisplaceCornerSmooth(float s, float t, sint8 smoothBorderX, sint8 smoothBorderY) const;
01144
01145
01148 CVector computeNormalEdgeSmooth(float s, float t, sint8 smoothBorderX, sint8 smoothBorderY) const;
01151 CVector computeNormalCornerSmooth(float s, float t, sint8 smoothBorderX, sint8 smoothBorderY) const;
01154 CVector computeNormalOnNeighbor(float s, float t, uint edgeExclude) const;
01155
01156
01160 void computeNoise(float s, float t, CVector &displace) const;
01161
01162
01163
01164
01165
01166 void computeTbTm(uint &numtb, uint &numtm, uint ts, uint tt);
01167
01168
01170
01171
01173 void createVegetableBlock(uint numTb, uint ts, uint tt);
01175 void releaseVegetableBlock(uint numTb);
01176
01177
01178
01179
01180
01181
01182 void generateTileVegetable(CVegetableInstanceGroup *vegetIg, uint distType, uint ts, uint tt,
01183 CLandscapeVegetableBlockCreateContext &vbCreateCtx);
01184
01185
01186 void getTileLumelmapPrecomputed(uint ts, uint tt, uint8 *dest, uint stride);
01190 void getTileLumelmapPixelPrecomputed(uint ts, uint tt, uint s, uint t, uint8 &dest) const;
01191
01192
01193
01194
01196
01197 CPatch *_ULNearPrec;
01198 CPatch *_ULNearNext;
01199
01200
01201
01203
01204
01209 CPatchDLMContext *_DLMContext;
01210
01214 sint _DLMContextRefCount;
01215
01217 void addRefDLMContext();
01219 void decRefDLMContext(uint count= 1);
01220
01221
01222
01223
01224 private:
01225
01226
01227
01228 static CBezierPatch CachePatch;
01229
01230 static const CPatch *LastPatch;
01231
01232 public:
01233
01234 CBezierPatch *unpackIntoCache() const;
01235
01236 };
01237
01238
01239
01240 }
01241
01242
01243 #endif // NL_PATCH_H
01244
01245