From 60115b1ce160f78eada6d874330ce678bee05971 Mon Sep 17 00:00:00 2001 From: tangziwen Date: Tue, 16 Jun 2015 17:46:21 +0800 Subject: [PATCH] update --- cocos/3d/CCTerrain.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cocos/3d/CCTerrain.cpp b/cocos/3d/CCTerrain.cpp index de4845c977..2d1e9a9393 100644 --- a/cocos/3d/CCTerrain.cpp +++ b/cocos/3d/CCTerrain.cpp @@ -159,9 +159,9 @@ void Terrain::onDraw(const Mat4 &transform, uint32_t flags) if(_isCameraViewChanged ) { - auto camPos = camera->getPosition3D(); + auto m = camera->getWorldToNodeTransform(); //set lod - setChunksLOD(camPos); + setChunksLOD(Vec3(m.m[12], m.m[13], m.m[14])); } if(_isCameraViewChanged ) @@ -263,8 +263,7 @@ void Terrain::setChunksLOD(Vec3 cameraPos) { AABB aabb = _chunkesArray[m][n]->_parent->_worldSpaceAABB; auto center = aabb.getCenter(); - center.y = 0; - float dist = Vec3(center.x,0,center.z).distance(Vec3(cameraPos.x,0,cameraPos.z)); + float dist = Vec2(center.x, center.z).distance(Vec2(cameraPos.x, cameraPos.z)); _chunkesArray[m][n]->_currentLod = 3; for(int i =0;i<3;i++) { @@ -1226,7 +1225,7 @@ void Terrain::Chunk::calculateAABB() std::vectorpos; for(int i =0;i<_originalVertices.size();i++) { - pos.push_back(originalVertices[i]._position); + pos.push_back(_originalVertices[i]._position); } _aabb.updateMinMax(&pos[0],pos.size()); }