|
|
@ -40,7 +40,6 @@ MapView::MapView()
|
|
|
|
m_lockedFirstVisibleFloor = -1;
|
|
|
|
m_lockedFirstVisibleFloor = -1;
|
|
|
|
m_cachedFirstVisibleFloor = 0;
|
|
|
|
m_cachedFirstVisibleFloor = 0;
|
|
|
|
m_cachedLastVisibleFloor = 7;
|
|
|
|
m_cachedLastVisibleFloor = 7;
|
|
|
|
m_customCameraPosition.z = 7;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Size frameBufferSize(std::min(g_graphics.getMaxTextureSize(), (int)DEFAULT_FRAMBUFFER_WIDTH),
|
|
|
|
Size frameBufferSize(std::min(g_graphics.getMaxTextureSize(), (int)DEFAULT_FRAMBUFFER_WIDTH),
|
|
|
|
std::min(g_graphics.getMaxTextureSize(), (int)DEFAULT_FRAMBUFFER_HEIGHT));
|
|
|
|
std::min(g_graphics.getMaxTextureSize(), (int)DEFAULT_FRAMBUFFER_HEIGHT));
|
|
|
@ -472,50 +471,53 @@ int MapView::calcFirstVisibleFloor()
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
Position cameraPosition = getCameraPosition();
|
|
|
|
Position cameraPosition = getCameraPosition();
|
|
|
|
|
|
|
|
|
|
|
|
// avoid rendering multifloors in far views
|
|
|
|
// this could happens if the player is not known yet
|
|
|
|
if(m_viewRange >= FAR_VIEW) {
|
|
|
|
if(cameraPosition.isValid()) {
|
|
|
|
z = cameraPosition.z;
|
|
|
|
// avoid rendering multifloors in far views
|
|
|
|
} else {
|
|
|
|
if(m_viewRange >= FAR_VIEW) {
|
|
|
|
// if nothing is limiting the view, the first visible floor is 0
|
|
|
|
z = cameraPosition.z;
|
|
|
|
int firstFloor = 0;
|
|
|
|
} else {
|
|
|
|
|
|
|
|
// if nothing is limiting the view, the first visible floor is 0
|
|
|
|
// limits to underground floors while under sea level
|
|
|
|
int firstFloor = 0;
|
|
|
|
if(cameraPosition.z > Otc::SEA_FLOOR)
|
|
|
|
|
|
|
|
firstFloor = std::max(cameraPosition.z - Otc::AWARE_UNDEGROUND_FLOOR_RANGE, (int)Otc::UNDERGROUND_FLOOR);
|
|
|
|
// limits to underground floors while under sea level
|
|
|
|
|
|
|
|
if(cameraPosition.z > Otc::SEA_FLOOR)
|
|
|
|
// loop in 3x3 tiles around the camera
|
|
|
|
firstFloor = std::max(cameraPosition.z - Otc::AWARE_UNDEGROUND_FLOOR_RANGE, (int)Otc::UNDERGROUND_FLOOR);
|
|
|
|
for(int ix = -1; ix <= 1 && firstFloor < cameraPosition.z; ++ix) {
|
|
|
|
|
|
|
|
for(int iy = -1; iy <= 1 && firstFloor < cameraPosition.z; ++iy) {
|
|
|
|
// loop in 3x3 tiles around the camera
|
|
|
|
Position pos = cameraPosition.translated(ix, iy);
|
|
|
|
for(int ix = -1; ix <= 1 && firstFloor < cameraPosition.z; ++ix) {
|
|
|
|
|
|
|
|
for(int iy = -1; iy <= 1 && firstFloor < cameraPosition.z; ++iy) {
|
|
|
|
// process tiles that we can look through, e.g. windows, doors
|
|
|
|
Position pos = cameraPosition.translated(ix, iy);
|
|
|
|
if((ix == 0 && iy == 0) || (/*(std::abs(ix) != std::abs(iy)) && */g_map.isLookPossible(pos))) {
|
|
|
|
|
|
|
|
Position upperPos = pos;
|
|
|
|
// process tiles that we can look through, e.g. windows, doors
|
|
|
|
Position coveredPos = pos;
|
|
|
|
if((ix == 0 && iy == 0) || (/*(std::abs(ix) != std::abs(iy)) && */g_map.isLookPossible(pos))) {
|
|
|
|
|
|
|
|
Position upperPos = pos;
|
|
|
|
while(coveredPos.coveredUp() && upperPos.up() && upperPos.z >= firstFloor) {
|
|
|
|
Position coveredPos = pos;
|
|
|
|
// check tiles physically above
|
|
|
|
|
|
|
|
TilePtr tile = g_map.getTile(upperPos);
|
|
|
|
while(coveredPos.coveredUp() && upperPos.up() && upperPos.z >= firstFloor) {
|
|
|
|
if(tile && tile->limitsFloorsView()) {
|
|
|
|
// check tiles physically above
|
|
|
|
firstFloor = upperPos.z + 1;
|
|
|
|
TilePtr tile = g_map.getTile(upperPos);
|
|
|
|
break;
|
|
|
|
if(tile && tile->limitsFloorsView()) {
|
|
|
|
}
|
|
|
|
firstFloor = upperPos.z + 1;
|
|
|
|
|
|
|
|
break;
|
|
|
|
// check tiles geometrically above
|
|
|
|
}
|
|
|
|
tile = g_map.getTile(coveredPos);
|
|
|
|
|
|
|
|
if(tile && tile->limitsFloorsView()) {
|
|
|
|
// check tiles geometrically above
|
|
|
|
firstFloor = coveredPos.z + 1;
|
|
|
|
tile = g_map.getTile(coveredPos);
|
|
|
|
break;
|
|
|
|
if(tile && tile->limitsFloorsView()) {
|
|
|
|
|
|
|
|
firstFloor = coveredPos.z + 1;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
z = firstFloor;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
z = firstFloor;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// just ensure the that the floor is in the valid range
|
|
|
|
z = std::min(std::max(z, 0), (int)Otc::MAX_Z);
|
|
|
|
z = std::min(std::max(z, 0), (int)Otc::MAX_Z);
|
|
|
|
return z;
|
|
|
|
return z;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -525,17 +527,21 @@ int MapView::calcLastVisibleFloor()
|
|
|
|
int z = 7;
|
|
|
|
int z = 7;
|
|
|
|
|
|
|
|
|
|
|
|
Position cameraPosition = getCameraPosition();
|
|
|
|
Position cameraPosition = getCameraPosition();
|
|
|
|
// avoid rendering multifloors in far views
|
|
|
|
// this could happens if the player is not known yet
|
|
|
|
if(m_viewRange >= FAR_VIEW) {
|
|
|
|
if(cameraPosition.isValid()) {
|
|
|
|
z = cameraPosition.z;
|
|
|
|
// avoid rendering multifloors in far views
|
|
|
|
} else {
|
|
|
|
if(m_viewRange >= FAR_VIEW) {
|
|
|
|
// view only underground floors when below sea level
|
|
|
|
z = cameraPosition.z;
|
|
|
|
if(cameraPosition.z > Otc::SEA_FLOOR)
|
|
|
|
} else {
|
|
|
|
z = cameraPosition.z + Otc::AWARE_UNDEGROUND_FLOOR_RANGE;
|
|
|
|
// view only underground floors when below sea level
|
|
|
|
else
|
|
|
|
if(cameraPosition.z > Otc::SEA_FLOOR)
|
|
|
|
z = Otc::SEA_FLOOR;
|
|
|
|
z = cameraPosition.z + Otc::AWARE_UNDEGROUND_FLOOR_RANGE;
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
z = Otc::SEA_FLOOR;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// just ensure the that the floor is in the valid range
|
|
|
|
z = std::min(std::max(z, 0), (int)Otc::MAX_Z);
|
|
|
|
z = std::min(std::max(z, 0), (int)Otc::MAX_Z);
|
|
|
|
return z;
|
|
|
|
return z;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -553,6 +559,10 @@ TilePtr MapView::getTile(const Point& mousePos, const Rect& mapRect)
|
|
|
|
Size visibleSize = getVisibleSize();
|
|
|
|
Size visibleSize = getVisibleSize();
|
|
|
|
Position cameraPosition = getCameraPosition();
|
|
|
|
Position cameraPosition = getCameraPosition();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if we have no camera, its impossible to get the tile
|
|
|
|
|
|
|
|
if(!cameraPosition.isValid())
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
|
|
|
|
|
|
|
|
float scaleFactor = m_tileSize / (float)Otc::TILE_PIXELS;
|
|
|
|
float scaleFactor = m_tileSize / (float)Otc::TILE_PIXELS;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|