mirror of
https://codeberg.org/comaps/comaps
synced 2025-12-20 13:23:59 +00:00
Organic Maps sources as of 02.04.2025 (fad26bbf22ac3da75e01e62aa01e5c8e11861005)
To expand with full Organic Maps and Maps.ME commits history run: git remote add om-historic [om-historic.git repo url] git fetch --tags om-historic git replace squashed-history historic-commits
This commit is contained in:
34
drape/utils/projection.cpp
Normal file
34
drape/utils/projection.cpp
Normal file
@@ -0,0 +1,34 @@
|
||||
#include "drape/utils/projection.hpp"
|
||||
|
||||
namespace dp
|
||||
{
|
||||
std::array<float, 16> MakeProjection(dp::ApiVersion apiVersion, float left, float right,
|
||||
float bottom, float top)
|
||||
{
|
||||
std::array<float, 16> result = {};
|
||||
|
||||
// Projection matrix is calculated for [-1;1] depth-space, in some APIs (e.g. Metal)
|
||||
// depth-space is [0;1], so we have to remap projection matrix.
|
||||
float depthScale = 1.0f;
|
||||
float depthOffset = 0.0f;
|
||||
if (apiVersion == dp::ApiVersion::Metal)
|
||||
{
|
||||
depthScale = 0.5f;
|
||||
depthOffset = 0.5f;
|
||||
}
|
||||
|
||||
float const width = right - left;
|
||||
float const height = top - bottom;
|
||||
float const depth = kMaxDepth - kMinDepth;
|
||||
|
||||
result[0] = 2.0f / width;
|
||||
result[3] = -(right + left) / width;
|
||||
result[5] = 2.0f / height;
|
||||
result[7] = -(top + bottom) / height;
|
||||
result[10] = -2.0f * depthScale / depth;
|
||||
result[11] = depthOffset - (kMaxDepth + kMinDepth) / depth;
|
||||
result[15] = 1.0;
|
||||
|
||||
return result;
|
||||
}
|
||||
} // namespace dp
|
||||
Reference in New Issue
Block a user