mirror of
https://github.com/overte-org/overte.git
synced 2025-04-16 13:56:24 +02:00
merge with upstream, fixed a smal typo bug and clean up the ui
This commit is contained in:
commit
87b159e491
12 changed files with 196 additions and 110 deletions
|
@ -1,34 +0,0 @@
|
|||
//
|
||||
// ClassificationTracker.cpp
|
||||
// libraries/workload/src/workload
|
||||
//
|
||||
// Created by Andrew Meadows 2018.02.21
|
||||
// Copyright 2018 High Fidelity, Inc.
|
||||
//
|
||||
// Originally from lighthouse3d. Modified to utilize glm::vec3 and clean up to our coding standards
|
||||
// Simple plane class.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
#include "ClassificationTracker.h"
|
||||
|
||||
using namespace workload;
|
||||
|
||||
void ClassificationTracker::configure(const Config& config) {
|
||||
}
|
||||
|
||||
void ClassificationTracker::run(const WorkloadContextPointer& context, Outputs& outputs) {
|
||||
auto space = context->_space;
|
||||
if (space) {
|
||||
Changes changes;
|
||||
space->categorizeAndGetChanges(changes);
|
||||
outputs.resize(workload::Region::NUM_TRANSITIONS);
|
||||
for (uint32_t i = 0; i < changes.size(); ++i) {
|
||||
int32_t j = Region::computeTransitionIndex(changes[i].prevRegion, changes[i].region);
|
||||
assert(j >= 0 && j < workload::Region::NUM_TRANSITIONS);
|
||||
outputs[j].push_back(changes[i].proxyId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -17,29 +17,10 @@
|
|||
#include <iostream>
|
||||
|
||||
#include "ViewTask.h"
|
||||
#include "ClassificationTracker.h"
|
||||
#include "RegionTracker.h"
|
||||
#include "RegionState.h"
|
||||
|
||||
namespace workload {
|
||||
class DebugCout {
|
||||
public:
|
||||
using Inputs = SortedChanges;
|
||||
using JobModel = workload::Job::ModelI<DebugCout, Inputs>;
|
||||
|
||||
DebugCout() {}
|
||||
|
||||
void run(const workload::WorkloadContextPointer& renderContext, const Inputs& inputs) {
|
||||
qDebug() << "Some message from " << inputs.size();
|
||||
int i = 0;
|
||||
for (auto& b: inputs) {
|
||||
qDebug() << " Bucket Number" << i << " size is " << b.size();
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
protected:
|
||||
};
|
||||
|
||||
|
||||
WorkloadContext::WorkloadContext(const SpacePointer& space) : task::JobContext(trace_workload()), _space(space) {}
|
||||
|
||||
class EngineBuilder {
|
||||
|
@ -48,8 +29,8 @@ namespace workload {
|
|||
using JobModel = Task::ModelI<EngineBuilder, Inputs>;
|
||||
void build(JobModel& model, const Varying& in, Varying& out) {
|
||||
model.addJob<SetupViews>("setupViews", in);
|
||||
const auto classifications = model.addJob<ClassificationTracker>("classificationTracker");
|
||||
// model.addJob<DebugCout>("debug", classifications);
|
||||
const auto regionChanges = model.addJob<RegionTracker>("regionTracker");
|
||||
model.addJob<RegionState>("regionState", regionChanges);
|
||||
|
||||
}
|
||||
};
|
||||
|
|
69
libraries/workload/src/workload/RegionState.cpp
Normal file
69
libraries/workload/src/workload/RegionState.cpp
Normal file
|
@ -0,0 +1,69 @@
|
|||
//
|
||||
// RegionState.cpp
|
||||
// libraries/workload/src/workload
|
||||
//
|
||||
// Created by Andrew Meadows 2018.03.07
|
||||
// Copyright 2018 High Fidelity, Inc.
|
||||
//
|
||||
// Originally from lighthouse3d. Modified to utilize glm::vec3 and clean up to our coding standards
|
||||
// Simple plane class.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include "RegionState.h"
|
||||
|
||||
using namespace workload;
|
||||
|
||||
void RegionState::run(const workload::WorkloadContextPointer& renderContext, const Inputs& inputs) {
|
||||
// inputs is a vector of vectors of proxyId's:
|
||||
//
|
||||
// inputs[0] = vector of ids exiting region 0
|
||||
// inputs[1] = vector of ids entering region 0
|
||||
// ...
|
||||
// inputs[2N] = vector of ids exiting region N
|
||||
// inputs[2N + 1] = vector of ids entering region N
|
||||
assert(inputs.size() == 2 * Region::UNKNOWN);
|
||||
|
||||
// The id's in each vector are sorted in ascending order
|
||||
// because the source vectors are scanned in ascending order.
|
||||
|
||||
for (uint32_t i = 0; i < _state.size(); ++i) {
|
||||
const IndexVector& going = inputs[2 * i];
|
||||
const IndexVector& coming = inputs[2 * i + 1];
|
||||
if (coming.size() == 0 && going.size() == 0) {
|
||||
continue;
|
||||
}
|
||||
if (_state[i].empty()) {
|
||||
assert(going.empty());
|
||||
_state[i] = coming;
|
||||
} else {
|
||||
// NOTE: all vectors are sorted by proxyId!
|
||||
// which means we can build the new vector by walking three vectors (going, current, coming) in one pass
|
||||
IndexVector& oldState = _state[i];
|
||||
IndexVector newState;
|
||||
newState.reserve(oldState.size() - going.size() + coming.size());
|
||||
uint32_t goingIndex = 0;
|
||||
uint32_t comingIndex = 0;
|
||||
for (uint32_t j = 0; j < oldState.size(); ++j) {
|
||||
int32_t proxyId = oldState[j];
|
||||
while (comingIndex < coming.size() && coming[comingIndex] < proxyId) {
|
||||
newState.push_back(coming[comingIndex]);
|
||||
++comingIndex;
|
||||
}
|
||||
if (goingIndex < going.size() && going[goingIndex] == proxyId) {
|
||||
++goingIndex;
|
||||
} else {
|
||||
newState.push_back(proxyId);
|
||||
}
|
||||
}
|
||||
assert(goingIndex == going.size());
|
||||
while (comingIndex < coming.size()) {
|
||||
newState.push_back(coming[comingIndex]);
|
||||
++comingIndex;
|
||||
}
|
||||
oldState.swap(newState);
|
||||
}
|
||||
}
|
||||
}
|
38
libraries/workload/src/workload/RegionState.h
Normal file
38
libraries/workload/src/workload/RegionState.h
Normal file
|
@ -0,0 +1,38 @@
|
|||
//
|
||||
// RegionState.h
|
||||
// libraries/workload/src/workload
|
||||
//
|
||||
// Created by Andrew Meadows 2018.03.07
|
||||
// Copyright 2018 High Fidelity, Inc.
|
||||
//
|
||||
// Originally from lighthouse3d. Modified to utilize glm::vec3 and clean up to our coding standards
|
||||
// Simple plane class.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#ifndef hifi_workload_RegionState_h
|
||||
#define hifi_workload_RegionState_h
|
||||
|
||||
#include "Space.h"
|
||||
#include "Engine.h"
|
||||
|
||||
namespace workload {
|
||||
|
||||
class RegionState {
|
||||
public:
|
||||
using Inputs = IndexVectors;
|
||||
using JobModel = workload::Job::ModelI<RegionState, Inputs>;
|
||||
|
||||
RegionState() {
|
||||
_state.resize(Region::UNKNOWN);
|
||||
}
|
||||
|
||||
void run(const workload::WorkloadContextPointer& renderContext, const Inputs& inputs);
|
||||
|
||||
protected:
|
||||
IndexVectors _state;
|
||||
};
|
||||
}
|
||||
#endif // hifi_workload_RegionState_h
|
43
libraries/workload/src/workload/RegionTracker.cpp
Normal file
43
libraries/workload/src/workload/RegionTracker.cpp
Normal file
|
@ -0,0 +1,43 @@
|
|||
//
|
||||
// RegionTracker.cpp
|
||||
// libraries/workload/src/workload
|
||||
//
|
||||
// Created by Andrew Meadows 2018.02.21
|
||||
// Copyright 2018 High Fidelity, Inc.
|
||||
//
|
||||
// Originally from lighthouse3d. Modified to utilize glm::vec3 and clean up to our coding standards
|
||||
// Simple plane class.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
#include "RegionTracker.h"
|
||||
|
||||
#include "Region.h"
|
||||
|
||||
using namespace workload;
|
||||
|
||||
void RegionTracker::configure(const Config& config) {
|
||||
}
|
||||
|
||||
void RegionTracker::run(const WorkloadContextPointer& context, Outputs& outputs) {
|
||||
outputs.clear();
|
||||
auto space = context->_space;
|
||||
if (space) {
|
||||
Changes changes;
|
||||
space->categorizeAndGetChanges(changes);
|
||||
// use exit/enter lists for each region less than Region::UNKNOWN
|
||||
outputs.resize(2 * (workload::Region::NUM_CLASSIFICATIONS - 1));
|
||||
for (uint32_t i = 0; i < changes.size(); ++i) {
|
||||
Space::Change& change = changes[i];
|
||||
if (change.prevRegion < Region::UNKNOWN) {
|
||||
// EXIT list index = 2 * regionIndex
|
||||
outputs[2 * change.prevRegion].push_back(change.proxyId);
|
||||
}
|
||||
if (change.region < Region::UNKNOWN) {
|
||||
// ENTER list index = 2 * regionIndex + 1
|
||||
outputs[2 * change.region + 1].push_back(change.proxyId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,5 +1,5 @@
|
|||
//
|
||||
// ClassificationTracker.h
|
||||
// RegionTracker.h
|
||||
// libraries/workload/src/workload
|
||||
//
|
||||
// Created by Andrew Meadows 2018.02.21
|
||||
|
@ -12,27 +12,27 @@
|
|||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#ifndef hifi_workload_ClassificationTracker_h
|
||||
#define hifi_workload_ClassificationTracker_h
|
||||
#ifndef hifi_workload_RegionTracker_h
|
||||
#define hifi_workload_RegionTracker_h
|
||||
|
||||
#include "Space.h"
|
||||
#include "Engine.h"
|
||||
|
||||
namespace workload {
|
||||
|
||||
class ClassificationTrackerConfig : public Job::Config {
|
||||
class RegionTrackerConfig : public Job::Config {
|
||||
Q_OBJECT
|
||||
public:
|
||||
ClassificationTrackerConfig() : Job::Config(true) {}
|
||||
RegionTrackerConfig() : Job::Config(true) {}
|
||||
};
|
||||
|
||||
class ClassificationTracker {
|
||||
class RegionTracker {
|
||||
public:
|
||||
using Config = ClassificationTrackerConfig;
|
||||
using Outputs = SortedChanges;
|
||||
using JobModel = workload::Job::ModelO<ClassificationTracker, Outputs, Config>;
|
||||
using Config = RegionTrackerConfig;
|
||||
using Outputs = IndexVectors;
|
||||
using JobModel = workload::Job::ModelO<RegionTracker, Outputs, Config>;
|
||||
|
||||
ClassificationTracker() {}
|
||||
RegionTracker() {}
|
||||
|
||||
void configure(const Config& config);
|
||||
void run(const workload::WorkloadContextPointer& renderContext, Outputs& outputs);
|
||||
|
@ -42,4 +42,4 @@ namespace workload {
|
|||
|
||||
} // namespace workload
|
||||
|
||||
#endif // hifi_workload_ClassificationTracker_h
|
||||
#endif // hifi_workload_RegionTracker_h
|
|
@ -62,7 +62,6 @@ void Space::copyViews(std::vector<View>& copy) const {
|
|||
copy = _views;
|
||||
}
|
||||
|
||||
// TODO?: move this to an algorithm/job?
|
||||
void Space::categorizeAndGetChanges(std::vector<Space::Change>& changes) {
|
||||
uint32_t numProxies = (uint32_t)_proxies.size();
|
||||
uint32_t numViews = (uint32_t)_views.size();
|
||||
|
@ -74,21 +73,11 @@ void Space::categorizeAndGetChanges(std::vector<Space::Change>& changes) {
|
|||
uint8_t region = Region::UNKNOWN;
|
||||
for (uint32_t j = 0; j < numViews; ++j) {
|
||||
auto& view = _views[j];
|
||||
|
||||
glm::vec3 distance2(glm::distance2(proxyCenter, glm::vec3(view.regions[0])), glm::distance2(proxyCenter, glm::vec3(view.regions[1])), glm::distance2(proxyCenter, glm::vec3(view.regions[2])));
|
||||
glm::vec3 regionRadii2(view.regions[0].w + proxyRadius, view.regions[1].w + proxyRadius, view.regions[2].w + proxyRadius);
|
||||
regionRadii2 *= regionRadii2;
|
||||
auto touchTests = glm::lessThanEqual(distance2, regionRadii2);
|
||||
|
||||
if (glm::any(touchTests)) {
|
||||
if (touchTests.x) {
|
||||
region = Region::R1;
|
||||
break;
|
||||
} else if (touchTests.y) {
|
||||
region = Region::R2;
|
||||
break;
|
||||
} else {
|
||||
region = Region::R3;
|
||||
// for each 'view' we need only increment 'k' below the current value of 'region'
|
||||
for (uint8_t k = 0; k < region; ++k) {
|
||||
float touchDistance = proxyRadius + view.regions[k].w;
|
||||
if (distance2(proxyCenter, glm::vec3(view.regions[k])) < touchDistance * touchDistance) {
|
||||
region = k;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -124,10 +113,8 @@ void Space::deleteProxy(int32_t proxyId) {
|
|||
}
|
||||
|
||||
uint32_t Space::copyProxyValues(Proxy* proxies, uint32_t numDestProxies) const {
|
||||
|
||||
auto numCopied = std::min(numDestProxies, (uint32_t)_proxies.size());
|
||||
memcpy(proxies, _proxies.data(), numCopied * sizeof(Proxy));
|
||||
|
||||
return numCopied;
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,8 @@
|
|||
|
||||
namespace workload {
|
||||
|
||||
using IndexVector = std::vector<int32_t>;
|
||||
|
||||
class Space {
|
||||
public:
|
||||
using Sphere = glm::vec4; // <x,y,z> = center, w = radius
|
||||
|
@ -52,7 +54,7 @@ public:
|
|||
|
||||
void clear();
|
||||
int32_t createProxy(const Sphere& sphere);
|
||||
void deleteProxies(const std::vector<int32_t>& deadIndices);
|
||||
void deleteProxies(const IndexVector& deadIndices);
|
||||
void updateProxies(const std::vector<ProxyUpdate>& changedProxies);
|
||||
void setViews(const std::vector<View>& views);
|
||||
|
||||
|
@ -72,12 +74,12 @@ private:
|
|||
|
||||
std::vector<Proxy> _proxies;
|
||||
Views _views;
|
||||
std::vector<int32_t> _freeIndices;
|
||||
IndexVector _freeIndices;
|
||||
};
|
||||
|
||||
using SpacePointer = std::shared_ptr<Space>;
|
||||
using Changes = std::vector<Space::Change>;
|
||||
using SortedChanges = std::vector<std::vector<int32_t>>;
|
||||
using IndexVectors = std::vector<IndexVector>;
|
||||
|
||||
} // namespace workload
|
||||
|
||||
|
|
|
@ -48,7 +48,6 @@ void View::updateRegions(View& view) {
|
|||
config[i * 2 + 1] = refFar * weight;
|
||||
refFar *= 2.0f;
|
||||
}
|
||||
|
||||
updateRegions(view, config.data());
|
||||
}
|
||||
|
||||
|
|
|
@ -65,4 +65,4 @@ using Views = std::vector<View>;
|
|||
|
||||
} // namespace workload
|
||||
|
||||
#endif // hifi_workload_View_h
|
||||
#endif // hifi_workload_View_h
|
||||
|
|
|
@ -41,14 +41,14 @@ namespace workload {
|
|||
void setR3Back(float d) { data.r3Back = d; emit dirty(); }
|
||||
|
||||
struct Data {
|
||||
float r1Front { 10.0f };
|
||||
float r1Back { 2.0f };
|
||||
float r1Front { 10.0f };
|
||||
|
||||
float r2Front{ 30.0f };
|
||||
float r2Back{ 5.0f };
|
||||
float r2Front{ 30.0f };
|
||||
|
||||
float r3Front{ 100.0f };
|
||||
float r3Back{ 10.0f };
|
||||
float r3Front{ 100.0f };
|
||||
} data;
|
||||
|
||||
signals:
|
||||
|
|
|
@ -40,24 +40,25 @@ Rectangle {
|
|||
checked: workload.spaceToRender["freezeViews"]
|
||||
onCheckedChanged: { workload.spaceToRender["freezeViews"] = checked, workload.setupViews.enabled = !checked; }
|
||||
}
|
||||
Repeater {
|
||||
model: [
|
||||
"R1 Front:r1Front:300:1.0", "R1 Back:r1Back:50.0:0.0",
|
||||
"R2 Front:r2Front:300:1.0", "R2 Back:r2Back:50.0:0.0",
|
||||
"R3 Front:r3Front:300:1.0", "R3 Back:r3Back:50.0:0.0"
|
||||
]
|
||||
ConfigSlider {
|
||||
label: qsTr(modelData.split(":")[0])
|
||||
integral: false
|
||||
config: workload.setupViews
|
||||
property: modelData.split(":")[1]
|
||||
max: modelData.split(":")[2]
|
||||
min: modelData.split(":")[3]
|
||||
Repeater {
|
||||
model: [
|
||||
"R1 Back:r1Back:50.0:0.0", " Front:r1Front:300:1.0",
|
||||
"R2 Back:r2Back:50.0:0.0", " Front:r2Front:300:1.0",
|
||||
"R3 Back:r3Back:50.0:0.0", " Front:r3Front:300:1.0"
|
||||
]
|
||||
ConfigSlider {
|
||||
label: qsTr(modelData.split(":")[0])
|
||||
integral: false
|
||||
config: workload.setupViews
|
||||
property: modelData.split(":")[1]
|
||||
max: modelData.split(":")[2]
|
||||
min: modelData.split(":")[3]
|
||||
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
anchors.left: parent.left
|
||||
anchors.right: parent.right
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Separator {}
|
||||
HifiControls.Label {
|
||||
text: "Display"
|
||||
|
|
Loading…
Reference in a new issue