An entity created by CVisualCollisionManager. More...
#include <visual_collision_entity.h>
Public Member Functions | |
| CVisualCollisionEntity (CVisualCollisionManager *owner) | |
| Constructor. | |
| ~CVisualCollisionEntity () | |
| bool | snapToGround (CVector &pos) |
| Snap the entity onto the ground. | |
| bool | snapToGround (CVector &pos, CVector &normal) |
| Snap the entity onto the ground. | |
| void | setGroundMode (bool groundMode) |
| If groundMode is true, the entity is snapped on faces with normal.z > 0. | |
| void | setCeilMode (bool ceilMode) |
| If ceilMode is true, the entity is snapped on faces with normal.z < 0. | |
| bool | getGroundMode () const |
| bool | getCeilMode () const |
| void | setSnapToRenderedTesselation (bool snapMode) |
| By default, the visual collision entity is snapped on rendered/geomorphed tesselation (true). | |
| bool | getSnapToRenderedTesselation () const |
| bool | getSurfaceInfo (const CVector &pos, CSurfaceInfo &info) |
| Get surface informations. | |
Static Lighting | |
| bool | getStaticLightSetup (NLMISC::CRGBA sunAmbient, const CVector &pos, std::vector< CPointLightInfluence > &pointLightList, uint8 &sunContribution, NLMISC::CRGBA &localAmbient) |
| Get the static Light Setup, using landscape under us. | |
Debug display | |
| void | displayDebugGrid (IDriver &drv) const |
| Draw lines for the landscape quadgrid collision faces under us. | |
Static Public Attributes | |
Parameters. | |
| static const float | BBoxRadius = 10 |
| This is the radius of the bbox around the entity where we have correct collisions: 10m. | |
| static const float | BBoxRadiusZ = 20 |
| Same as BBoxRadius, but for z value. | |
Private Attributes | |
| CVisualCollisionManager * | _Owner |
| bool | _CeilMode |
| bool | _GroundMode |
| bool | _SnapToRenderedTesselation |
Landscape part. | |
|
| |
| std::vector< CPatchQuadBlock * > | _PatchQuadBlocks |
| Array of quadBlock which are around the entity. | |
| CLandscapeCollisionGrid | _LandscapeQuadGrid |
| A quadgrid of chainlist of tileId (CVisualTileDescNode), which are around the entity. | |
| CAABBox | _CurrentBBoxValidity |
| The current BBox where we don't need to recompute the patchQuadBlocks if the entity is in. | |
| bool | _LastGPTValid |
| Cache for getPatchTriangleUnderUs(). | |
| CVector | _LastGPTPosInput |
| CVector | _LastGPTPosOutput |
| CTrianglePatch | _LastGPTTrianglePatch |
| static const uint32 | _StartPatchQuadBlockSize = 64 |
| Default capacity of _PatchQuadBlocks. | |
| static std::vector < CPatchBlockIdent > | _TmpBlockIds |
| This is the temp array of BlockIds filled by landscape search. | |
| static std::vector < CPatchQuadBlock * > | _TmpPatchQuadBlocks |
| This is the temp array of PatchBlocks ptr. | |
| static bool | triangleIntersect2DGround (CTriangle &tri, const CVector &pos0) |
| Fast "2D" test of a triangle against ray P0 P1. | |
| static bool | triangleIntersect2DCeil (CTriangle &tri, const CVector &pos0) |
| static void | computeUvForPos (const CTrianglePatch &tri, const CVector &pos, CUV &uv) |
| given a CTrianglePatch, compute Patch uv according to position. | |
| bool | triangleIntersect (CTriangle &tri, const CVector &pos0, const CVector &pos1, CVector &hit) |
| Fast "2D" test of a triangle against ray P0 P1. | |
| void | testComputeLandscape (const CVector &pos) |
| test if the new position is outside the preceding setuped bbox, and then compute tiles infos around the position. | |
| void | doComputeLandscape (const CVector &pos) |
| compute tiles infos around the position. | |
| void | snapToLandscapeCurrentTesselation (CVector &pos, const CTrianglePatch &tri) |
| snap to current rendered tesselation. | |
| CTrianglePatch * | getPatchTriangleUnderUs (const CVector &pos, CVector &res) |
| return the best trianglePatch under what we are. | |
An entity created by CVisualCollisionManager.
Definition at line 48 of file visual_collision_entity.h.
| NL3D::CVisualCollisionEntity::CVisualCollisionEntity | ( | CVisualCollisionManager * | owner | ) |
Constructor.
Definition at line 54 of file visual_collision_entity.cpp.
References _CeilMode, _CurrentBBoxValidity, _GroundMode, _LastGPTValid, _Owner, _PatchQuadBlocks, _SnapToRenderedTesselation, _StartPatchQuadBlockSize, NLMISC::CVector::Null, and NLMISC::CAABBox::setHalfSize().
| NL3D::CVisualCollisionEntity::~CVisualCollisionEntity | ( | ) |
Definition at line 70 of file visual_collision_entity.cpp.
References _LandscapeQuadGrid, _Owner, _PatchQuadBlocks, NL3D::CLandscapeCollisionGrid::clear(), and NL3D::CVisualCollisionManager::deletePatchQuadBlock().
| void NL3D::CVisualCollisionEntity::computeUvForPos | ( | const CTrianglePatch & | tri, | |
| const CVector & | pos, | |||
| CUV & | uv | |||
| ) | [static, private] |
given a CTrianglePatch, compute Patch uv according to position.
Definition at line 245 of file visual_collision_entity.cpp.
References NLMISC::CTriangle::computeGradient(), NLMISC::CUV::U, NLMISC::CTriangleUV::Uv0, NLMISC::CTriangleUV::Uv1, NLMISC::CTriangleUV::Uv2, NLMISC::CUV::V, and NLMISC::CTriangle::V0.
Referenced by getStaticLightSetup(), getSurfaceInfo(), and snapToLandscapeCurrentTesselation().
| void NL3D::CVisualCollisionEntity::displayDebugGrid | ( | IDriver & | drv | ) | const |
Draw lines for the landscape quadgrid collision faces under us.
Definition at line 610 of file visual_collision_entity.cpp.
References _PatchQuadBlocks, NL3D::CDRU::drawLinesUnlit(), NL3D::CMaterial::initUnlit(), NL_PATCH_BLOCK_MAX_VERTEX, NL3D::CPatchQuadBlock::PatchBlockId, NL3D::CPatchBlockIdent::S0, NL3D::CPatchBlockIdent::S1, NL3D::CPatchBlockIdent::T0, NL3D::CPatchBlockIdent::T1, and NL3D::CPatchQuadBlock::Vertices.
Referenced by NL3D::CVisualCollisionEntityUser::displayDebugGrid().
| void NL3D::CVisualCollisionEntity::doComputeLandscape | ( | const CVector & | pos | ) | [private] |
compute tiles infos around the position.
Definition at line 412 of file visual_collision_entity.cpp.
References _CurrentBBoxValidity, NL3D::CVisualCollisionManager::_Landscape, _LandscapeQuadGrid, _Owner, _PatchQuadBlocks, _TmpBlockIds, _TmpPatchQuadBlocks, BBoxRadius, BBoxRadiusZ, NL3D::CLandscapeCollisionGrid::build(), NL3D::CVisualCollisionManager::deletePatchQuadBlock(), NL3D::CVisualCollisionManager::newPatchQuadBlock(), NLMISC::CAABBox::setCenter(), NLMISC::CAABBox::setHalfSize(), NLMISC::CVector::x, NLMISC::CVector::y, and NLMISC::CVector::z.
Referenced by testComputeLandscape().
| bool NL3D::CVisualCollisionEntity::getCeilMode | ( | ) | const [inline] |
Definition at line 88 of file visual_collision_entity.h.
References _CeilMode.
Referenced by NL3D::CVisualCollisionEntityUser::getCeilMode().
| bool NL3D::CVisualCollisionEntity::getGroundMode | ( | ) | const [inline] |
Definition at line 87 of file visual_collision_entity.h.
References _GroundMode.
Referenced by NL3D::CVisualCollisionEntityUser::getGroundMode().
| CTrianglePatch * NL3D::CVisualCollisionEntity::getPatchTriangleUnderUs | ( | const CVector & | pos, | |
| CVector & | res | |||
| ) | [private] |
return the best trianglePatch under what we are.
NULL if not found. Ptr is valid until next call to getPatchTriangleUnderUs() Actually return NULL or
Definition at line 94 of file visual_collision_entity.cpp.
References NL3D::CVisualCollisionManager::_Landscape, _LandscapeQuadGrid, _LastGPTPosInput, _LastGPTPosOutput, _LastGPTTrianglePatch, _LastGPTValid, _Owner, _PatchQuadBlocks, NL3D::CVisualTileDescNode::Next, nlassert, NL3D::CVisualTileDescNode::PatchQuadBlocId, NL3D::CVisualTileDescNode::QuadId, NL3D::CLandscapeCollisionGrid::select(), NLMISC::sqr(), testComputeLandscape(), and triangleIntersect().
Referenced by getStaticLightSetup(), getSurfaceInfo(), and snapToGround().
| bool NL3D::CVisualCollisionEntity::getSnapToRenderedTesselation | ( | ) | const [inline] |
Definition at line 96 of file visual_collision_entity.h.
References _SnapToRenderedTesselation.
Referenced by NL3D::CVisualCollisionEntityUser::getSnapToRenderedTesselation().
| bool NL3D::CVisualCollisionEntity::getStaticLightSetup | ( | NLMISC::CRGBA | sunAmbient, | |
| const CVector & | pos, | |||
| std::vector< CPointLightInfluence > & | pointLightList, | |||
| uint8 & | sunContribution, | |||
| NLMISC::CRGBA & | localAmbient | |||
| ) |
Get the static Light Setup, using landscape under us.
append lights to pointLightList. NB: if find no landscape faces, don't modify pointLightList, set sunContribution=255, and return false Else, use CPatch::TileLightInfluences to get lights, and use CPatch::Lumels to get sunContribution. NB: because CPatch::Lumels encode the gouraud shading on the surface, returning lumelValue will darken the object too much. To avoid this, the sunContribution is raised to a power (0..1). See CVisualCollisionManager::setSunContributionPower(). Default is 0.5
Definition at line 525 of file visual_collision_entity.cpp.
References NL3D::CVisualCollisionManager::_Landscape, _Owner, NL3D::CVisualCollisionManager::_SunContributionLUT, computeUvForPos(), getPatchTriangleUnderUs(), and NL3D::CTrianglePatch::PatchId.
Referenced by NL3D::CInstanceLighter::computeSunContribution(), and NL3D::CVisualCollisionEntityUser::getStaticLightSetup().
| bool NL3D::CVisualCollisionEntity::getSurfaceInfo | ( | const CVector & | pos, | |
| CSurfaceInfo & | info | |||
| ) |
Get surface informations.
pos is checked with polygons that are at least (cache dependent) at +- 10m in altitude.
| info | will be filled with surface informations if the method returns true. |
Definition at line 563 of file visual_collision_entity.cpp.
References NL3D::CVisualCollisionManager::_Landscape, _Owner, computeUvForPos(), getPatchTriangleUnderUs(), NL3D::CTileBank::getTileSet(), NL3D::CTileBank::getTileXRef(), H_AUTO, NL_TILE_ELM_LAYER_EMPTY, NL3D::CTrianglePatch::PatchId, NL3D::CTileSet::SurfaceData, NL3D::CTileElement::Tile, and NL3D::CSurfaceInfo::UserSurfaceData.
Referenced by NL3D::CVisualCollisionEntityUser::getSurfaceInfo().
| void NL3D::CVisualCollisionEntity::setCeilMode | ( | bool | ceilMode | ) | [inline] |
If ceilMode is true, the entity is snapped on faces with normal.z < 0.
Default is false. NB: if both groundMode and ceilMode are false, snapToGround is a no-op.
Definition at line 84 of file visual_collision_entity.h.
References _CeilMode.
Referenced by NL3D::CVisualCollisionEntityUser::setCeilMode().
| void NL3D::CVisualCollisionEntity::setGroundMode | ( | bool | groundMode | ) | [inline] |
If groundMode is true, the entity is snapped on faces with normal.z > 0.
Default is true. NB: if both groundMode and ceilMode are false, snapToGround is a no-op.
Definition at line 78 of file visual_collision_entity.h.
References _GroundMode.
Referenced by NL3D::CVisualCollisionEntityUser::setGroundMode().
| void NL3D::CVisualCollisionEntity::setSnapToRenderedTesselation | ( | bool | snapMode | ) | [inline] |
By default, the visual collision entity is snapped on rendered/geomorphed tesselation (true).
Use this method to change this behavior. if false, the entity is snapped to the tile level tesselation according to noise etc...
Definition at line 95 of file visual_collision_entity.h.
References _SnapToRenderedTesselation.
Referenced by NL3D::CVisualCollisionEntityUser::setSnapToRenderedTesselation().
Snap the entity onto the ground.
pos.z is modified so that it lies on the ground, according to rendered landscapes and meshes. pos is checked with polygons that are at least (cache dependent) at +- 10m in altitude.
| normal | the ret normal of where it is snapped. NB: if return false, not modified. |
Definition at line 209 of file visual_collision_entity.cpp.
References _SnapToRenderedTesselation, getPatchTriangleUnderUs(), NLMISC::CVector::normalize(), snapToLandscapeCurrentTesselation(), NLMISC::CTriangle::V0, NLMISC::CTriangle::V1, and NLMISC::CTriangle::V2.
Snap the entity onto the ground.
pos.z is modified so that it lies on the ground, according to rendered landscapes and meshes. see setSnapToRenderedTesselation() option. pos is checked with polygons that are at least (cache dependent) at +- 10m in altitude.
Definition at line 85 of file visual_collision_entity.cpp.
Referenced by NL3D::CVisualCollisionEntityUser::snapToGround().
| void NL3D::CVisualCollisionEntity::snapToLandscapeCurrentTesselation | ( | CVector & | pos, | |
| const CTrianglePatch & | tri | |||
| ) | [private] |
snap to current rendered tesselation.
Definition at line 259 of file visual_collision_entity.cpp.
References NL3D::CVisualCollisionManager::_Landscape, _Owner, computeUvForPos(), NL3D::CTrianglePatch::PatchId, and NLMISC::CVector::z.
Referenced by snapToGround().
| void NL3D::CVisualCollisionEntity::testComputeLandscape | ( | const CVector & | pos | ) | [private] |
test if the new position is outside the preceding setuped bbox, and then compute tiles infos around the position.
Definition at line 401 of file visual_collision_entity.cpp.
References _CurrentBBoxValidity, doComputeLandscape(), NLMISC::CAABBox::getHalfSize(), NLMISC::CAABBox::include(), and NLMISC::CVector::Null.
Referenced by getPatchTriangleUnderUs().
| bool NL3D::CVisualCollisionEntity::triangleIntersect | ( | CTriangle & | tri, | |
| const CVector & | pos0, | |||
| const CVector & | pos1, | |||
| CVector & | hit | |||
| ) | [private] |
Fast "2D" test of a triangle against ray P0 P1.
Definition at line 364 of file visual_collision_entity.cpp.
References _CeilMode, _GroundMode, NLMISC::CPlane::intersect(), NLMISC::CPlane::make(), triangleIntersect2DCeil(), triangleIntersect2DGround(), NLMISC::CTriangle::V0, NLMISC::CTriangle::V1, NLMISC::CTriangle::V2, NLMISC::CVector::x, NLMISC::CVector::y, and NLMISC::CVector::z.
Referenced by getPatchTriangleUnderUs().
| bool NL3D::CVisualCollisionEntity::triangleIntersect2DCeil | ( | CTriangle & | tri, | |
| const CVector & | pos0 | |||
| ) | [static, private] |
Definition at line 334 of file visual_collision_entity.cpp.
References NLMISC::CTriangle::V0, NLMISC::CTriangle::V1, NLMISC::CTriangle::V2, NLMISC::CVector::x, and NLMISC::CVector::y.
Referenced by triangleIntersect().
| bool NL3D::CVisualCollisionEntity::triangleIntersect2DGround | ( | CTriangle & | tri, | |
| const CVector & | pos0 | |||
| ) | [static, private] |
Fast "2D" test of a triangle against ray P0 P1.
Definition at line 297 of file visual_collision_entity.cpp.
References NLMISC::CTriangle::V0, NLMISC::CTriangle::V1, NLMISC::CTriangle::V2, NLMISC::CVector::x, and NLMISC::CVector::y.
Referenced by triangleIntersect().
bool NL3D::CVisualCollisionEntity::_CeilMode [private] |
Definition at line 147 of file visual_collision_entity.h.
Referenced by CVisualCollisionEntity(), getCeilMode(), setCeilMode(), and triangleIntersect().
The current BBox where we don't need to recompute the patchQuadBlocks if the entity is in.
Definition at line 169 of file visual_collision_entity.h.
Referenced by CVisualCollisionEntity(), doComputeLandscape(), and testComputeLandscape().
Definition at line 148 of file visual_collision_entity.h.
Referenced by CVisualCollisionEntity(), getGroundMode(), setGroundMode(), and triangleIntersect().
A quadgrid of chainlist of tileId (CVisualTileDescNode), which are around the entity.
Definition at line 167 of file visual_collision_entity.h.
Referenced by doComputeLandscape(), getPatchTriangleUnderUs(), and ~CVisualCollisionEntity().
Definition at line 172 of file visual_collision_entity.h.
Referenced by getPatchTriangleUnderUs().
Definition at line 173 of file visual_collision_entity.h.
Referenced by getPatchTriangleUnderUs().
Definition at line 174 of file visual_collision_entity.h.
Referenced by getPatchTriangleUnderUs().
Cache for getPatchTriangleUnderUs().
Definition at line 171 of file visual_collision_entity.h.
Referenced by CVisualCollisionEntity(), and getPatchTriangleUnderUs().
Definition at line 145 of file visual_collision_entity.h.
Referenced by CVisualCollisionEntity(), doComputeLandscape(), getPatchTriangleUnderUs(), getStaticLightSetup(), getSurfaceInfo(), snapToLandscapeCurrentTesselation(), and ~CVisualCollisionEntity().
std::vector<CPatchQuadBlock*> NL3D::CVisualCollisionEntity::_PatchQuadBlocks [private] |
Array of quadBlock which are around the entity.
NB: plain vector, because not so big (ptrs). NB: reserve to a big size (64), so reallocation rarely occurs. NB: this array is sorted in ascending order (comparison of CPatchBlockIdent).
Definition at line 165 of file visual_collision_entity.h.
Referenced by CVisualCollisionEntity(), displayDebugGrid(), doComputeLandscape(), getPatchTriangleUnderUs(), and ~CVisualCollisionEntity().
Definition at line 149 of file visual_collision_entity.h.
Referenced by CVisualCollisionEntity(), getSnapToRenderedTesselation(), setSnapToRenderedTesselation(), and snapToGround().
const uint32 NL3D::CVisualCollisionEntity::_StartPatchQuadBlockSize = 64 [static, private] |
Default capacity of _PatchQuadBlocks.
Definition at line 155 of file visual_collision_entity.h.
Referenced by CVisualCollisionEntity().
vector< CPatchBlockIdent > NL3D::CVisualCollisionEntity::_TmpBlockIds [static, private] |
This is the temp array of BlockIds filled by landscape search.
Definition at line 157 of file visual_collision_entity.h.
Referenced by doComputeLandscape().
vector< CPatchQuadBlock * > NL3D::CVisualCollisionEntity::_TmpPatchQuadBlocks [static, private] |
This is the temp array of PatchBlocks ptr.
Definition at line 159 of file visual_collision_entity.h.
Referenced by doComputeLandscape().
const float NL3D::CVisualCollisionEntity::BBoxRadius = 10 [static] |
This is the radius of the bbox around the entity where we have correct collisions: 10m.
Definition at line 110 of file visual_collision_entity.h.
Referenced by doComputeLandscape().
const float NL3D::CVisualCollisionEntity::BBoxRadiusZ = 20 [static] |
Same as BBoxRadius, but for z value.
This later should be greater because of NLPACS surface quadtree imprecision. 20m NB: Because of caching, if the pos.z passed to snapToGround() is outside of the currentBBox with BBoxRadiuZ/2 (=> 10m), then the bbox is recomputed. Hence, this actually means that a pos is checked with patchs that are at least at +- 10m in altitude.
Definition at line 117 of file visual_collision_entity.h.
Referenced by doComputeLandscape().
1.6.1