mirror of
https://github.com/overte-org/overte.git
synced 2025-04-06 22:32:57 +02:00
Starting to move dynamically yeah
This commit is contained in:
parent
a6bd589f4f
commit
9b1a887469
6 changed files with 73 additions and 38 deletions
|
@ -15,8 +15,32 @@
|
|||
|
||||
#include "PhysicsBoundary.h"
|
||||
#pragma optimize( "[optimization-list]", off )
|
||||
|
||||
ControlViews::ControlViews() {
|
||||
regionBackFronts[0] = glm::vec2(2.0f, 10.0f);
|
||||
regionBackFronts[1] = glm::vec2(5.0f, 30.0f);
|
||||
regionBackFronts[2] = glm::vec2(10.0f, 100.0f);
|
||||
|
||||
}
|
||||
|
||||
void ControlViews::configure(const Config& config) {
|
||||
_data = config.data;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
if (_data.regulateViewRanges) {
|
||||
regulateViews(outViews, inTimings);
|
||||
}
|
||||
}
|
||||
|
||||
float wtf_adjust(float current, float timing) {
|
||||
float error = (timing * 0.001f) - 2.0f;
|
||||
float error = -((timing * 0.001f) - 2.0f);
|
||||
if (error < 0.0f) {
|
||||
current += 0.2f * (error) / 16.0f;
|
||||
} else {
|
||||
|
@ -30,22 +54,25 @@ float wtf_adjust(float current, float timing) {
|
|||
}
|
||||
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;
|
||||
|
||||
|
||||
|
||||
void ControlViews::regulateViews(workload::Views& outViews, const workload::Timings& timings) {
|
||||
|
||||
for (auto& outView : outViews) {
|
||||
for (int r = 0; r < workload::Region::NUM_VIEW_REGIONS; r++) {
|
||||
outView.regionBackFronts[r] = regionBackFronts[r];
|
||||
}
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
for (auto& outView : outViews) {
|
||||
auto& current = regionBackFronts[workload::Region::R2].y;
|
||||
auto newCurrent = wtf_adjust(current, inTimings[0]);
|
||||
outView.regions[workload::Region::R2].y = newCurrent;
|
||||
auto current = regionBackFronts[workload::Region::R2].y;
|
||||
auto newCurrent = wtf_adjust(current, timings[0]);
|
||||
regionBackFronts[workload::Region::R2].y = newCurrent;
|
||||
outView.regionBackFronts[workload::Region::R2].y = newCurrent;
|
||||
workload::View::updateRegionsFromBackFronts(outView);
|
||||
}
|
||||
}
|
||||
|
||||
#pragma optimize( "[optimization-list]", on )
|
||||
|
||||
class WorkloadEngineBuilder {
|
||||
|
|
|
@ -45,8 +45,17 @@ public:
|
|||
|
||||
class ControlViewsConfig : public workload::Job::Config {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool regulateViewRanges READ regulateViewRanges WRITE setRegulateViewRanges NOTIFY dirty)
|
||||
|
||||
public:
|
||||
|
||||
bool regulateViewRanges() const { return data.regulateViewRanges; }
|
||||
void setRegulateViewRanges(bool use) { data.regulateViewRanges = use; emit dirty(); }
|
||||
|
||||
struct Data {
|
||||
bool regulateViewRanges{ true };
|
||||
|
||||
} data;
|
||||
signals:
|
||||
void dirty();
|
||||
};
|
||||
|
@ -58,12 +67,17 @@ public:
|
|||
using Output = workload::Views;
|
||||
using JobModel = workload::Job::ModelIO<ControlViews, Input, Output, Config>;
|
||||
|
||||
ControlViews() = default;
|
||||
ControlViews();
|
||||
|
||||
void configure(const Config& config) {}
|
||||
void configure(const Config& config);
|
||||
void run(const workload::WorkloadContextPointer& runContext, const Input& inputs, Output& outputs);
|
||||
glm::vec2 regionBackFronts[workload::Region::NUM_VIEW_REGIONS + 1];
|
||||
|
||||
|
||||
void regulateViews(workload::Views& views, const workload::Timings& timings);
|
||||
|
||||
protected:
|
||||
Config::Data _data;
|
||||
};
|
||||
|
||||
#endif // hifi_GameWorkload_h
|
||||
|
|
|
@ -190,18 +190,21 @@ const VectorOfMotionStates& PhysicalEntitySimulation::getObjectsToRemoveFromPhys
|
|||
for (auto entity: _entitiesToRemoveFromPhysics) {
|
||||
EntityMotionState* motionState = static_cast<EntityMotionState*>(entity->getPhysicsInfo());
|
||||
assert(motionState);
|
||||
// TODO CLEan this, just a n extra check to avoid the crash that shouldn;t happen
|
||||
if (motionState) {
|
||||
|
||||
_entitiesToAddToPhysics.remove(entity);
|
||||
if (entity->isDead() && entity->getElement()) {
|
||||
_deadEntities.insert(entity);
|
||||
_entitiesToAddToPhysics.remove(entity);
|
||||
if (entity->isDead() && entity->getElement()) {
|
||||
_deadEntities.insert(entity);
|
||||
}
|
||||
|
||||
_incomingChanges.remove(motionState);
|
||||
removeOwnershipData(motionState);
|
||||
_physicalObjects.remove(motionState);
|
||||
|
||||
// remember this motionState and delete it later (after removing its RigidBody from the PhysicsEngine)
|
||||
_objectsToDelete.push_back(motionState);
|
||||
}
|
||||
|
||||
_incomingChanges.remove(motionState);
|
||||
removeOwnershipData(motionState);
|
||||
_physicalObjects.remove(motionState);
|
||||
|
||||
// remember this motionState and delete it later (after removing its RigidBody from the PhysicsEngine)
|
||||
_objectsToDelete.push_back(motionState);
|
||||
}
|
||||
_entitiesToRemoveFromPhysics.clear();
|
||||
return _objectsToDelete;
|
||||
|
|
|
@ -62,11 +62,7 @@ void SetupViews::run(const WorkloadContextPointer& renderContext, const Input& i
|
|||
|
||||
// Update regions based on the current config
|
||||
for (auto& v : outViews) {
|
||||
if (data.applyViewRanges) {
|
||||
View::updateRegionsFromBackFrontDistances(v, (float*) &data);
|
||||
} else {
|
||||
View::updateRegionsFromBackFronts(v);
|
||||
}
|
||||
View::updateRegionsFromBackFrontDistances(v, (float*) &data);
|
||||
}
|
||||
|
||||
// outViews is ready to be used
|
||||
|
|
|
@ -27,7 +27,7 @@ namespace workload {
|
|||
Q_PROPERTY(bool forceViewHorizontal READ forceViewHorizontal WRITE setForceViewHorizontal NOTIFY dirty)
|
||||
|
||||
Q_PROPERTY(bool simulateSecondaryCamera READ simulateSecondaryCamera WRITE setSimulateSecondaryCamera NOTIFY dirty)
|
||||
Q_PROPERTY(bool applyViewRanges READ applyViewRanges WRITE setApplyViewRanges NOTIFY dirty)
|
||||
|
||||
public:
|
||||
|
||||
|
||||
|
@ -55,9 +55,6 @@ namespace workload {
|
|||
bool simulateSecondaryCamera() const { return data.simulateSecondaryCamera; }
|
||||
void setSimulateSecondaryCamera(bool use) { data.simulateSecondaryCamera = use; emit dirty(); }
|
||||
|
||||
bool applyViewRanges() const { return data.applyViewRanges; }
|
||||
void setApplyViewRanges(bool use) { data.applyViewRanges = use; emit dirty(); }
|
||||
|
||||
struct Data {
|
||||
float r1Back { 2.0f };
|
||||
float r1Front { 10.0f };
|
||||
|
@ -72,8 +69,6 @@ namespace workload {
|
|||
bool useAvatarView{ false };
|
||||
bool forceViewHorizontal{ false };
|
||||
bool simulateSecondaryCamera{ false };
|
||||
bool applyViewRanges{ true };
|
||||
|
||||
} data;
|
||||
|
||||
signals:
|
||||
|
|
|
@ -113,9 +113,9 @@ Rectangle {
|
|||
Separator {}
|
||||
HifiControls.CheckBox {
|
||||
boxSize: 20
|
||||
text: "Apply Front Back Ranges"
|
||||
checked: Workload.getConfig("setupViews")["applyViewRanges"]
|
||||
onCheckedChanged: { Workload.getConfig("setupViews")["applyViewRanges"] = checked; }
|
||||
text: "Regulate View Ranges"
|
||||
checked: Workload.getConfig("controlViews")["regulateViewRanges"]
|
||||
onCheckedChanged: { Workload.getConfig("controlViews")["regulateViewRanges"] = checked; }
|
||||
}
|
||||
|
||||
RowLayout {
|
||||
|
|
Loading…
Reference in a new issue