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/tess__block_8cpp-source.html | 458 ++++++++++++++++++++++++++ 1 file changed, 458 insertions(+) create mode 100644 docs/doxygen/nel/tess__block_8cpp-source.html (limited to 'docs/doxygen/nel/tess__block_8cpp-source.html') diff --git a/docs/doxygen/nel/tess__block_8cpp-source.html b/docs/doxygen/nel/tess__block_8cpp-source.html new file mode 100644 index 00000000..be62cb86 --- /dev/null +++ b/docs/doxygen/nel/tess__block_8cpp-source.html @@ -0,0 +1,458 @@ + + + + nevrax.org : docs + + + + + + + + + + + + + + +
# Home   # nevrax.com   
+ + + + +
Nevrax
+ + + + + + + + + + +
+ + +
+ Nevrax.org
+ + + + + + + +
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
+
+ + +
+ + +
+Docs + +
+  + + + + + +
Documentation 
+ +
+Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  
+

tess_block.cpp

Go to the documentation of this file.
00001 
+00007 /* Copyright, 2000 Nevrax Ltd.
+00008  *
+00009  * This file is part of NEVRAX NEL.
+00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
+00011  * it under the terms of the GNU General Public License as published by
+00012  * the Free Software Foundation; either version 2, or (at your option)
+00013  * any later version.
+00014 
+00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
+00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
+00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+00018  * General Public License for more details.
+00019 
+00020  * You should have received a copy of the GNU General Public License
+00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
+00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+00023  * MA 02111-1307, USA.
+00024  */
+00025 
+00026 #include "std3d.h"
+00027 
+00028 #include "3d/tess_block.h"
+00029 #include "3d/patch_rdr_pass.h"
+00030 #include "3d/landscape_face_vector_manager.h"
+00031 
+00032 
+00033 namespace NL3D 
+00034 {
+00035 
+00036 
+00037 CPlane  CTessBlock::CurrentPyramid[NL3D_TESSBLOCK_NUM_CLIP_PLANE];
+00038 
+00039 
+00040 
+00041 // ***************************************************************************
+00042 CTessBlock::CTessBlock()
+00043 {
+00044         _Patch= NULL;
+00045 
+00046         // init bounding info.
+00047         Empty= true;
+00048         // By default, the tessBlock is clipped.
+00049         Clipped= true;
+00050         FullFar1= false;
+00051         EmptyFar1= false;
+00052 
+00053         // init vert/face list.
+00054         for(sint i=0;i<NL3D_TESSBLOCK_TILESIZE;i++)
+00055         {
+00056                 RdrTileRoot[i]=NULL;
+00057         }
+00058 
+00059         // init LightMap.
+00060         LightMapRefCount= 0;
+00061 
+00062         Far0FaceVector= NULL;
+00063         Far1FaceVector= NULL;
+00064 
+00065         _PrecToModify= NULL;
+00066         _NextToModify= NULL;
+00067 
+00068         FaceTileMaterialRefCount= 0;
+00069         TileMaterialRefCount= 0;
+00070 
+00071         // Micro-vegetation.
+00072         VegetableBlock= NULL;
+00073 }
+00074 
+00075 
+00076 // ***************************************************************************
+00077 CTessBlock::~CTessBlock()
+00078 {
+00079         if(isInModifyList())
+00080         {
+00081                 removeFromModifyList();
+00082         }
+00083 
+00084         // LightMap should be released
+00085         nlassert(LightMapRefCount==0);
+00086 }
+00087 
+00088 // ***************************************************************************
+00089 void                    CTessBlock::init(CPatch *patch)
+00090 {
+00091         _Patch= patch;
+00092 }
+00093 // ***************************************************************************
+00094 CPatch                  *CTessBlock::getPatch()
+00095 {
+00096         return _Patch;
+00097 }
+00098 
+00099 
+00100 
+00101 // ***************************************************************************
+00102 void                    CTessBlock::extendSphereFirst(const CVector &vec)
+00103 {
+00104         if(Empty)
+00105         {
+00106                 Empty= false;
+00107                 BBox.setCenter(vec);
+00108                 BBox.setHalfSize(CVector::Null);
+00109         }
+00110         else
+00111                 extendSphereAdd(vec);
+00112 }
+00113 
+00114 // ***************************************************************************
+00115 void                    CTessBlock::extendSphereAdd(const CVector &vec)
+00116 {
+00117         if( !BBox.include(vec) )
+00118                 BBox.extend(vec);
+00119 }
+00120 
+00121 // ***************************************************************************
+00122 void                    CTessBlock::extendSphereCompile()
+00123 {
+00124         BSphere.Center= BBox.getCenter();
+00125         BSphere.Radius= BBox.getRadius();
+00126 }
+00127 
+00128 
+00129 // ***************************************************************************
+00130 void                    CTessBlock::resetClip()
+00131 {
+00132         Clipped= false;
+00133         FullFar1= false;
+00134         EmptyFar1= false;
+00135 }
+00136 
+00137 
+00138 // ***************************************************************************
+00139 void                    CTessBlock::forceClip()
+00140 {
+00141         Clipped= true;
+00142 }
+00143 
+00144 
+00145 // ***************************************************************************
+00146 void                    CTessBlock::clip()
+00147 {
+00148         Clipped= false;
+00149         for(sint i=0;i<NL3D_TESSBLOCK_NUM_CLIP_PLANE;i++)
+00150         {
+00151                 // If entirely out.
+00152                 if(!BSphere.clipBack( CTessBlock::CurrentPyramid[i] ))
+00153                 {
+00154                         Clipped= true;
+00155                         break;
+00156                 }
+00157         }
+00158 }
+00159 // ***************************************************************************
+00160 void                    CTessBlock::clipFar(const CVector &refineCenter, float tileDistNear, float farTransition)
+00161 {
+00162         float   r= (refineCenter-BSphere.Center).norm();
+00163         if( (r-BSphere.Radius) > tileDistNear)
+00164         {
+00165                 FullFar1= true;
+00166         }
+00167         else
+00168         {
+00169                 if( (r+BSphere.Radius) < (tileDistNear-farTransition) )
+00170                         EmptyFar1= true;
+00171         }
+00172 }
+00173 
+00174 
+00175 
+00176 // ***************************************************************************
+00177 void                    CTessBlock::refillFaceVectorFar0()
+00178 {
+00179         // If size is not 0.
+00180         if(FarFaceList.size()>0)
+00181         {
+00182                 nlassert(Far0FaceVector!=NULL);
+00183 
+00184                 // Fill this faceVector, with FarFaceList
+00185                 CTessFace       *pFace;
+00186                 uint32          *dest= Far0FaceVector->TriPtr;
+00187                 for(pFace= FarFaceList.begin(); pFace; pFace= (CTessFace*)pFace->Next)
+00188                 {
+00189                         *(dest++)= pFace->FVBase->Index0;
+00190                         *(dest++)= pFace->FVLeft->Index0;
+00191                         *(dest++)= pFace->FVRight->Index0;
+00192                 }
+00193         }
+00194 }
+00195 
+00196 
+00197 // ***************************************************************************
+00198 void                    CTessBlock::createFaceVectorFar0(CLandscapeFaceVectorManager &mgr)
+00199 {
+00200         nlassert(Far0FaceVector==NULL);
+00201         // If size is not 0.
+00202         if(FarFaceList.size()>0)
+00203         {
+00204                 // Create a faceVector of the wanted triangles size.
+00205                 Far0FaceVector= mgr.createFaceVector(FarFaceList.size());
+00206 
+00207                 // init.
+00208                 refillFaceVectorFar0();
+00209         }
+00210 
+00211 }
+00212 // ***************************************************************************
+00213 void                    CTessBlock::deleteFaceVectorFar0(CLandscapeFaceVectorManager &mgr)
+00214 {
+00215         if(Far0FaceVector)
+00216         {
+00217                 mgr.deleteFaceVector(Far0FaceVector);
+00218                 Far0FaceVector= NULL;
+00219         }
+00220 }
+00221 
+00222 // ***************************************************************************
+00223 void                    CTessBlock::refillFaceVectorFar1()
+00224 {
+00225         // If size is not 0.
+00226         if(FarFaceList.size()>0)
+00227         {
+00228                 nlassert(Far1FaceVector!=NULL);
+00229                 // Fill this faceVector, with FarFaceList
+00230                 CTessFace       *pFace;
+00231                 uint32          *dest= Far1FaceVector->TriPtr;
+00232                 for(pFace= FarFaceList.begin(); pFace; pFace= (CTessFace*)pFace->Next)
+00233                 {
+00234                         *(dest++)= pFace->FVBase->Index1;
+00235                         *(dest++)= pFace->FVLeft->Index1;
+00236                         *(dest++)= pFace->FVRight->Index1;
+00237                 }
+00238         }
+00239 }
+00240 
+00241 // ***************************************************************************
+00242 void                    CTessBlock::createFaceVectorFar1(CLandscapeFaceVectorManager &mgr)
+00243 {
+00244         nlassert(Far1FaceVector==NULL);
+00245         // If size is not 0.
+00246         if(FarFaceList.size()>0)
+00247         {
+00248                 // Create a faceVector of the wanted triangles size.
+00249                 Far1FaceVector= mgr.createFaceVector(FarFaceList.size());
+00250 
+00251                 // init.
+00252                 refillFaceVectorFar1();
+00253         }
+00254 }
+00255 // ***************************************************************************
+00256 void                    CTessBlock::deleteFaceVectorFar1(CLandscapeFaceVectorManager &mgr)
+00257 {
+00258         if(Far1FaceVector)
+00259         {
+00260                 mgr.deleteFaceVector(Far1FaceVector);
+00261                 Far1FaceVector= NULL;
+00262         }
+00263 }
+00264 
+00265 
+00266 // ***************************************************************************
+00267 void                    CTessBlock::refillFaceVectorTile()
+00268 {
+00269         // For all tiles existing, and for all facePass existing, fill the faceVector.
+00270         for(uint tileId=0; tileId<NL3D_TESSBLOCK_TILESIZE; tileId++)
+00271         {
+00272                 // if tile exist.
+00273                 if(RdrTileRoot[tileId])
+00274                 {
+00275                         // For all Pass faces of the tile.
+00276                         for(uint facePass=0; facePass<NL3D_MAX_TILE_FACE; facePass++)
+00277                         {
+00278                                 CTessList<CTileFace>    &faceList= RdrTileRoot[tileId]->TileFaceList[facePass];
+00279                                 CLandscapeFaceVector    *faceVector= RdrTileRoot[tileId]->TileFaceVectors[facePass];
+00280                                 // If some triangles create them.
+00281                                 if(faceList.size()>0)
+00282                                 {
+00283                                         nlassert( faceVector!=NULL );
+00284 
+00285                                         // Fill this faceVector, with the TileFaceList
+00286                                         CTileFace       *pFace;
+00287                                         uint32          *dest= faceVector->TriPtr;
+00288                                         for(pFace= faceList.begin(); pFace; pFace= (CTileFace*)pFace->Next)
+00289                                         {
+00290                                                 *(dest++)= pFace->V[CTessFace::IdUvBase]->Index;
+00291                                                 *(dest++)= pFace->V[CTessFace::IdUvLeft]->Index;
+00292                                                 *(dest++)= pFace->V[CTessFace::IdUvRight]->Index;
+00293                                         }
+00294                                 }
+00295                         }
+00296                 }
+00297         }
+00298 }
+00299 
+00300 
+00301 // ***************************************************************************
+00302 void                    CTessBlock::createFaceVectorTile(CLandscapeFaceVectorManager &mgr)
+00303 {
+00304         // For all tiles existing, and for all facePass existing, create the faceVector.
+00305         for(uint tileId=0; tileId<NL3D_TESSBLOCK_TILESIZE; tileId++)
+00306         {
+00307                 // if tile exist.
+00308                 if(RdrTileRoot[tileId])
+00309                 {
+00310                         // For all Pass faces of the tile.
+00311                         for(uint facePass=0; facePass<NL3D_MAX_TILE_FACE; facePass++)
+00312                         {
+00313                                 CTessList<CTileFace>    &faceList= RdrTileRoot[tileId]->TileFaceList[facePass];
+00314                                 CLandscapeFaceVector    *&faceVector= RdrTileRoot[tileId]->TileFaceVectors[facePass];
+00315                                 // If some triangles create them.
+00316                                 if(faceList.size()>0)
+00317                                 {
+00318                                         // Create a faceVector of the wanted triangles size.
+00319                                         faceVector= mgr.createFaceVector(faceList.size());
+00320                                 }
+00321                         }
+00322                 }
+00323         }
+00324 
+00325         // init.
+00326         refillFaceVectorTile();
+00327 }
+00328 // ***************************************************************************
+00329 void                    CTessBlock::deleteFaceVectorTile(CLandscapeFaceVectorManager &mgr)
+00330 {
+00331         // For all tiles existing, and for all facePass existing, delete the faceVector.
+00332         for(uint tileId=0; tileId<NL3D_TESSBLOCK_TILESIZE; tileId++)
+00333         {
+00334                 // if tile exist.
+00335                 if(RdrTileRoot[tileId])
+00336                 {
+00337                         // For all Pass faces of the tile.
+00338                         for(uint facePass=0; facePass<NL3D_MAX_TILE_FACE; facePass++)
+00339                         {
+00340                                 CLandscapeFaceVector    *&faceVector= RdrTileRoot[tileId]->TileFaceVectors[facePass];
+00341                                 // If the faceVector exist, delete it.
+00342                                 if(faceVector)
+00343                                 {
+00344                                         mgr.deleteFaceVector(faceVector);
+00345                                         faceVector= NULL;
+00346                                 }
+00347                         }
+00348                 }
+00349         }
+00350 }
+00351 
+00352 
+00353 // ***************************************************************************
+00354 void                    CTessBlock::appendToModifyListAndDeleteFaceVector(CTessBlock &root, CLandscapeFaceVectorManager &mgr)
+00355 {
+00356         // If already appened, return.
+00357         if(isInModifyList())
+00358                 return;
+00359 
+00360         // append to root.
+00361         _PrecToModify= &root;
+00362         _NextToModify= root._NextToModify;
+00363         if(root._NextToModify)
+00364                 root._NextToModify->_PrecToModify= this;
+00365         root._NextToModify= this;
+00366 
+00367         // Then delete All faceVector that may exist.
+00368         deleteFaceVectorFar0(mgr);
+00369         deleteFaceVectorFar1(mgr);
+00370         deleteFaceVectorTile(mgr);
+00371 }
+00372 // ***************************************************************************
+00373 void                    CTessBlock::removeFromModifyList()
+00374 {
+00375         // If already removed, return.
+00376         // _PrecToModify must be !NULL
+00377         if(!isInModifyList())
+00378                 return;
+00379 
+00380         // unlink.
+00381         _PrecToModify->_NextToModify= _NextToModify;
+00382         if(_NextToModify)
+00383                 _NextToModify->_PrecToModify= _PrecToModify;
+00384         _PrecToModify= NULL;
+00385         _NextToModify= NULL;
+00386 }
+00387 
+00388 
+00389 } // NL3D
+
+ + +
                                                                                                                                                                    +
+ + -- cgit v1.2.1