|
|
|
@ -202,7 +202,7 @@ void CTool::getMouseRightDown(bool &down, sint32 &x, sint32 &y)
|
|
|
|
|
x = y = -1;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
down = cursor->getPointerMiddleDown(x, y);
|
|
|
|
|
down = cursor->getPointerRightDown(x, y);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -372,7 +372,6 @@ bool CTool::raytrace(const NLMISC::CVector &segmentStart, const NLMISC::CVector
|
|
|
|
|
{
|
|
|
|
|
if (Landscape)
|
|
|
|
|
{
|
|
|
|
|
nlinfo("landscape=%d,%d", segmentStart.x, segmentStart.y);
|
|
|
|
|
// use a shortest distance for collision manager (for speed)
|
|
|
|
|
CVector segmentEnd = segmentStart + 100.f * dir;
|
|
|
|
|
float dist = Landscape->getRayCollision(segmentStart, segmentEnd);
|
|
|
|
@ -485,27 +484,19 @@ bool CTool::computeNearestValidSurfaceFromHeightMap(float x, float y, NLMISC::CV
|
|
|
|
|
|
|
|
|
|
const CScenarioEntryPoints::CCompleteIsland *islandDesc = getEditor().getIslandCollision().getCurrIslandDesc();
|
|
|
|
|
if (!islandDesc) return false;
|
|
|
|
|
|
|
|
|
|
nlinfo("have island");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sint mapX = (sint) (x - islandDesc->XMin);
|
|
|
|
|
sint mapY = (sint) (y - islandDesc->YMin);
|
|
|
|
|
|
|
|
|
|
nlinfo("mapX,mapY=%d,%d island=%d,%d-%d,%d", mapX, mapY, islandDesc->XMin, islandDesc->YMin, islandDesc->XMax, islandDesc->YMax);
|
|
|
|
|
if (mapX < 0 || mapY < 0 || mapX >= (islandDesc->XMax - islandDesc->XMin) || mapY >= (islandDesc->YMax - islandDesc->YMin)) return false;
|
|
|
|
|
sint hmZ = heightMap(mapX, mapY);
|
|
|
|
|
nlinfo("HeightMap = %d", hmZ);
|
|
|
|
|
if (hmZ >= 0x7ffe) return false; // not an accessible pos
|
|
|
|
|
|
|
|
|
|
nlinfo("accessible pos");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!isIslandValidPos(heightMap, *islandDesc, x + 0.5f, y) ||
|
|
|
|
|
!isIslandValidPos(heightMap, *islandDesc, x - 0.5f, y) ||
|
|
|
|
|
!isIslandValidPos(heightMap, *islandDesc, x, y + 0.5f) ||
|
|
|
|
|
!isIslandValidPos(heightMap, *islandDesc, x, y - 0.5f)) return false;
|
|
|
|
|
|
|
|
|
|
nlinfo("valid pos");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float z = 1.f + 2.f * hmZ;
|
|
|
|
|
// this is a possibly valid position
|
|
|
|
|
// compute nearest surface from here, and see if not far from the intersection
|
|
|
|
@ -524,9 +515,7 @@ bool CTool::computeNearestValidSurfaceFromHeightMap(float x, float y, NLMISC::CV
|
|
|
|
|
inter1Found = inter1Found && normal1.z >= minAngleSin;
|
|
|
|
|
inter2Found = inter2Found && normal2.z >= minAngleSin;
|
|
|
|
|
if (!inter1Found && !inter2Found) return false;
|
|
|
|
|
|
|
|
|
|
nlinfo("inter foud");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (inter1Found && inter2Found)
|
|
|
|
|
{
|
|
|
|
|
// because z in heightmap in usually a 'ceil' of real height, tends to favor surface below
|
|
|
|
@ -543,7 +532,6 @@ bool CTool::computeNearestValidSurfaceFromHeightMap(float x, float y, NLMISC::CV
|
|
|
|
|
{
|
|
|
|
|
inter = inter2;
|
|
|
|
|
}
|
|
|
|
|
nlinfo("inter = %d,%d", inter.x, inter.y);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -573,7 +561,6 @@ CTool::TRayIntersectionType CTool::computeLandscapeRayIntersection(const CWorldV
|
|
|
|
|
{
|
|
|
|
|
CVector delta = bias * (cardinals[k].x * worldViewRay.Right + cardinals[k].y * worldViewRay.Up);
|
|
|
|
|
found = raytrace(worldViewRay.Origin + delta, worldViewRay.Dir, inter);
|
|
|
|
|
nlinfo("found");
|
|
|
|
|
}
|
|
|
|
|
if (!found)
|
|
|
|
|
{
|
|
|
|
@ -585,12 +572,10 @@ CTool::TRayIntersectionType CTool::computeLandscapeRayIntersection(const CWorldV
|
|
|
|
|
const CArray2D<sint16> &heightMap = getEditor().getIslandCollision().getHeightMap();
|
|
|
|
|
if (!heightMap.empty())
|
|
|
|
|
{
|
|
|
|
|
nlinfo("okidoi : %d, %d", inter.x, inter.y);
|
|
|
|
|
// if heightmap is present, use it because it gives us more reliable information
|
|
|
|
|
CVector surfPos;
|
|
|
|
|
if (!computeNearestValidSurfaceFromHeightMap(inter.x, inter.y, surfPos)) return InvalidPacsPos;
|
|
|
|
|
static volatile float threshold = 2.f;
|
|
|
|
|
nlinfo("found");
|
|
|
|
|
return (inter - surfPos).norm() < threshold ? ValidPacsPos : InvalidPacsPos;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -601,7 +586,6 @@ CTool::TRayIntersectionType CTool::computeLandscapeRayIntersection(const CWorldV
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
nlinfo("GR");
|
|
|
|
|
// see if pacs collisions are ok at that pos
|
|
|
|
|
NLPACS::UGlobalPosition dummyPos;
|
|
|
|
|
return getPacsType(inter, 2.f, dummyPos);
|
|
|
|
|