Arg get me the feedback working!!!!

This commit is contained in:
samcake 2018-04-18 18:16:06 -07:00
parent d6b6645630
commit 52a4224442
7 changed files with 60 additions and 17 deletions

View file

@ -14,13 +14,39 @@
#include <workload/SpaceClassifier.h>
#include "PhysicsBoundary.h"
#pragma optimize( "[optimization-list]", off )
float wtf_adjust(float current, float timing) {
float error = (timing * 0.001f) - 2.0f;
if (error < 0.0f) {
current += 0.2f * (error) / 16.0f;
} else {
current += 0.1f * (error) / 16.0f;
}
void ControlViews::run(const workload::WorkloadContextPointer& renderContext, const Input& inputs, Output& outputs) {
const auto& inViews = inputs.getN<0>();
const auto& inTimings = inputs[1];
outputs = inViews;
if (current > 100.0f) {
current = 100.0f;
} else if (current < 5.0f) {
current = 5.0f;
}
return current;
}
void ControlViews::run(const workload::WorkloadContextPointer& runContext, const Input& inputs, Output& outputs) {
const auto& inViews = inputs.get0();
const auto& inTimings = inputs.get1();
auto& outViews = outputs;
outViews.clear();
outViews = inViews;
int i = 0;
for (auto& outView : outViews) {
auto& current = regionBackFronts[workload::Region::R2].y;
current = wtf_adjust(current, inTimings[0]);
outView.regions[workload::Region::R2].y = current;
workload::View::updateRegionsFromBackFronts(outView);
}
}
#pragma optimize( "[optimization-list]", on )
class WorkloadEngineBuilder {
public:
@ -35,9 +61,7 @@ public:
const auto usedViews = model.addJob<workload::SetupViews>("setupViews", inViews);
ControlViews::Input controlViewsIn;
controlViewsIn[0] = usedViews;
controlViewsIn[1] = inTimings;
const auto controlViewsIn = ControlViews::Input(usedViews, inTimings).asVarying();
const auto fixedViews = model.addJob<ControlViews>("controlViews", controlViewsIn);
const auto regionTrackerOut = model.addJob<workload::SpaceClassifierTask>("spaceClassifier", fixedViews);

View file

@ -58,8 +58,12 @@ public:
using Output = workload::Views;
using JobModel = workload::Job::ModelIO<ControlViews, Input, Output, Config>;
ControlViews() = default;
void configure(const Config& config) {}
void run(const workload::WorkloadContextPointer& renderContext, const Input& inputs, Output& outputs);
void run(const workload::WorkloadContextPointer& runContext, const Input& inputs, Output& outputs);
glm::vec2 regionBackFronts[workload::Region::NUM_VIEW_REGIONS + 1];
};
#endif // hifi_GameWorkload_h

View file

@ -88,4 +88,8 @@ void main(void) {
region = (0x000000FF & region);
varColor = vec4(colorWheel(float(region) / 4.0), proxy.sphere.w);
if (region == 4) {
gl_Position = vec4(0.0);
}
}

View file

@ -25,6 +25,7 @@ struct WorkloadView {
vec4 direction_far;
vec4 fov;
vec4 origin;
vec4 backFront[2];
vec4 regions[3];
};

View file

@ -41,7 +41,7 @@ Sphere View::evalRegionSphere(const View& view, float originRadius, float maxDis
return Sphere(view.origin + view.direction * center, radius);
}
void View::updateRegions(View& view) {
void View::updateRegionsDefault(View& view) {
std::vector<float> config(Region::NUM_VIEW_REGIONS * 2, 0.0f);
float refFar = 10.0f;
@ -52,11 +52,18 @@ void View::updateRegions(View& view) {
config[i * 2 + 1] = refFar * weight;
refFar *= 2.0f;
}
updateRegions(view, config.data());
updateRegionsFromBackFrontDistances(view, config.data());
}
void View::updateRegions(View& view, const float* configDistances) {
void View::updateRegionsFromBackFronts(View& view) {
for (int i = 0; i < Region::NUM_VIEW_REGIONS; i++) {
view.regions[i] = evalRegionSphere(view, configDistances[i * 2], configDistances[i * 2 + 1]);
view.regions[i] = evalRegionSphere(view, view.regionBackFronts[i].x, view.regionBackFronts[i].y);
}
}
void View::updateRegionsFromBackFrontDistances(View& view, const float* configDistances) {
for (int i = 0; i < Region::NUM_VIEW_REGIONS; i++) {
view.regionBackFronts[i] = glm::vec2(configDistances[i * 2], configDistances[i * 2 + 1]);
}
updateRegionsFromBackFronts(view);
}

View file

@ -47,6 +47,9 @@ public:
// Origin radius
float originRadius{ 0.5f };
// N regions distances
glm::vec2 regionBackFronts[Region::NUM_VIEW_REGIONS + 1];
// N regions spheres
Sphere regions[Region::NUM_VIEW_REGIONS];
@ -59,9 +62,9 @@ public:
static View evalFromFrustum(const ViewFrustum& frustum, const glm::vec3& offset = glm::vec3());
static Sphere evalRegionSphere(const View& view, float originRadius, float maxDistance);
static void updateRegions(View& view);
static void updateRegions(View& view, const float* configDistances);
static void updateRegionsDefault(View& view);
static void updateRegionsFromBackFronts(View& view);
static void updateRegionsFromBackFrontDistances(View& view, const float* configDistances);
};
using Views = std::vector<View>;

View file

@ -62,7 +62,7 @@ void SetupViews::run(const WorkloadContextPointer& renderContext, const Input& i
// Update regions based on the current config
for (auto& v : outViews) {
View::updateRegions(v, (float*) &data);
View::updateRegionsFromBackFrontDistances(v, (float*) &data);
}
// outViews is ready to be used