From 5b857f7d6674d189c9bfebafd5ed4c39c013d514 Mon Sep 17 00:00:00 2001 From: tangziwen Date: Tue, 23 Jun 2015 16:11:00 +0800 Subject: [PATCH] fix some bug --- cocos/3d/CCTerrain.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/cocos/3d/CCTerrain.cpp b/cocos/3d/CCTerrain.cpp index 37bf796c10..7bb2b8a8b9 100644 --- a/cocos/3d/CCTerrain.cpp +++ b/cocos/3d/CCTerrain.cpp @@ -512,13 +512,13 @@ bool Terrain::getIntersectionPoint(const Ray & ray, Vec3 & intersectionPoint) co start.y /=(_terrainData._chunkSize.height+1); Vec2 delta = dir.getNormalized(); int maxStep = 10; - Vec2 neighbors[] = { Vec2(0, 0), Vec2(1, 1), Vec2(0, 1), Vec2(1, 0), Vec2(-1, 0), Vec2(0, -1), Vec2(-1, 1), - Vec2(1, -1), Vec2(-1, -1) }; - for(int i=0;i 0 && start.x > width) || (delta.x <0 && start.x <0)) + { + break; + } + if ((delta.y > 0 && start.y > height) || (delta.y < 0 && start.y < 0)) + { + break; + } } return false; }