Cleanup, externalize mask used to pick center

openmw-39
Aesylwinn 9 years ago
parent a4cc891383
commit 99e9017242

@ -12,8 +12,6 @@
#include <osgUtil/LineSegmentIntersector> #include <osgUtil/LineSegmentIntersector>
#include "mask.hpp"
namespace CSVRender namespace CSVRender
{ {
@ -361,6 +359,7 @@ namespace CSVRender
, mDown(false) , mDown(false)
, mRollLeft(false) , mRollLeft(false)
, mRollRight(false) , mRollRight(false)
, mPickingMask(~0)
, mCenter(0,0,0) , mCenter(0,0,0)
, mDistance(0) , mDistance(0)
, mOrbitSpeed(osg::PI / 4) , mOrbitSpeed(osg::PI / 4)
@ -378,6 +377,11 @@ namespace CSVRender
return mOrbitSpeedMult; return mOrbitSpeedMult;
} }
unsigned int OrbitCameraController::getPickingMask() const
{
return mPickingMask;
}
void OrbitCameraController::setOrbitSpeed(double value) void OrbitCameraController::setOrbitSpeed(double value)
{ {
mOrbitSpeed = value; mOrbitSpeed = value;
@ -388,6 +392,11 @@ namespace CSVRender
mOrbitSpeedMult = value; mOrbitSpeedMult = value;
} }
void OrbitCameraController::setPickingMask(unsigned int value)
{
mPickingMask = value;
}
bool OrbitCameraController::handleKeyEvent(QKeyEvent* event, bool pressed) bool OrbitCameraController::handleKeyEvent(QKeyEvent* event, bool pressed)
{ {
if (!isActive()) if (!isActive())
@ -523,7 +532,7 @@ namespace CSVRender
intersector->setIntersectionLimit(osgUtil::LineSegmentIntersector::LIMIT_NEAREST); intersector->setIntersectionLimit(osgUtil::LineSegmentIntersector::LIMIT_NEAREST);
osgUtil::IntersectionVisitor visitor(intersector); osgUtil::IntersectionVisitor visitor(intersector);
visitor.setTraversalMask(Mask_Reference | Mask_Terrain); visitor.setTraversalMask(mPickingMask);
getCamera()->accept(visitor); getCamera()->accept(visitor);

@ -115,9 +115,11 @@ namespace CSVRender
double getOrbitSpeed() const; double getOrbitSpeed() const;
double getOrbitSpeedMultiplier() const; double getOrbitSpeedMultiplier() const;
unsigned int getPickingMask() const;
void setOrbitSpeed(double value); void setOrbitSpeed(double value);
void setOrbitSpeedMultiplier(double value); void setOrbitSpeedMultiplier(double value);
void setPickingMask(unsigned int value);
bool handleKeyEvent(QKeyEvent* event, bool pressed); bool handleKeyEvent(QKeyEvent* event, bool pressed);
bool handleMouseMoveEvent(std::string mode, int x, int y); bool handleMouseMoveEvent(std::string mode, int x, int y);
@ -138,6 +140,7 @@ namespace CSVRender
bool mInitialized; bool mInitialized;
bool mFast, mLeft, mRight, mUp, mDown, mRollLeft, mRollRight; bool mFast, mLeft, mRight, mUp, mDown, mRollLeft, mRollRight;
unsigned int mPickingMask;
osg::Vec3d mCenter; osg::Vec3d mCenter;
double mDistance; double mDistance;

@ -167,6 +167,7 @@ SceneWidget::SceneWidget(boost::shared_ptr<Resource::ResourceSystem> resourceSys
, mCurrentCamControl(mFreeCamControl.get()) , mCurrentCamControl(mFreeCamControl.get())
, mCamPositionSet(false) , mCamPositionSet(false)
{ {
mOrbitCamControl->setPickingMask(Mask_Reference | Mask_Terrain);
selectNavigationMode("free"); selectNavigationMode("free");
// we handle lighting manually // we handle lighting manually

Loading…
Cancel
Save