Commit 5adfda9b authored by Alexander Wiebel's avatar Alexander Wiebel
Browse files

[ADD] contains information about normals now

[ADD] allow to set modifier key
[CHANGE] added consts to functions
parent 21043caa
......@@ -29,6 +29,7 @@
#include <utility>
#include "../math/WPosition.h"
#include "../math/WVector3D.h"
/**
* Encapsulates info for pick action.
......@@ -54,8 +55,13 @@ public:
* \param pickPosition position where object was hit
* \param pixelCoords pixel coordinates fo the mouse
* \param modKey relevant modifier key pressed during the pick
* \param pickNormal normal at position where object was hit. (0,0,0) means not set.
*/
inline WPickInfo( std::string name, wmath::WPosition pickPosition, std::pair< float, float > pixelCoords, modifierKey modKey );
inline WPickInfo( std::string name,
wmath::WPosition pickPosition,
std::pair< float, float > pixelCoords,
modifierKey modKey,
wmath::WVector3D pickNormal = wmath::WVector3D() );
/**
* Creates an object with the empty name, zero position and no modkey.
......@@ -65,34 +71,45 @@ public:
/**
* Get the modifier key associated with the pick
*/
inline modifierKey getModifierKey();
inline modifierKey getModifierKey() const;
/**
* Set the modifier key associated with the pick
* \param modKey new modifier key
*/
inline void setModifierKey( const modifierKey& modKey );
/**
* Get name of picked object.
*/
inline std::string getName();
inline std::string getName() const;
/**
* Get position where object was hit.
*/
inline wmath::WPosition getPickPosition();
inline wmath::WPosition getPickPosition() const;
/**
* Get normal at position where object was hit.
*/
inline wmath::WVector3D getPickNormal() const;
/**
* Get pixel coordinates where object was hit.
*/
inline std::pair< float, float > getPickPixelPosition();
inline std::pair< float, float > getPickPixelPosition() const;
/**
* Tests two pick infos for equality
* \param rhs right hand side of comparison
*/
inline bool operator==( WPickInfo rhs );
inline bool operator==( WPickInfo rhs ) const;
/**
* Tests two pick infos for inequality
* \param rhs right hand side of comparison
*/
inline bool operator!=( WPickInfo rhs );
inline bool operator!=( WPickInfo rhs ) const;
protected:
private:
......@@ -101,13 +118,19 @@ private:
wmath::WPosition m_pickPosition; //!< position where object was hit.
std::pair< float, float > m_pixelCoords; //!< Pixel coordinates of the mouse.
modifierKey m_modKey; //!< modifier key associated with the pick
wmath::WVector3D m_pickNormal; //!< normal at position where object was hit.
};
WPickInfo::WPickInfo( std::string name, wmath::WPosition pickPosition, std::pair< float, float > pixelCoords, modifierKey modKey ) :
WPickInfo::WPickInfo( std::string name,
wmath::WPosition pickPosition,
std::pair< float, float > pixelCoords,
modifierKey modKey,
wmath::WVector3D pickNormal ) :
m_name( name ),
m_pickPosition( pickPosition ),
m_pixelCoords( pixelCoords ),
m_modKey( modKey )
m_modKey( modKey ),
m_pickNormal( pickNormal )
{
}
......@@ -119,34 +142,45 @@ WPickInfo::WPickInfo() :
{
}
WPickInfo::modifierKey WPickInfo::getModifierKey()
WPickInfo::modifierKey WPickInfo::getModifierKey() const
{
return m_modKey;
}
std::string WPickInfo::getName()
void WPickInfo::setModifierKey( const modifierKey& modKey )
{
m_modKey = modKey;
}
std::string WPickInfo::getName() const
{
return m_name;
}
wmath::WPosition WPickInfo::getPickPosition()
wmath::WPosition WPickInfo::getPickPosition() const
{
return m_pickPosition;
}
std::pair< float, float > WPickInfo::getPickPixelPosition()
wmath::WVector3D WPickInfo::getPickNormal() const
{
return m_pickNormal;
}
std::pair< float, float > WPickInfo::getPickPixelPosition() const
{
return m_pixelCoords;
}
inline bool WPickInfo::operator==( WPickInfo rhs )
inline bool WPickInfo::operator==( WPickInfo rhs ) const
{
return ( this->m_name == rhs.m_name
&& this->m_pickPosition == rhs.m_pickPosition
&& this->m_modKey == rhs.m_modKey );
}
inline bool WPickInfo::operator!=( WPickInfo rhs )
inline bool WPickInfo::operator!=( WPickInfo rhs ) const
{
return !( *this == rhs );
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment