mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-16 19:19:56 +00:00
Merge pull request #1543
This commit is contained in:
commit
9920779a7b
5 changed files with 61 additions and 13 deletions
|
@ -191,6 +191,7 @@ void CSMPrefs::State::declare()
|
||||||
setTooltip ("Acceleration factor during drag operations while holding down shift").
|
setTooltip ("Acceleration factor during drag operations while holding down shift").
|
||||||
setRange (0.001, 100.0);
|
setRange (0.001, 100.0);
|
||||||
declareDouble ("rotate-factor", "Free rotation factor", 0.007).setPrecision(4).setRange(0.0001, 0.1);
|
declareDouble ("rotate-factor", "Free rotation factor", 0.007).setPrecision(4).setRange(0.0001, 0.1);
|
||||||
|
declareDouble ("object-marker-alpha", "Object Marker Transparency", 0.5).setPrecision(2).setRange(0,1);
|
||||||
|
|
||||||
declareCategory ("Tooltips");
|
declareCategory ("Tooltips");
|
||||||
declareBool ("scene", "Show Tooltips in 3D scenes", true);
|
declareBool ("scene", "Show Tooltips in 3D scenes", true);
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
|
#include <osg/Depth>
|
||||||
#include <osg/Group>
|
#include <osg/Group>
|
||||||
#include <osg/PositionAttitudeTransform>
|
#include <osg/PositionAttitudeTransform>
|
||||||
|
|
||||||
|
@ -21,6 +22,7 @@
|
||||||
#include "../../model/world/universalid.hpp"
|
#include "../../model/world/universalid.hpp"
|
||||||
#include "../../model/world/commandmacro.hpp"
|
#include "../../model/world/commandmacro.hpp"
|
||||||
#include "../../model/world/cellcoordinates.hpp"
|
#include "../../model/world/cellcoordinates.hpp"
|
||||||
|
#include "../../model/prefs/state.hpp"
|
||||||
|
|
||||||
#include <components/resource/scenemanager.hpp>
|
#include <components/resource/scenemanager.hpp>
|
||||||
#include <components/sceneutil/lightutil.hpp>
|
#include <components/sceneutil/lightutil.hpp>
|
||||||
|
@ -220,7 +222,7 @@ osg::ref_ptr<osg::Node> CSVRender::Object::makeMoveOrScaleMarker (int axis)
|
||||||
|
|
||||||
for (int i=0; i<2; ++i)
|
for (int i=0; i<2; ++i)
|
||||||
{
|
{
|
||||||
float length = i ? shaftLength : 0;
|
float length = i ? shaftLength : MarkerShaftWidth;
|
||||||
|
|
||||||
vertices->push_back (getMarkerPosition (-MarkerShaftWidth/2, -MarkerShaftWidth/2, length, axis));
|
vertices->push_back (getMarkerPosition (-MarkerShaftWidth/2, -MarkerShaftWidth/2, length, axis));
|
||||||
vertices->push_back (getMarkerPosition (-MarkerShaftWidth/2, MarkerShaftWidth/2, length, axis));
|
vertices->push_back (getMarkerPosition (-MarkerShaftWidth/2, MarkerShaftWidth/2, length, axis));
|
||||||
|
@ -285,15 +287,15 @@ osg::ref_ptr<osg::Node> CSVRender::Object::makeMoveOrScaleMarker (int axis)
|
||||||
|
|
||||||
for (int i=0; i<8; ++i)
|
for (int i=0; i<8; ++i)
|
||||||
colours->push_back (osg::Vec4f (axis==0 ? 1.0f : 0.2f, axis==1 ? 1.0f : 0.2f,
|
colours->push_back (osg::Vec4f (axis==0 ? 1.0f : 0.2f, axis==1 ? 1.0f : 0.2f,
|
||||||
axis==2 ? 1.0f : 0.2f, 1.0f));
|
axis==2 ? 1.0f : 0.2f, mMarkerTransparency));
|
||||||
|
|
||||||
for (int i=8; i<8+4+1; ++i)
|
for (int i=8; i<8+4+1; ++i)
|
||||||
colours->push_back (osg::Vec4f (axis==0 ? 1.0f : 0.0f, axis==1 ? 1.0f : 0.0f,
|
colours->push_back (osg::Vec4f (axis==0 ? 1.0f : 0.0f, axis==1 ? 1.0f : 0.0f,
|
||||||
axis==2 ? 1.0f : 0.0f, 1.0f));
|
axis==2 ? 1.0f : 0.0f, mMarkerTransparency));
|
||||||
|
|
||||||
geometry->setColorArray (colours, osg::Array::BIND_PER_VERTEX);
|
geometry->setColorArray (colours, osg::Array::BIND_PER_VERTEX);
|
||||||
|
|
||||||
geometry->getOrCreateStateSet()->setMode (GL_LIGHTING, osg::StateAttribute::OFF);
|
setupCommonMarkerState(geometry);
|
||||||
|
|
||||||
osg::ref_ptr<osg::Geode> geode (new osg::Geode);
|
osg::ref_ptr<osg::Geode> geode (new osg::Geode);
|
||||||
geode->addDrawable (geometry);
|
geode->addDrawable (geometry);
|
||||||
|
@ -305,11 +307,11 @@ osg::ref_ptr<osg::Node> CSVRender::Object::makeRotateMarker (int axis)
|
||||||
{
|
{
|
||||||
const float Pi = 3.14159265f;
|
const float Pi = 3.14159265f;
|
||||||
|
|
||||||
const float InnerRadius = mBaseNode->getBound().radius();
|
const float InnerRadius = std::max(MarkerShaftBaseLength, mBaseNode->getBound().radius());
|
||||||
const float OuterRadius = InnerRadius + MarkerShaftWidth;
|
const float OuterRadius = InnerRadius + MarkerShaftWidth;
|
||||||
|
|
||||||
const float SegmentDistance = 100.f;
|
const float SegmentDistance = 100.f;
|
||||||
const size_t SegmentCount = std::min(64, std::max(8, (int)(OuterRadius * 2 * Pi / SegmentDistance)));
|
const size_t SegmentCount = std::min(64, std::max(24, (int)(OuterRadius * 2 * Pi / SegmentDistance)));
|
||||||
const size_t VerticesPerSegment = 4;
|
const size_t VerticesPerSegment = 4;
|
||||||
const size_t IndicesPerSegment = 24;
|
const size_t IndicesPerSegment = 24;
|
||||||
|
|
||||||
|
@ -334,6 +336,9 @@ osg::ref_ptr<osg::Node> CSVRender::Object::makeRotateMarker (int axis)
|
||||||
osg::ref_ptr<osg::DrawElementsUShort> primitives = new osg::DrawElementsUShort(osg::PrimitiveSet::TRIANGLES,
|
osg::ref_ptr<osg::DrawElementsUShort> primitives = new osg::DrawElementsUShort(osg::PrimitiveSet::TRIANGLES,
|
||||||
IndexCount);
|
IndexCount);
|
||||||
|
|
||||||
|
// prevent some depth collision issues from overlaps
|
||||||
|
osg::Vec3f offset = getMarkerPosition(0, MarkerShaftWidth/4, 0, axis);
|
||||||
|
|
||||||
for (size_t i = 0; i < SegmentCount; ++i)
|
for (size_t i = 0; i < SegmentCount; ++i)
|
||||||
{
|
{
|
||||||
size_t index = i * VerticesPerSegment;
|
size_t index = i * VerticesPerSegment;
|
||||||
|
@ -344,13 +349,17 @@ osg::ref_ptr<osg::Node> CSVRender::Object::makeRotateMarker (int axis)
|
||||||
float outerX = OuterRadius * std::cos(i * Angle);
|
float outerX = OuterRadius * std::cos(i * Angle);
|
||||||
float outerY = OuterRadius * std::sin(i * Angle);
|
float outerY = OuterRadius * std::sin(i * Angle);
|
||||||
|
|
||||||
vertices->at(index++) = getMarkerPosition(innerX, innerY, MarkerShaftWidth / 2, axis);
|
vertices->at(index++) = getMarkerPosition(innerX, innerY, MarkerShaftWidth / 2, axis) + offset;
|
||||||
vertices->at(index++) = getMarkerPosition(innerX, innerY, -MarkerShaftWidth / 2, axis);
|
vertices->at(index++) = getMarkerPosition(innerX, innerY, -MarkerShaftWidth / 2, axis) + offset;
|
||||||
vertices->at(index++) = getMarkerPosition(outerX, outerY, MarkerShaftWidth / 2, axis);
|
vertices->at(index++) = getMarkerPosition(outerX, outerY, MarkerShaftWidth / 2, axis) + offset;
|
||||||
vertices->at(index++) = getMarkerPosition(outerX, outerY, -MarkerShaftWidth / 2, axis);
|
vertices->at(index++) = getMarkerPosition(outerX, outerY, -MarkerShaftWidth / 2, axis) + offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
colors->at(0) = osg::Vec4f (axis==0 ? 1.0f : 0.2f, axis==1 ? 1.0f : 0.2f, axis==2 ? 1.0f : 0.2f, 1.0f);
|
colors->at(0) = osg::Vec4f (
|
||||||
|
axis==0 ? 1.0f : 0.2f,
|
||||||
|
axis==1 ? 1.0f : 0.2f,
|
||||||
|
axis==2 ? 1.0f : 0.2f,
|
||||||
|
mMarkerTransparency);
|
||||||
|
|
||||||
for (size_t i = 0; i < SegmentCount; ++i)
|
for (size_t i = 0; i < SegmentCount; ++i)
|
||||||
{
|
{
|
||||||
|
@ -374,7 +383,7 @@ osg::ref_ptr<osg::Node> CSVRender::Object::makeRotateMarker (int axis)
|
||||||
geometry->setColorArray(colors, osg::Array::BIND_OVERALL);
|
geometry->setColorArray(colors, osg::Array::BIND_OVERALL);
|
||||||
geometry->addPrimitiveSet(primitives);
|
geometry->addPrimitiveSet(primitives);
|
||||||
|
|
||||||
geometry->getOrCreateStateSet()->setMode (GL_LIGHTING, osg::StateAttribute::OFF);
|
setupCommonMarkerState(geometry);
|
||||||
|
|
||||||
osg::ref_ptr<osg::Geode> geode = new osg::Geode();
|
osg::ref_ptr<osg::Geode> geode = new osg::Geode();
|
||||||
geode->addDrawable (geometry);
|
geode->addDrawable (geometry);
|
||||||
|
@ -382,6 +391,15 @@ osg::ref_ptr<osg::Node> CSVRender::Object::makeRotateMarker (int axis)
|
||||||
return geode;
|
return geode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVRender::Object::setupCommonMarkerState(osg::ref_ptr<osg::Geometry> geometry)
|
||||||
|
{
|
||||||
|
osg::ref_ptr<osg::StateSet> state = geometry->getOrCreateStateSet();
|
||||||
|
state->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
|
||||||
|
state->setMode(GL_BLEND, osg::StateAttribute::ON);
|
||||||
|
|
||||||
|
state->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
|
||||||
|
}
|
||||||
|
|
||||||
osg::Vec3f CSVRender::Object::getMarkerPosition (float x, float y, float z, int axis)
|
osg::Vec3f CSVRender::Object::getMarkerPosition (float x, float y, float z, int axis)
|
||||||
{
|
{
|
||||||
switch (axis)
|
switch (axis)
|
||||||
|
@ -399,7 +417,7 @@ osg::Vec3f CSVRender::Object::getMarkerPosition (float x, float y, float z, int
|
||||||
CSVRender::Object::Object (CSMWorld::Data& data, osg::Group* parentNode,
|
CSVRender::Object::Object (CSMWorld::Data& data, osg::Group* parentNode,
|
||||||
const std::string& id, bool referenceable, bool forceBaseToZero)
|
const std::string& id, bool referenceable, bool forceBaseToZero)
|
||||||
: mData (data), mBaseNode(0), mSelected(false), mParentNode(parentNode), mResourceSystem(data.getResourceSystem().get()), mForceBaseToZero (forceBaseToZero),
|
: mData (data), mBaseNode(0), mSelected(false), mParentNode(parentNode), mResourceSystem(data.getResourceSystem().get()), mForceBaseToZero (forceBaseToZero),
|
||||||
mScaleOverride (1), mOverrideFlags (0), mSubMode (-1)
|
mScaleOverride (1), mOverrideFlags (0), mSubMode (-1), mMarkerTransparency(0.5f)
|
||||||
{
|
{
|
||||||
mRootNode = new osg::PositionAttitudeTransform;
|
mRootNode = new osg::PositionAttitudeTransform;
|
||||||
|
|
||||||
|
@ -453,6 +471,7 @@ void CSVRender::Object::setSelected(bool selected)
|
||||||
else
|
else
|
||||||
mRootNode->addChild(mBaseNode);
|
mRootNode->addChild(mBaseNode);
|
||||||
|
|
||||||
|
mMarkerTransparency = CSMPrefs::get()["3D Scene Input"]["object-marker-alpha"].toDouble();
|
||||||
updateMarker();
|
updateMarker();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -629,6 +648,12 @@ void CSVRender::Object::setScale (float scale)
|
||||||
adjustTransform();
|
adjustTransform();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CSVRender::Object::setMarkerTransparency(float value)
|
||||||
|
{
|
||||||
|
mMarkerTransparency = value;
|
||||||
|
updateMarker();
|
||||||
|
}
|
||||||
|
|
||||||
void CSVRender::Object::apply (CSMWorld::CommandMacro& commands)
|
void CSVRender::Object::apply (CSMWorld::CommandMacro& commands)
|
||||||
{
|
{
|
||||||
const CSMWorld::RefCollection& collection = mData.getReferences();
|
const CSMWorld::RefCollection& collection = mData.getReferences();
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include <osg/ref_ptr>
|
#include <osg/ref_ptr>
|
||||||
|
#include <osg/Geometry>
|
||||||
#include <osg/Referenced>
|
#include <osg/Referenced>
|
||||||
|
|
||||||
#include <components/esm/defs.hpp>
|
#include <components/esm/defs.hpp>
|
||||||
|
@ -96,6 +97,7 @@ namespace CSVRender
|
||||||
int mOverrideFlags;
|
int mOverrideFlags;
|
||||||
osg::ref_ptr<osg::Node> mMarker[3];
|
osg::ref_ptr<osg::Node> mMarker[3];
|
||||||
int mSubMode;
|
int mSubMode;
|
||||||
|
float mMarkerTransparency;
|
||||||
|
|
||||||
/// Not implemented
|
/// Not implemented
|
||||||
Object (const Object&);
|
Object (const Object&);
|
||||||
|
@ -121,6 +123,9 @@ namespace CSVRender
|
||||||
osg::ref_ptr<osg::Node> makeMoveOrScaleMarker (int axis);
|
osg::ref_ptr<osg::Node> makeMoveOrScaleMarker (int axis);
|
||||||
osg::ref_ptr<osg::Node> makeRotateMarker (int axis);
|
osg::ref_ptr<osg::Node> makeRotateMarker (int axis);
|
||||||
|
|
||||||
|
/// Sets up a stateset with properties common to all marker types.
|
||||||
|
void setupCommonMarkerState(osg::ref_ptr<osg::Geometry> geometry);
|
||||||
|
|
||||||
osg::Vec3f getMarkerPosition (float x, float y, float z, int axis);
|
osg::Vec3f getMarkerPosition (float x, float y, float z, int axis);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
@ -179,6 +184,8 @@ namespace CSVRender
|
||||||
/// Set override scale
|
/// Set override scale
|
||||||
void setScale (float scale);
|
void setScale (float scale);
|
||||||
|
|
||||||
|
void setMarkerTransparency(float value);
|
||||||
|
|
||||||
/// Apply override changes via command and end edit mode
|
/// Apply override changes via command and end edit mode
|
||||||
void apply (CSMWorld::CommandMacro& commands);
|
void apply (CSMWorld::CommandMacro& commands);
|
||||||
|
|
||||||
|
|
|
@ -51,6 +51,7 @@ CSVRender::WorldspaceWidget::WorldspaceWidget (CSMDoc::Document& document, QWidg
|
||||||
, mToolTipPos (-1, -1)
|
, mToolTipPos (-1, -1)
|
||||||
, mShowToolTips(false)
|
, mShowToolTips(false)
|
||||||
, mToolTipDelay(0)
|
, mToolTipDelay(0)
|
||||||
|
, mInConstructor(true)
|
||||||
{
|
{
|
||||||
setAcceptDrops(true);
|
setAcceptDrops(true);
|
||||||
|
|
||||||
|
@ -114,6 +115,8 @@ CSVRender::WorldspaceWidget::WorldspaceWidget (CSMDoc::Document& document, QWidg
|
||||||
|
|
||||||
CSMPrefs::Shortcut* abortShortcut = new CSMPrefs::Shortcut("scene-edit-abort", this);
|
CSMPrefs::Shortcut* abortShortcut = new CSMPrefs::Shortcut("scene-edit-abort", this);
|
||||||
connect(abortShortcut, SIGNAL(activated()), this, SLOT(abortDrag()));
|
connect(abortShortcut, SIGNAL(activated()), this, SLOT(abortDrag()));
|
||||||
|
|
||||||
|
mInConstructor = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CSVRender::WorldspaceWidget::~WorldspaceWidget ()
|
CSVRender::WorldspaceWidget::~WorldspaceWidget ()
|
||||||
|
@ -128,6 +131,17 @@ void CSVRender::WorldspaceWidget::settingChanged (const CSMPrefs::Setting *setti
|
||||||
mDragWheelFactor = setting->toDouble();
|
mDragWheelFactor = setting->toDouble();
|
||||||
else if (*setting=="3D Scene Input/drag-shift-factor")
|
else if (*setting=="3D Scene Input/drag-shift-factor")
|
||||||
mDragShiftFactor = setting->toDouble();
|
mDragShiftFactor = setting->toDouble();
|
||||||
|
else if (*setting=="3D Scene Input/object-marker-alpha" && !mInConstructor)
|
||||||
|
{
|
||||||
|
float alpha = setting->toDouble();
|
||||||
|
// getSelection is virtual, thus this can not be called from the constructor
|
||||||
|
auto selection = getSelection(Mask_Reference);
|
||||||
|
for (osg::ref_ptr<TagBase> tag : selection)
|
||||||
|
{
|
||||||
|
if (auto objTag = dynamic_cast<ObjectTag*>(tag.get()))
|
||||||
|
objTag->mObject->setMarkerTransparency(alpha);
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (*setting=="Tooltips/scene-delay")
|
else if (*setting=="Tooltips/scene-delay")
|
||||||
mToolTipDelay = setting->toInt();
|
mToolTipDelay = setting->toInt();
|
||||||
else if (*setting=="Tooltips/scene")
|
else if (*setting=="Tooltips/scene")
|
||||||
|
|
|
@ -65,6 +65,7 @@ namespace CSVRender
|
||||||
QPoint mToolTipPos;
|
QPoint mToolTipPos;
|
||||||
bool mShowToolTips;
|
bool mShowToolTips;
|
||||||
int mToolTipDelay;
|
int mToolTipDelay;
|
||||||
|
bool mInConstructor;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue