forked from mirror/openmw-tes3mp
Finally re-added rendering stats, refactored some functions
to better fit new input structure, removed unneeded shortcut declarations in headers, and changed the cell marker interaction to use primary/secondary select instead of shift + primary/secondary edit.
This commit is contained in:
parent
faa84e0a35
commit
1b5273f2b7
9 changed files with 113 additions and 139 deletions
|
@ -259,6 +259,7 @@ void CSMPrefs::State::declare()
|
|||
QKeySequence(Qt::ControlModifier | (int)Qt::MiddleButton));
|
||||
declareShortcut ("scene-edit-abort", "Scene editor abort key", QKeySequence(Qt::Key_Escape));
|
||||
declareShortcut ("scene-focus-toolbar", "Change focus in scene editor", QKeySequence(Qt::Key_T));
|
||||
declareShortcut ("scene-render-stats", "Displays debug rendering stats", QKeySequence(Qt::Key_F3));
|
||||
}
|
||||
|
||||
void CSMPrefs::State::declareCategory (const std::string& key)
|
||||
|
|
|
@ -268,10 +268,10 @@ namespace CSVRender
|
|||
mLockUpright = false;
|
||||
}
|
||||
|
||||
bool FreeCameraController::handleMouseMoveEvent(std::string mode, int x, int y)
|
||||
void FreeCameraController::handleMouseMoveEvent(int x, int y)
|
||||
{
|
||||
if (!isActive())
|
||||
return false;
|
||||
return;
|
||||
|
||||
if (mNaviPrimary)
|
||||
{
|
||||
|
@ -287,16 +287,14 @@ namespace CSVRender
|
|||
|
||||
translate(movement);
|
||||
}
|
||||
else if (mode == "t-navi")
|
||||
{
|
||||
translate(LocalForward * x * (mFast ? getWheelMovementMultiplier() : 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
void FreeCameraController::handleMouseScrollEvent(int x)
|
||||
{
|
||||
if (!isActive())
|
||||
return;
|
||||
|
||||
translate(LocalForward * x * (mFast ? getWheelMovementMultiplier() : 1));
|
||||
}
|
||||
|
||||
void FreeCameraController::update(double dt)
|
||||
|
@ -336,17 +334,6 @@ namespace CSVRender
|
|||
getCamera()->getViewMatrix().orthoNormal(getCamera()->getViewMatrix());
|
||||
}
|
||||
|
||||
void FreeCameraController::resetInput()
|
||||
{
|
||||
mFast = false;
|
||||
mLeft = false;
|
||||
mRight = false;
|
||||
mForward = false;
|
||||
mBackward = false;
|
||||
mRollLeft = false;
|
||||
mRollRight = false;
|
||||
}
|
||||
|
||||
void FreeCameraController::yaw(double value)
|
||||
{
|
||||
getCamera()->getViewMatrix() *= osg::Matrixd::rotate(value, LocalUp);
|
||||
|
@ -555,10 +542,10 @@ namespace CSVRender
|
|||
mPickingMask = value;
|
||||
}
|
||||
|
||||
bool OrbitCameraController::handleMouseMoveEvent(std::string mode, int x, int y)
|
||||
void OrbitCameraController::handleMouseMoveEvent(int x, int y)
|
||||
{
|
||||
if (!isActive())
|
||||
return false;
|
||||
return;
|
||||
|
||||
if (!mInitialized)
|
||||
initialize();
|
||||
|
@ -577,16 +564,14 @@ namespace CSVRender
|
|||
|
||||
translate(movement);
|
||||
}
|
||||
else if (mode == "t-navi")
|
||||
{
|
||||
zoom(-x * (mFast ? getWheelMovementMultiplier() : 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
void OrbitCameraController::handleMouseScrollEvent(int x)
|
||||
{
|
||||
if (!isActive())
|
||||
return;
|
||||
|
||||
zoom(-x * (mFast ? getWheelMovementMultiplier() : 1));
|
||||
}
|
||||
|
||||
void OrbitCameraController::update(double dt)
|
||||
|
@ -620,17 +605,6 @@ namespace CSVRender
|
|||
getCamera()->getViewMatrix().orthoNormal(getCamera()->getViewMatrix());
|
||||
}
|
||||
|
||||
void OrbitCameraController::resetInput()
|
||||
{
|
||||
mFast = false;
|
||||
mLeft = false;
|
||||
mRight =false;
|
||||
mUp = false;
|
||||
mDown = false;
|
||||
mRollLeft = false;
|
||||
mRollRight = false;
|
||||
}
|
||||
|
||||
void OrbitCameraController::onActivate()
|
||||
{
|
||||
mInitialized = false;
|
||||
|
|
|
@ -57,12 +57,11 @@ namespace CSVRender
|
|||
// moves the camera to an intelligent position
|
||||
void setup(osg::Group* root, unsigned int mask, const osg::Vec3d& up);
|
||||
|
||||
virtual bool handleMouseMoveEvent(std::string mode, int x, int y) = 0;
|
||||
virtual void handleMouseMoveEvent(int x, int y) = 0;
|
||||
virtual void handleMouseScrollEvent(int x) = 0;
|
||||
|
||||
virtual void update(double dt) = 0;
|
||||
|
||||
virtual void resetInput() = 0;
|
||||
|
||||
protected:
|
||||
|
||||
virtual void onActivate(){}
|
||||
|
@ -96,12 +95,11 @@ namespace CSVRender
|
|||
void fixUpAxis(const osg::Vec3d& up);
|
||||
void unfixUpAxis();
|
||||
|
||||
bool handleMouseMoveEvent(std::string mode, int x, int y);
|
||||
void handleMouseMoveEvent(int x, int y);
|
||||
void handleMouseScrollEvent(int x);
|
||||
|
||||
void update(double dt);
|
||||
|
||||
void resetInput();
|
||||
|
||||
private:
|
||||
|
||||
void yaw(double value);
|
||||
|
@ -151,12 +149,11 @@ namespace CSVRender
|
|||
void setOrbitSpeedMultiplier(double value);
|
||||
void setPickingMask(unsigned int value);
|
||||
|
||||
bool handleMouseMoveEvent(std::string mode, int x, int y);
|
||||
void handleMouseMoveEvent(int x, int y);
|
||||
void handleMouseScrollEvent(int x);
|
||||
|
||||
void update(double dt);
|
||||
|
||||
void resetInput();
|
||||
|
||||
private:
|
||||
|
||||
void onActivate();
|
||||
|
|
|
@ -142,74 +142,71 @@ void CSVRender::PagedWorldspaceWidget::addEditModeSelectorButtons (
|
|||
"terrain-move");
|
||||
}
|
||||
|
||||
void CSVRender::PagedWorldspaceWidget::handleMouseClick (const WorldspaceHitResult& hit, InteractionType type,
|
||||
bool shift)
|
||||
void CSVRender::PagedWorldspaceWidget::handleInteractionPress (const WorldspaceHitResult& hit, InteractionType type)
|
||||
{
|
||||
if (hit.tag && hit.tag->getMask()==Mask_CellArrow)
|
||||
{
|
||||
if (type == InteractionType_PrimaryEdit || type == InteractionType_SecondaryEdit)
|
||||
if (CellArrowTag *cellArrowTag = dynamic_cast<CSVRender::CellArrowTag *> (hit.tag.get()))
|
||||
{
|
||||
if (CellArrowTag *cellArrowTag = dynamic_cast<CSVRender::CellArrowTag *> (hit.tag.get()))
|
||||
CellArrow *arrow = cellArrowTag->getCellArrow();
|
||||
|
||||
CSMWorld::CellCoordinates coordinates = arrow->getCoordinates();
|
||||
|
||||
CellArrow::Direction direction = arrow->getDirection();
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
|
||||
switch (direction)
|
||||
{
|
||||
CellArrow *arrow = cellArrowTag->getCellArrow();
|
||||
case CellArrow::Direction_North: y = 1; break;
|
||||
case CellArrow::Direction_West: x = -1; break;
|
||||
case CellArrow::Direction_South: y = -1; break;
|
||||
case CellArrow::Direction_East: x = 1; break;
|
||||
}
|
||||
|
||||
CSMWorld::CellCoordinates coordinates = arrow->getCoordinates();
|
||||
bool modified = false;
|
||||
|
||||
CellArrow::Direction direction = arrow->getDirection();
|
||||
if (type == InteractionType_PrimarySelect)
|
||||
{
|
||||
addCellSelection (x, y);
|
||||
modified = true;
|
||||
}
|
||||
else if (type == InteractionType_SecondarySelect)
|
||||
{
|
||||
moveCellSelection (x, y);
|
||||
modified = true;
|
||||
}
|
||||
else // Primary/SecondaryEdit
|
||||
{
|
||||
CSMWorld::CellCoordinates newCoordinates = coordinates.move (x, y);
|
||||
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
|
||||
switch (direction)
|
||||
if (mCells.find (newCoordinates)==mCells.end())
|
||||
{
|
||||
case CellArrow::Direction_North: y = 1; break;
|
||||
case CellArrow::Direction_West: x = -1; break;
|
||||
case CellArrow::Direction_South: y = -1; break;
|
||||
case CellArrow::Direction_East: x = 1; break;
|
||||
}
|
||||
|
||||
bool modified = false;
|
||||
|
||||
if (shift)
|
||||
{
|
||||
if (type == InteractionType_PrimaryEdit)
|
||||
addCellSelection (x, y);
|
||||
else
|
||||
moveCellSelection (x, y);
|
||||
|
||||
addCellToScene (newCoordinates);
|
||||
mSelection.add (newCoordinates);
|
||||
modified = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
CSMWorld::CellCoordinates newCoordinates = coordinates.move (x, y);
|
||||
|
||||
if (mCells.find (newCoordinates)==mCells.end())
|
||||
if (type == InteractionType_SecondaryEdit)
|
||||
{
|
||||
if (mCells.find (coordinates)!=mCells.end())
|
||||
{
|
||||
addCellToScene (newCoordinates);
|
||||
mSelection.add (newCoordinates);
|
||||
removeCellFromScene (coordinates);
|
||||
mSelection.remove (coordinates);
|
||||
modified = true;
|
||||
}
|
||||
|
||||
if (type == InteractionType_SecondaryEdit)
|
||||
{
|
||||
if (mCells.find (coordinates)!=mCells.end())
|
||||
{
|
||||
removeCellFromScene (coordinates);
|
||||
mSelection.remove (coordinates);
|
||||
modified = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (modified)
|
||||
adjustCells();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (modified)
|
||||
adjustCells();
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
WorldspaceWidget::handleMouseClick (hit, type, shift);
|
||||
WorldspaceWidget::handleInteractionPress (hit, type);
|
||||
}
|
||||
|
||||
void CSVRender::PagedWorldspaceWidget::referenceableDataChanged (const QModelIndex& topLeft,
|
||||
|
|
|
@ -138,7 +138,7 @@ namespace CSVRender
|
|||
|
||||
virtual void addEditModeSelectorButtons (CSVWidget::SceneToolMode *tool);
|
||||
|
||||
virtual void handleMouseClick (const WorldspaceHitResult& hit, InteractionType type, bool shift);
|
||||
virtual void handleInteractionPress (const WorldspaceHitResult& hit, InteractionType type);
|
||||
|
||||
signals:
|
||||
|
||||
|
|
|
@ -107,6 +107,15 @@ osg::Camera *RenderWidget::getCamera()
|
|||
return mView->getCamera();
|
||||
}
|
||||
|
||||
void RenderWidget::toggleRenderStats()
|
||||
{
|
||||
osgViewer::GraphicsWindow* window =
|
||||
static_cast<osgViewer::GraphicsWindow*>(mView->getCamera()->getGraphicsContext());
|
||||
|
||||
window->getEventQueue()->keyPress(osgGA::GUIEventAdapter::KEY_S);
|
||||
window->getEventQueue()->keyRelease(osgGA::GUIEventAdapter::KEY_S);
|
||||
}
|
||||
|
||||
|
||||
// --------------------------------------------------
|
||||
|
||||
|
@ -182,10 +191,6 @@ SceneWidget::SceneWidget(boost::shared_ptr<Resource::ResourceSystem> resourceSys
|
|||
setMouseTracking(true);
|
||||
setFocusPolicy(Qt::ClickFocus);
|
||||
|
||||
mFocusToolbarShortcut = new CSMPrefs::Shortcut("scene-focus-toolbar", this);
|
||||
mShortcutHandler->addShortcut(mFocusToolbarShortcut);
|
||||
connect(mFocusToolbarShortcut, SIGNAL(activated()), this, SIGNAL(focusToolbarRequest()));
|
||||
|
||||
connect (&CSMPrefs::State::get(), SIGNAL (settingChanged (const CSMPrefs::Setting *)),
|
||||
this, SLOT (settingChanged (const CSMPrefs::Setting *)));
|
||||
|
||||
|
@ -197,6 +202,15 @@ SceneWidget::SceneWidget(boost::shared_ptr<Resource::ResourceSystem> resourceSys
|
|||
}
|
||||
|
||||
connect (&CompositeViewer::get(), SIGNAL (simulationUpdated(double)), this, SLOT (update(double)));
|
||||
|
||||
// Shortcuts
|
||||
CSMPrefs::Shortcut* focusToolbarShortcut = new CSMPrefs::Shortcut("scene-focus-toolbar", this);
|
||||
mShortcutHandler->addShortcut(focusToolbarShortcut);
|
||||
connect(focusToolbarShortcut, SIGNAL(activated()), this, SIGNAL(focusToolbarRequest()));
|
||||
|
||||
CSMPrefs::Shortcut* renderStatsShortcut = new CSMPrefs::Shortcut("scene-render-stats", this);
|
||||
mShortcutHandler->addShortcut(renderStatsShortcut);
|
||||
connect(renderStatsShortcut, SIGNAL(activated()), this, SLOT(toggleRenderStats()));
|
||||
}
|
||||
|
||||
SceneWidget::~SceneWidget()
|
||||
|
@ -280,7 +294,7 @@ void SceneWidget::setDefaultAmbient (const osg::Vec4f& colour)
|
|||
|
||||
void SceneWidget::mouseMoveEvent (QMouseEvent *event)
|
||||
{
|
||||
mCurrentCamControl->handleMouseMoveEvent("TODO", event->x() - mPrevMouseX, event->y() - mPrevMouseY);
|
||||
mCurrentCamControl->handleMouseMoveEvent(event->x() - mPrevMouseX, event->y() - mPrevMouseY);
|
||||
|
||||
mPrevMouseX = event->x();
|
||||
mPrevMouseY = event->y();
|
||||
|
@ -288,7 +302,7 @@ void SceneWidget::mouseMoveEvent (QMouseEvent *event)
|
|||
|
||||
void SceneWidget::wheelEvent(QWheelEvent *event)
|
||||
{
|
||||
mCurrentCamControl->handleMouseMoveEvent("t-navi", event->delta(), 0);
|
||||
mCurrentCamControl->handleMouseScrollEvent(event->delta());
|
||||
}
|
||||
|
||||
void SceneWidget::update(double dt)
|
||||
|
|
|
@ -69,18 +69,19 @@ namespace CSVRender
|
|||
osg::ref_ptr<osg::Group> mRootNode;
|
||||
|
||||
QTimer mTimer;
|
||||
|
||||
protected slots:
|
||||
|
||||
void toggleRenderStats();
|
||||
};
|
||||
|
||||
/// Extension of RenderWidget to support lighting mode selection & toolbar
|
||||
class SceneWidget : public RenderWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
SceneWidget(boost::shared_ptr<Resource::ResourceSystem> resourceSystem, QWidget* parent = 0,
|
||||
Qt::WindowFlags f = 0, bool retrieveInput = true);
|
||||
|
||||
virtual ~SceneWidget();
|
||||
|
||||
CSVWidget::SceneToolMode *makeLightingSelector (CSVWidget::SceneToolbar *parent);
|
||||
|
@ -91,7 +92,6 @@ namespace CSVRender
|
|||
///< \note The actual ambient colour may differ based on lighting settings.
|
||||
|
||||
protected:
|
||||
|
||||
void setLighting (Lighting *lighting);
|
||||
///< \attention The ownership of \a lighting is not transferred to *this.
|
||||
|
||||
|
@ -117,7 +117,6 @@ namespace CSVRender
|
|||
CameraController* mCurrentCamControl;
|
||||
|
||||
CSMPrefs::ShortcutEventHandler *mShortcutHandler;
|
||||
CSMPrefs::Shortcut* mFocusToolbarShortcut;
|
||||
|
||||
private:
|
||||
bool mCamPositionSet;
|
||||
|
@ -145,9 +144,7 @@ namespace CSVRender
|
|||
class CompositeViewer : public QObject, public osgViewer::CompositeViewer
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
CompositeViewer();
|
||||
|
||||
static CompositeViewer& get();
|
||||
|
|
|
@ -97,25 +97,25 @@ CSVRender::WorldspaceWidget::WorldspaceWidget (CSMDoc::Document& document, QWidg
|
|||
CSMPrefs::get()["Tooltips"].update();
|
||||
|
||||
// Shortcuts
|
||||
mPrimaryEditShortcut = new CSMPrefs::Shortcut("scene-edit-primary", this);
|
||||
mShortcutHandler->addShortcut(mPrimaryEditShortcut);
|
||||
connect(mPrimaryEditShortcut, SIGNAL(activated(bool)), this, SLOT(primaryEdit(bool)));
|
||||
CSMPrefs::Shortcut* primaryEditShortcut = new CSMPrefs::Shortcut("scene-edit-primary", this);
|
||||
mShortcutHandler->addShortcut(primaryEditShortcut);
|
||||
connect(primaryEditShortcut, SIGNAL(activated(bool)), this, SLOT(primaryEdit(bool)));
|
||||
|
||||
mSecondaryEditShortcut = new CSMPrefs::Shortcut("scene-edit-secondary", this);
|
||||
mShortcutHandler->addShortcut(mSecondaryEditShortcut);
|
||||
connect(mSecondaryEditShortcut, SIGNAL(activated(bool)), this, SLOT(secondaryEdit(bool)));
|
||||
CSMPrefs::Shortcut* secondaryEditShortcut = new CSMPrefs::Shortcut("scene-edit-secondary", this);
|
||||
mShortcutHandler->addShortcut(secondaryEditShortcut);
|
||||
connect(secondaryEditShortcut, SIGNAL(activated(bool)), this, SLOT(secondaryEdit(bool)));
|
||||
|
||||
mPrimarySelectShortcut = new CSMPrefs::Shortcut("scene-select-primary", this);
|
||||
mShortcutHandler->addShortcut(mPrimarySelectShortcut);
|
||||
connect(mPrimarySelectShortcut, SIGNAL(activated(bool)), this, SLOT(primarySelect(bool)));
|
||||
CSMPrefs::Shortcut* primarySelectShortcut = new CSMPrefs::Shortcut("scene-select-primary", this);
|
||||
mShortcutHandler->addShortcut(primarySelectShortcut);
|
||||
connect(primarySelectShortcut, SIGNAL(activated(bool)), this, SLOT(primarySelect(bool)));
|
||||
|
||||
mSecondarySelectShortcut = new CSMPrefs::Shortcut("scene-select-secondary", this);
|
||||
mShortcutHandler->addShortcut(mSecondarySelectShortcut);
|
||||
connect(mSecondarySelectShortcut, SIGNAL(activated(bool)), this, SLOT(secondarySelect(bool)));
|
||||
CSMPrefs::Shortcut* secondarySelectShortcut = new CSMPrefs::Shortcut("scene-select-secondary", this);
|
||||
mShortcutHandler->addShortcut(secondarySelectShortcut);
|
||||
connect(secondarySelectShortcut, SIGNAL(activated(bool)), this, SLOT(secondarySelect(bool)));
|
||||
|
||||
mAbortShortcut = new CSMPrefs::Shortcut("scene-edit-abort", this);
|
||||
mShortcutHandler->addShortcut(mAbortShortcut);
|
||||
connect(mSecondaryEditShortcut, SIGNAL(activated()), this, SLOT(abortDrag()));
|
||||
CSMPrefs::Shortcut* abortShortcut = new CSMPrefs::Shortcut("scene-edit-abort", this);
|
||||
mShortcutHandler->addShortcut(abortShortcut);
|
||||
connect(abortShortcut, SIGNAL(activated()), this, SLOT(abortDrag()));
|
||||
}
|
||||
|
||||
CSVRender::WorldspaceWidget::~WorldspaceWidget ()
|
||||
|
@ -670,7 +670,7 @@ void CSVRender::WorldspaceWidget::wheelEvent (QWheelEvent *event)
|
|||
SceneWidget::wheelEvent(event);
|
||||
}
|
||||
|
||||
void CSVRender::WorldspaceWidget::handleMouseClick (const WorldspaceHitResult& hit, InteractionType type, bool shift)
|
||||
void CSVRender::WorldspaceWidget::handleInteractionPress (const WorldspaceHitResult& hit, InteractionType type)
|
||||
{
|
||||
EditMode& editMode = dynamic_cast<CSVRender::EditMode&> (*mEditMode->getCurrent());
|
||||
|
||||
|
@ -729,7 +729,7 @@ void CSVRender::WorldspaceWidget::handleInteraction(InteractionType type, bool a
|
|||
else
|
||||
{
|
||||
WorldspaceHitResult hit = mousePick(mapFromGlobal(QCursor::pos()), getInteractionMask());
|
||||
handleMouseClick(hit, type, false);
|
||||
handleInteractionPress(hit, type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -68,12 +68,6 @@ namespace CSVRender
|
|||
bool mShowToolTips;
|
||||
int mToolTipDelay;
|
||||
|
||||
CSMPrefs::Shortcut* mPrimaryEditShortcut;
|
||||
CSMPrefs::Shortcut* mSecondaryEditShortcut;
|
||||
CSMPrefs::Shortcut* mPrimarySelectShortcut;
|
||||
CSMPrefs::Shortcut* mSecondarySelectShortcut;
|
||||
CSMPrefs::Shortcut* mAbortShortcut;
|
||||
|
||||
public:
|
||||
|
||||
enum DropType
|
||||
|
@ -209,7 +203,7 @@ namespace CSVRender
|
|||
virtual void mouseMoveEvent (QMouseEvent *event);
|
||||
virtual void wheelEvent (QWheelEvent *event);
|
||||
|
||||
virtual void handleMouseClick (const WorldspaceHitResult& hit, InteractionType type, bool shift);
|
||||
virtual void handleInteractionPress (const WorldspaceHitResult& hit, InteractionType type);
|
||||
|
||||
virtual void settingChanged (const CSMPrefs::Setting *setting);
|
||||
|
||||
|
|
Loading…
Reference in a new issue