Home | nevrax.com |
|
visual_collision_manager.cppGo to the documentation of this file.00001 00007 /* Copyright, 2001 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/visual_collision_manager.h" 00029 #include "3d/visual_collision_entity.h" 00030 #include "3d/landscape.h" 00031 #include "nel/misc/common.h" 00032 00033 00034 namespace NL3D 00035 { 00036 00037 00038 // *************************************************************************** 00039 // Those blocks size are computed to be approximatively one block for 10 entities. 00040 const uint TileDescNodeAllocatorBlockSize= 40000; 00041 const uint PatchQuadBlockAllocatorBlockSize= 160; 00042 00043 00044 // *************************************************************************** 00045 CVisualCollisionManager::CVisualCollisionManager() : 00046 _TileDescNodeAllocator(TileDescNodeAllocatorBlockSize), 00047 _PatchQuadBlockAllocator(PatchQuadBlockAllocatorBlockSize) 00048 { 00049 _Landscape= NULL; 00050 00051 // Default. 00052 setSunContributionPower(0.5f); 00053 } 00054 // *************************************************************************** 00055 CVisualCollisionManager::~CVisualCollisionManager() 00056 { 00057 _Landscape= NULL; 00058 } 00059 00060 00061 // *************************************************************************** 00062 void CVisualCollisionManager::setLandscape(CLandscape *landscape) 00063 { 00064 _Landscape= landscape; 00065 } 00066 00067 00068 // *************************************************************************** 00069 CVisualCollisionEntity *CVisualCollisionManager::createEntity() 00070 { 00071 return new CVisualCollisionEntity(this); 00072 } 00073 00074 00075 // *************************************************************************** 00076 void CVisualCollisionManager::deleteEntity(CVisualCollisionEntity *entity) 00077 { 00078 delete entity; 00079 } 00080 00081 00082 // *************************************************************************** 00083 CVisualTileDescNode *CVisualCollisionManager::newVisualTileDescNode() 00084 { 00085 return _TileDescNodeAllocator.allocate(); 00086 } 00087 00088 // *************************************************************************** 00089 void CVisualCollisionManager::deleteVisualTileDescNode(CVisualTileDescNode *ptr) 00090 { 00091 _TileDescNodeAllocator.free(ptr); 00092 } 00093 00094 // *************************************************************************** 00095 CPatchQuadBlock *CVisualCollisionManager::newPatchQuadBlock() 00096 { 00097 return _PatchQuadBlockAllocator.allocate(); 00098 } 00099 00100 // *************************************************************************** 00101 void CVisualCollisionManager::deletePatchQuadBlock(CPatchQuadBlock *ptr) 00102 { 00103 _PatchQuadBlockAllocator.free(ptr); 00104 } 00105 00106 00107 // *************************************************************************** 00108 void CVisualCollisionManager::setSunContributionPower(float power) 00109 { 00110 NLMISC::clamp(power, 0.f, 1.f); 00111 00112 for(uint i=0; i<256; i++) 00113 { 00114 float f= i/255.f; 00115 f= powf(f, power); 00116 sint uf= (sint)floor(255*f); 00117 NLMISC::clamp(uf, 0, 255); 00118 _SunContributionLUT[i]= uf; 00119 } 00120 00121 } 00122 00123 00124 00125 } // NL3D |