Skip to content

Commit

Permalink
Changed the preprocessor directives
Browse files Browse the repository at this point in the history
Signed-off-by: Patryk Skowroński <[email protected]>
  • Loading branch information
Patryk Skowroński committed Jul 5, 2023
1 parent c6922cd commit 7cc4d16
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 17 deletions.
3 changes: 0 additions & 3 deletions avogadro/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@
#include "renderingdialog.h"
#include "tooltipfilter.h"
#include "viewfactory.h"

#ifdef _3DCONNEXION
#include "tdxcontroller.h"
#endif

#include <avogadro/core/elements.h>
#include <avogadro/io/cjsonformat.h>
Expand Down
2 changes: 0 additions & 2 deletions avogadro/menubuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,10 @@ class MenuBuilder : public QObject
*/
void print();

#ifdef _3DCONNEXION
/**
* @brief Get the map of string to action lists.
*/
const QMap<QString, QList<QAction*>> &getMenuActions() const { return m_menuActions; };
#endif

private:
/** A map of string to action lists. */
Expand Down
29 changes: 19 additions & 10 deletions avogadro/tdxcontroller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,10 +423,16 @@ long Avogadro::TDxController::GetHitLookAt(navlib::point_t &position) const
origin = transform * Eigen::Vector4f(0., 0., 0., 1.);
origin /= origin.w();

distance = m_pGLRenderer->scene().getHitDistance(
Eigen::Vector3f(origin.x(), origin.y(), origin.z()),
Eigen::Vector3f(m_lookDirection.x, m_lookDirection.y, m_lookDirection.z),
rayLength);
auto rayOrigin = Eigen::Vector3f(origin.x(), origin.y(), origin.z());
auto rayDirection = Eigen::Vector3f(m_lookDirection.x,
m_lookDirection.y,
m_lookDirection.z);

distance = m_pGLRenderer->hit(
rayOrigin,
rayOrigin + rayLength * rayDirection,
rayDirection);

} else {

Eigen::Vector4f originBuffer = Eigen::Vector4f::Zero();
Expand All @@ -439,12 +445,15 @@ long Avogadro::TDxController::GetHitLookAt(navlib::point_t &position) const
originBuffer = transform * Eigen::Vector4f(x, y, 0., 1.);
originBuffer /= originBuffer.w();

float buffer = m_pGLRenderer->scene().getHitDistance(
Eigen::Vector3f(originBuffer.x(), originBuffer.y(), originBuffer.z()),
Eigen::Vector3f(m_lookDirection.x,
m_lookDirection.y,
m_lookDirection.z),
rayLength);
auto rayOrigin = Eigen::Vector3f(originBuffer.x(), originBuffer.y(), originBuffer.z());
auto rayDirection = Eigen::Vector3f(m_lookDirection.x,
m_lookDirection.y,
m_lookDirection.z);

float buffer = m_pGLRenderer->hit(
rayOrigin,
rayOrigin + rayLength * rayDirection,
rayDirection);

if (buffer > 0.0f && buffer < distance) {
origin = originBuffer;
Expand Down
9 changes: 7 additions & 2 deletions avogadro/tdxcontroller.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
This source code is released under the 3-Clause BSD License, (see "LICENSE").
******************************************************************************/

#pragma once
#ifdef _3DCONNEXION
#ifndef AVOGADRO_TDXCONTROLLER_H
#define AVOGADRO_TDXCONTROLLER_H

#include <SpaceMouse/CImage.hpp>
#include <SpaceMouse/CNavigation3D.hpp>

Expand Down Expand Up @@ -153,5 +156,7 @@ class TDxController : private TDx::SpaceMouse::Navigation3D::CNavigation3D, priv
virtual long SetActiveCommand(std::string commandId) override;
virtual long SetTransaction(long value) override;
};
}

}
#endif // ! AVOGADRO_TDXCONTROLLER_H
#endif // _3DCONNEXION

0 comments on commit 7cc4d16

Please sign in to comment.