Added height slider and textfields to chaperone page.
This commit is contained in:
@@ -7,6 +7,7 @@ namespace advsettings {
|
||||
|
||||
|
||||
void ChaperoneTabController::initStage1() {
|
||||
m_height = getBoundsMaxY();
|
||||
reloadChaperoneProfiles();
|
||||
eventLoopTick();
|
||||
}
|
||||
@@ -241,6 +242,48 @@ void ChaperoneTabController::setFadeDistance(float value, bool notify) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
float ChaperoneTabController::height() const {
|
||||
return m_height;
|
||||
}
|
||||
|
||||
|
||||
void ChaperoneTabController::setHeight(float value, bool notify) {
|
||||
if (m_height != value) {
|
||||
m_height = value;
|
||||
vr::VRChaperoneSetup()->RevertWorkingCopy();
|
||||
unsigned collisionBoundsCount = 0;
|
||||
vr::VRChaperoneSetup()->GetWorkingCollisionBoundsInfo(nullptr, &collisionBoundsCount);
|
||||
if (collisionBoundsCount > 0) {
|
||||
vr::HmdQuad_t* collisionBounds = new vr::HmdQuad_t[collisionBoundsCount];
|
||||
vr::VRChaperoneSetup()->GetWorkingCollisionBoundsInfo(collisionBounds, &collisionBoundsCount);
|
||||
for (unsigned b = 0; b < collisionBoundsCount; b++) {
|
||||
collisionBounds[b].vCorners[0].v[1] = 0.0;
|
||||
collisionBounds[b].vCorners[1].v[1] = value;
|
||||
collisionBounds[b].vCorners[2].v[1] = value;
|
||||
collisionBounds[b].vCorners[3].v[1] = 0.0;
|
||||
}
|
||||
vr::VRChaperoneSetup()->SetWorkingCollisionBoundsInfo(collisionBounds, collisionBoundsCount);
|
||||
vr::VRChaperoneSetup()->CommitWorkingCopy(vr::EChaperoneConfigFile_Live);
|
||||
delete collisionBounds;
|
||||
}
|
||||
if (notify) {
|
||||
emit heightChanged(m_fadeDistance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ChaperoneTabController::updateHeight(float value, bool notify) {
|
||||
if (m_height != value) {
|
||||
m_height = value;
|
||||
if (notify) {
|
||||
emit heightChanged(m_fadeDistance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool ChaperoneTabController::centerMarker() const {
|
||||
return m_centerMarker;
|
||||
}
|
||||
@@ -415,6 +458,7 @@ void ChaperoneTabController::applyChaperoneProfile(unsigned index) {
|
||||
setForceBounds(profile.forceBounds);
|
||||
}
|
||||
vr::VRSettings()->Sync();
|
||||
updateHeight(getBoundsMaxY());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -428,4 +472,27 @@ void ChaperoneTabController::deleteChaperoneProfile(unsigned index) {
|
||||
}
|
||||
}
|
||||
|
||||
float ChaperoneTabController::getBoundsMaxY() {
|
||||
unsigned collisionBoundsCount = 0;
|
||||
float result = FP_NAN;
|
||||
vr::VRChaperoneSetup()->GetLiveCollisionBoundsInfo(nullptr, &collisionBoundsCount);
|
||||
if (collisionBoundsCount > 0) {
|
||||
vr::HmdQuad_t* collisionBounds = new vr::HmdQuad_t[collisionBoundsCount];
|
||||
vr::VRChaperoneSetup()->GetLiveCollisionBoundsInfo(collisionBounds, &collisionBoundsCount);
|
||||
for (unsigned b = 0; b < collisionBoundsCount; b++) {
|
||||
int ci;
|
||||
if (collisionBounds[b].vCorners[1].v[1] >= collisionBounds[b].vCorners[2].v[1]) {
|
||||
ci = 1;
|
||||
} else {
|
||||
ci = 2;
|
||||
}
|
||||
if (isnan(result) || result < collisionBounds[b].vCorners[ci].v[1]) {
|
||||
result = collisionBounds[b].vCorners[ci].v[1];
|
||||
}
|
||||
}
|
||||
delete collisionBounds;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace advconfig
|
||||
|
||||
@@ -53,9 +53,10 @@ class ChaperoneTabController : public QObject {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(float boundsVisibility READ boundsVisibility WRITE setBoundsVisibility NOTIFY boundsVisibilityChanged)
|
||||
Q_PROPERTY(float fadeDistance READ fadeDistance WRITE setFadeDistance NOTIFY fadeDistanceChanged)
|
||||
Q_PROPERTY(float centerMarker READ centerMarker WRITE setCenterMarker NOTIFY centerMarkerChanged)
|
||||
Q_PROPERTY(float playSpaceMarker READ playSpaceMarker WRITE setPlaySpaceMarker NOTIFY playSpaceMarkerChanged)
|
||||
Q_PROPERTY(float forceBounds READ forceBounds WRITE setForceBounds NOTIFY forceBoundsChanged)
|
||||
Q_PROPERTY(float height READ height WRITE setHeight NOTIFY heightChanged)
|
||||
Q_PROPERTY(bool centerMarker READ centerMarker WRITE setCenterMarker NOTIFY centerMarkerChanged)
|
||||
Q_PROPERTY(bool playSpaceMarker READ playSpaceMarker WRITE setPlaySpaceMarker NOTIFY playSpaceMarkerChanged)
|
||||
Q_PROPERTY(bool forceBounds READ forceBounds WRITE setForceBounds NOTIFY forceBoundsChanged)
|
||||
|
||||
private:
|
||||
OverlayController* parent;
|
||||
@@ -63,6 +64,7 @@ private:
|
||||
|
||||
float m_visibility = 0.6f;
|
||||
float m_fadeDistance = 0.7f;
|
||||
float m_height = 2.0f;
|
||||
bool m_centerMarker = false;
|
||||
bool m_playSpaceMarker = false;
|
||||
bool m_forceBounds = false;
|
||||
@@ -79,6 +81,7 @@ public:
|
||||
|
||||
float boundsVisibility() const;
|
||||
float fadeDistance() const;
|
||||
float height() const;
|
||||
bool centerMarker() const;
|
||||
bool playSpaceMarker() const;
|
||||
bool forceBounds() const;
|
||||
@@ -89,9 +92,13 @@ public:
|
||||
Q_INVOKABLE unsigned getChaperoneProfileCount();
|
||||
Q_INVOKABLE QString getChaperoneProfileName(unsigned index);
|
||||
|
||||
float getBoundsMaxY();
|
||||
|
||||
public slots:
|
||||
void setBoundsVisibility(float value, bool notify = true);
|
||||
void setFadeDistance(float value, bool notify = true);
|
||||
void setHeight(float value, bool notify = true);
|
||||
void updateHeight(float value, bool notify = true);
|
||||
void setCenterMarker(bool value, bool notify = true);
|
||||
void setPlaySpaceMarker(bool value, bool notify = true);
|
||||
void setForceBounds(bool value, bool notify = true);
|
||||
@@ -100,13 +107,14 @@ public slots:
|
||||
void reloadFromDisk();
|
||||
|
||||
void addChaperoneProfile(QString name, bool includeGeometry, bool includeVisbility, bool includeFadeDistance, bool includeCenterMarker,
|
||||
bool includePlaySpaceMarker, bool includeFloorBounds, bool includeBoundsColor, bool includeChaperoneStyle, bool includeForceBounds);
|
||||
bool includePlaySpaceMarker, bool includeFloorBounds, bool includeBoundsColor, bool includeChaperoneStyle, bool includeForceBounds);
|
||||
void applyChaperoneProfile(unsigned index);
|
||||
void deleteChaperoneProfile(unsigned index);
|
||||
|
||||
signals:
|
||||
void boundsVisibilityChanged(float value);
|
||||
void fadeDistanceChanged(float value);
|
||||
void heightChanged(float value);
|
||||
void centerMarkerChanged(bool value);
|
||||
void playSpaceMarkerChanged(bool value);
|
||||
void forceBoundsChanged(bool value);
|
||||
|
||||
Reference in New Issue
Block a user