mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 09:35:28 +00:00
Add settings to enable/disable debug rendering of mouse picking.
This commit is contained in:
parent
dd9208afeb
commit
cc0acec64c
@ -150,6 +150,13 @@ void CSMSettings::UserSettings::buildSettingModelDefaults()
|
|||||||
ritd->setDeclaredValues (values);
|
ritd->setDeclaredValues (values);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
declareSection ("debug", "Debug Options");
|
||||||
|
{
|
||||||
|
Setting *mousePicking = createSetting (Type_CheckBox, "mouse-picking", "Debug Render Mouse-Picking");
|
||||||
|
mousePicking->setDefaultValue ("false");
|
||||||
|
mousePicking->setToolTip ("Enable redering debug information for mouse picking. "
|
||||||
|
"This option may be removed in future once the mouse picking feature is completed.");
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
/******************************************************************
|
/******************************************************************
|
||||||
|
@ -19,6 +19,7 @@
|
|||||||
|
|
||||||
#include "../../model/world/tablemimedata.hpp"
|
#include "../../model/world/tablemimedata.hpp"
|
||||||
#include "../../model/world/idtable.hpp"
|
#include "../../model/world/idtable.hpp"
|
||||||
|
#include "../../model/settings/usersettings.hpp"
|
||||||
|
|
||||||
#include "../widget/scenetooltoggle.hpp"
|
#include "../widget/scenetooltoggle.hpp"
|
||||||
#include "../world/physicssystem.hpp"
|
#include "../world/physicssystem.hpp"
|
||||||
@ -185,9 +186,12 @@ void CSVRender::PagedWorldspaceWidget::mouseReleaseEvent (QMouseEvent *event)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance();
|
||||||
{
|
bool debug = userSettings.setting ("debug/mouse-picking", QString("false")) == "true" ? true : false;
|
||||||
|
if(!debug)
|
||||||
|
return;
|
||||||
|
|
||||||
// mouse picking
|
// mouse picking
|
||||||
// FIXME: need to virtualise mouse buttons
|
// FIXME: need to virtualise mouse buttons
|
||||||
int viewportWidth = getCamera()->getViewport()->getActualWidth();
|
int viewportWidth = getCamera()->getViewport()->getActualWidth();
|
||||||
@ -196,12 +200,12 @@ void CSVRender::PagedWorldspaceWidget::mouseReleaseEvent (QMouseEvent *event)
|
|||||||
float mouseX = (float) event->x()/viewportWidth;
|
float mouseX = (float) event->x()/viewportWidth;
|
||||||
float mouseY = (float) event->y()/viewportHeight;
|
float mouseY = (float) event->y()/viewportHeight;
|
||||||
|
|
||||||
// Need to set each time in case there are multiple subviews
|
// Need to set scene manager each time in case there are multiple subviews
|
||||||
CSVWorld::PhysicsSystem::instance()->setSceneManager(getSceneManager());
|
CSVWorld::PhysicsSystem::instance()->setSceneManager(getSceneManager());
|
||||||
std::pair<bool, std::string> result = CSVWorld::PhysicsSystem::instance()->castRay(mouseX, mouseY, NULL, NULL, getCamera());
|
std::pair<bool, std::string> result =
|
||||||
|
CSVWorld::PhysicsSystem::instance()->castRay(mouseX, mouseY, NULL, NULL, getCamera());
|
||||||
if(result.first)
|
if(result.first)
|
||||||
{
|
{
|
||||||
flagAsModified();
|
|
||||||
std::cout << "ReferenceId: " << result.second << std::endl;
|
std::cout << "ReferenceId: " << result.second << std::endl;
|
||||||
const CSMWorld::CellRef& cellref = mDocument.getData().getReferences().getRecord (result.second).get();
|
const CSMWorld::CellRef& cellref = mDocument.getData().getReferences().getRecord (result.second).get();
|
||||||
//std::cout << "CellRef mId: " << cellref.mId << std::endl; // Same as ReferenceId
|
//std::cout << "CellRef mId: " << cellref.mId << std::endl; // Same as ReferenceId
|
||||||
@ -223,11 +227,12 @@ void CSVRender::PagedWorldspaceWidget::mouseReleaseEvent (QMouseEvent *event)
|
|||||||
{
|
{
|
||||||
if(iter->first.getId("dummy") == cellref.mCell)
|
if(iter->first.getId("dummy") == cellref.mCell)
|
||||||
{
|
{
|
||||||
std::cout << "Cell found" << std::endl;
|
//std::cout << "Cell found" << std::endl;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
++iter;
|
++iter;
|
||||||
}
|
}
|
||||||
|
flagAsModified();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -238,9 +243,15 @@ void CSVRender::PagedWorldspaceWidget::mouseDoubleClickEvent (QMouseEvent *event
|
|||||||
{
|
{
|
||||||
std::cout << "double clicked" << std::endl;
|
std::cout << "double clicked" << std::endl;
|
||||||
|
|
||||||
// Need to set each time in case there are multiple subviews
|
CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance();
|
||||||
|
bool debug = userSettings.setting ("debug/mouse-picking", QString("false")) == "true" ? true : false;
|
||||||
|
if(!debug)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Need to set scene manager each time in case there are multiple subviews
|
||||||
CSVWorld::PhysicsSystem::instance()->setSceneManager(getSceneManager());
|
CSVWorld::PhysicsSystem::instance()->setSceneManager(getSceneManager());
|
||||||
CSVWorld::PhysicsSystem::instance()->toggleDebugRendering();
|
CSVWorld::PhysicsSystem::instance()->toggleDebugRendering();
|
||||||
|
flagAsModified();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,7 +148,9 @@ namespace CSVWorld
|
|||||||
|
|
||||||
void PhysicsSystem::toggleDebugRendering()
|
void PhysicsSystem::toggleDebugRendering()
|
||||||
{
|
{
|
||||||
if(!mSceneMgr)
|
CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance();
|
||||||
|
bool debug = userSettings.setting ("debug/mouse-picking", QString("false")) == "true" ? true : false;
|
||||||
|
if(!mSceneMgr || !debug)
|
||||||
return; // FIXME: add a warning message
|
return; // FIXME: add a warning message
|
||||||
|
|
||||||
mEngine->toggleDebugRendering();
|
mEngine->toggleDebugRendering();
|
||||||
@ -158,6 +160,8 @@ namespace CSVWorld
|
|||||||
std::pair<bool, std::string> PhysicsSystem::castRay(float mouseX, float mouseY,
|
std::pair<bool, std::string> PhysicsSystem::castRay(float mouseX, float mouseY,
|
||||||
Ogre::Vector3* normal, std::string* hit, Ogre::Camera *camera)
|
Ogre::Vector3* normal, std::string* hit, Ogre::Camera *camera)
|
||||||
{
|
{
|
||||||
|
CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance();
|
||||||
|
bool debug = userSettings.setting ("debug/mouse-picking", QString("false")) == "true" ? true : false;
|
||||||
if(!mSceneMgr)
|
if(!mSceneMgr)
|
||||||
return std::make_pair(false, ""); // FIXME: add a warning message
|
return std::make_pair(false, ""); // FIXME: add a warning message
|
||||||
|
|
||||||
@ -168,7 +172,6 @@ namespace CSVWorld
|
|||||||
camera->setNearClipDistance(nearClipDistance);
|
camera->setNearClipDistance(nearClipDistance);
|
||||||
|
|
||||||
Ogre::Vector3 from = ray.getOrigin();
|
Ogre::Vector3 from = ray.getOrigin();
|
||||||
CSMSettings::UserSettings &userSettings = CSMSettings::UserSettings::instance();
|
|
||||||
float farClipDist = userSettings.setting("Scene/far clip distance", QString("300000")).toFloat();
|
float farClipDist = userSettings.setting("Scene/far clip distance", QString("300000")).toFloat();
|
||||||
Ogre::Vector3 to = ray.getPoint(farClipDist);
|
Ogre::Vector3 to = ray.getPoint(farClipDist);
|
||||||
|
|
||||||
@ -193,7 +196,7 @@ namespace CSVWorld
|
|||||||
Ogre::SceneNode *scene = mSceneMgr->getSceneNode(sceneNode);
|
Ogre::SceneNode *scene = mSceneMgr->getSceneNode(sceneNode);
|
||||||
std::map<std::string, std::vector<std::string> >::iterator iter =
|
std::map<std::string, std::vector<std::string> >::iterator iter =
|
||||||
mSelectedEntities.find(sceneNode);
|
mSelectedEntities.find(sceneNode);
|
||||||
if(iter != mSelectedEntities.end()) // currently selected
|
if(debug && iter != mSelectedEntities.end()) // currently selected
|
||||||
{
|
{
|
||||||
std::vector<std::string> clonedEntities = mSelectedEntities[sceneNode];
|
std::vector<std::string> clonedEntities = mSelectedEntities[sceneNode];
|
||||||
while(!clonedEntities.empty())
|
while(!clonedEntities.empty())
|
||||||
@ -207,9 +210,12 @@ namespace CSVWorld
|
|||||||
}
|
}
|
||||||
mSelectedEntities.erase(iter);
|
mSelectedEntities.erase(iter);
|
||||||
|
|
||||||
removeHitPoint(mSceneMgr, sceneNode); // FIXME: for debugging
|
bool debugCursor = userSettings.setting (
|
||||||
|
"debug/mouse-position", QString("false")) == "true" ? true : false;
|
||||||
|
if(debugCursor) // FIXME: show cursor position for debugging
|
||||||
|
removeHitPoint(mSceneMgr, sceneNode);
|
||||||
}
|
}
|
||||||
else
|
else if(debug)
|
||||||
{
|
{
|
||||||
std::vector<std::string> clonedEntities;
|
std::vector<std::string> clonedEntities;
|
||||||
Ogre::SceneNode::ObjectIterator iter = scene->getAttachedObjectIterator();
|
Ogre::SceneNode::ObjectIterator iter = scene->getAttachedObjectIterator();
|
||||||
@ -244,19 +250,12 @@ namespace CSVWorld
|
|||||||
}
|
}
|
||||||
mSelectedEntities[sceneNode] = clonedEntities;
|
mSelectedEntities[sceneNode] = clonedEntities;
|
||||||
|
|
||||||
// FIXME: show cursor position for debugging
|
bool debugCursor = userSettings.setting (
|
||||||
|
"debug/mouse-position", QString("false")) == "true" ? true : false;
|
||||||
|
if(debugCursor) // FIXME: show cursor position for debugging
|
||||||
showHitPoint(mSceneMgr, sceneNode, ray.getPoint(farClipDist*result.second));
|
showHitPoint(mSceneMgr, sceneNode, ray.getPoint(farClipDist*result.second));
|
||||||
}
|
}
|
||||||
#if 0
|
|
||||||
std::cout << "hit " << result.first
|
|
||||||
+ " result " + std::to_string(result.second*farClipDist) << std::endl;
|
|
||||||
std::cout << "normal " + std::to_string(norm.x)
|
|
||||||
+ ", " + std::to_string(norm.y)
|
|
||||||
+ ", " + std::to_string(norm.z) << std::endl;
|
|
||||||
std::cout << "hit pos "+ std::to_string(ray.getPoint(farClipDist*result.second).x)
|
|
||||||
+ ", " + std::to_string(ray.getPoint(farClipDist*result.second).y)
|
|
||||||
+ ", " + std::to_string(ray.getPoint(farClipDist*result.second).z) << std::endl;
|
|
||||||
#endif
|
|
||||||
return std::make_pair(true, result.first);
|
return std::make_pair(true, result.first);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user