Small optimization
parent
e8f813ab38
commit
4731334605
|
@ -860,7 +860,7 @@ void Renderer::addAnnotation(vector<Annotation>& annotations,
|
|||
{
|
||||
GLint view[4] = { 0, 0, windowWidth, windowHeight };
|
||||
Vector3f win;
|
||||
if (Project(pos, m_modelMatrix, m_projMatrix, view, win))
|
||||
if (Project(pos, m_MVPMatrix, view, win))
|
||||
{
|
||||
float depth = pos.x() * m_modelMatrix(2, 0) +
|
||||
pos.y() * m_modelMatrix(2, 1) +
|
||||
|
@ -1577,6 +1577,7 @@ void Renderer::draw(const Observer& observer,
|
|||
// We'll usethem for positioning star and planet labels.
|
||||
m_projMatrix = Perspective(fov, getAspectRatio(), NEAR_DIST, FAR_DIST);
|
||||
m_modelMatrix = Affine3f(getCameraOrientation()).matrix();
|
||||
m_MVPMatrix = m_projMatrix * m_modelMatrix;
|
||||
|
||||
depthSortedAnnotations.clear();
|
||||
foregroundAnnotations.clear();
|
||||
|
@ -5017,10 +5018,10 @@ void Renderer::markersToAnnotations(const MarkerList& markers,
|
|||
{
|
||||
Vector3d offset = marker.position(jd).offsetFromKm(cameraPosition);
|
||||
|
||||
double distance = offset.norm();
|
||||
// Only render those markers that lie withing the field of view.
|
||||
if ((offset.dot(viewVector)) > cosViewConeAngle * offset.norm())
|
||||
if ((offset.dot(viewVector)) > cosViewConeAngle * distance)
|
||||
{
|
||||
double distance = offset.norm();
|
||||
float symbolSize = 0.0f;
|
||||
if (marker.sizing() == DistanceBasedSize)
|
||||
{
|
||||
|
|
|
@ -454,9 +454,6 @@ class Renderer
|
|||
|
||||
private:
|
||||
void setFieldOfView(float);
|
||||
void renderStars(const StarDatabase& starDB,
|
||||
float faintestVisible,
|
||||
const Observer& observer);
|
||||
void renderPointStars(const StarDatabase& starDB,
|
||||
float faintestVisible,
|
||||
const Observer& observer);
|
||||
|
@ -724,6 +721,7 @@ class Renderer
|
|||
|
||||
Eigen::Matrix4f m_modelMatrix;
|
||||
Eigen::Matrix4f m_projMatrix;
|
||||
Eigen::Matrix4f m_MVPMatrix;
|
||||
Eigen::Matrix4f m_orthoProjMatrix;
|
||||
|
||||
bool useCompressedTextures{ false };
|
||||
|
|
|
@ -66,13 +66,12 @@ LookAt(const Eigen::Matrix<T, 3, 1>& from, const Eigen::Matrix<T, 3, 1>& to, con
|
|||
*/
|
||||
template<class T> bool
|
||||
Project(const Eigen::Matrix<T, 3, 1>& from,
|
||||
const Eigen::Matrix<T, 4, 4>& modelViewMatrix,
|
||||
const Eigen::Matrix<T, 4, 4>& projMatrix,
|
||||
const Eigen::Matrix<T, 4, 4>& modelViewProjectionMatrix,
|
||||
const int viewport[4],
|
||||
Eigen::Matrix<T, 3, 1>& to)
|
||||
{
|
||||
Eigen::Matrix<T, 4, 1> in(from.x(), from.y(), from.z(), T(1.0));
|
||||
Eigen::Matrix<T, 4, 1> out = projMatrix * modelViewMatrix * in;
|
||||
Eigen::Matrix<T, 4, 1> out = modelViewProjectionMatrix * in;
|
||||
if (out.w() == T(0.0))
|
||||
return false;
|
||||
|
||||
|
@ -87,6 +86,18 @@ Project(const Eigen::Matrix<T, 3, 1>& from,
|
|||
return true;
|
||||
}
|
||||
|
||||
template<class T> bool
|
||||
Project(const Eigen::Matrix<T, 3, 1>& from,
|
||||
const Eigen::Matrix<T, 4, 4>& modelViewMatrix,
|
||||
const Eigen::Matrix<T, 4, 4>& projMatrix,
|
||||
const int viewport[4],
|
||||
Eigen::Matrix<T, 3, 1>& to)
|
||||
{
|
||||
Eigen::Matrix<T, 4, 4> m = projMatrix * modelViewMatrix;
|
||||
return Project(from, m, viewport, to);
|
||||
}
|
||||
|
||||
|
||||
/*! Return an perspective projection matrix
|
||||
*/
|
||||
template<class T> Eigen::Matrix<T, 4, 4>
|
||||
|
|
Loading…
Reference in New Issue