mirror of
https://github.com/overte-org/overte.git
synced 2025-04-06 22:32:57 +02:00
Trying to expose an array to js
This commit is contained in:
parent
ba29ebaeb0
commit
3ab0458d3a
3 changed files with 22 additions and 124 deletions
|
@ -5315,6 +5315,7 @@ void Application::update(float deltaTime) {
|
|||
|
||||
if (_physicsEnabled) {
|
||||
auto t0 = std::chrono::high_resolution_clock::now();
|
||||
auto t1 = t0;
|
||||
{
|
||||
PROFILE_RANGE(simulation_physics, "PrePhysics");
|
||||
PerformanceTimer perfTimer("prePhysics)");
|
||||
|
@ -5338,6 +5339,8 @@ void Application::update(float deltaTime) {
|
|||
|
||||
_entitySimulation->applyDynamicChanges();
|
||||
|
||||
t1 = std::chrono::high_resolution_clock::now();
|
||||
|
||||
avatarManager->getObjectsToRemoveFromPhysics(motionStates);
|
||||
_physicsEngine->removeObjects(motionStates);
|
||||
avatarManager->getObjectsToAddToPhysics(motionStates);
|
||||
|
@ -5350,6 +5353,7 @@ void Application::update(float deltaTime) {
|
|||
dynamic->prepareForPhysicsSimulation();
|
||||
});
|
||||
}
|
||||
auto t2 = std::chrono::high_resolution_clock::now();
|
||||
{
|
||||
PROFILE_RANGE(simulation_physics, "StepPhysics");
|
||||
PerformanceTimer perfTimer("stepPhysics");
|
||||
|
@ -5357,6 +5361,7 @@ void Application::update(float deltaTime) {
|
|||
_physicsEngine->stepSimulation();
|
||||
});
|
||||
}
|
||||
auto t3 = std::chrono::high_resolution_clock::now();
|
||||
{
|
||||
if (_physicsEngine->hasOutgoingChanges()) {
|
||||
{
|
||||
|
@ -5402,7 +5407,7 @@ void Application::update(float deltaTime) {
|
|||
// NOTE: the PhysicsEngine stats are written to stdout NOT to Qt log framework
|
||||
_physicsEngine->dumpStatsIfNecessary();
|
||||
}
|
||||
auto t1 = std::chrono::high_resolution_clock::now();
|
||||
auto t4 = std::chrono::high_resolution_clock::now();
|
||||
|
||||
if (!_aboutToQuit) {
|
||||
// NOTE: the getEntities()->update() call below will wait for lock
|
||||
|
@ -5410,11 +5415,16 @@ void Application::update(float deltaTime) {
|
|||
getEntities()->update(true); // update the models...
|
||||
}
|
||||
|
||||
auto t2 = std::chrono::high_resolution_clock::now();
|
||||
auto t5 = std::chrono::high_resolution_clock::now();
|
||||
|
||||
workload::Timings timings(6);
|
||||
timings[0] = (t4 - t0);
|
||||
timings[1] = (t5 - t4);
|
||||
timings[2] = (t4 - t3);
|
||||
timings[3] = (t3 - t2);
|
||||
timings[4] = (t2 - t1);
|
||||
timings[5] = (t1 - t0);
|
||||
|
||||
workload::Timings timings(2);
|
||||
timings[0] = (t1 - t0);
|
||||
timings[1] = (t2 - t1);
|
||||
_gameWorkload.updateSimulationTimings(timings);
|
||||
|
||||
}
|
||||
|
|
|
@ -43,123 +43,4 @@ public:
|
|||
workload::EnginePointer _engine;
|
||||
};
|
||||
|
||||
class ControlViewsConfig : public workload::Job::Config {
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(bool regulateViewRanges READ regulateViewRanges WRITE setRegulateViewRanges NOTIFY dirty)
|
||||
|
||||
Q_PROPERTY(float r1Timing READ r1Timing NOTIFY dirty)
|
||||
Q_PROPERTY(float r2Timing READ r2Timing NOTIFY dirty)
|
||||
Q_PROPERTY(float r3Timing READ r3Timing NOTIFY dirty)
|
||||
|
||||
Q_PROPERTY(float r1RangeBack READ r1RangeBack NOTIFY dirty)
|
||||
Q_PROPERTY(float r2RangeBack READ r2RangeBack NOTIFY dirty)
|
||||
Q_PROPERTY(float r3RangeBack READ r3RangeBack NOTIFY dirty)
|
||||
|
||||
Q_PROPERTY(float r1RangeFront READ r1RangeFront NOTIFY dirty)
|
||||
Q_PROPERTY(float r2RangeFront READ r2RangeFront NOTIFY dirty)
|
||||
Q_PROPERTY(float r3RangeFront READ r3RangeFront NOTIFY dirty)
|
||||
/*
|
||||
Q_PROPERTY(float r1MinRangeBack READ r1MinRangeBack WRITE setR1MinRangeBack NOTIFY dirty)
|
||||
Q_PROPERTY(float r2MinRangeBack READ r2MinRangeBack WRITE setR2MinRangeBack NOTIFY dirty)
|
||||
Q_PROPERTY(float r3MinRangeBack READ r3MinRangeBack WRITE setR3MinRangeBack NOTIFY dirty)
|
||||
|
||||
Q_PROPERTY(float r1MinRangeFront READ r1MinRangeFront WRITE setR1MinRangeFront NOTIFY dirty)
|
||||
Q_PROPERTY(float r2MinRangeFront READ r2MinRangeFront WRITE setR2MinRangeFront NOTIFY dirty)
|
||||
Q_PROPERTY(float r3MinRangeFront READ r3MinRangeFront WRITE setR3MinRangeFront NOTIFY dirty)
|
||||
|
||||
Q_PROPERTY(float r1MaxRangeBack READ r1MaxRangeBack WRITE setR1MaxRangeBack NOTIFY dirty)
|
||||
Q_PROPERTY(float r2MaxRangeBack READ r2MaxRangeBack WRITE setR2MaxRangeBack NOTIFY dirty)
|
||||
Q_PROPERTY(float r3MaxRangeBack READ r3MaxRangeBack WRITE setR3MaxRangeBack NOTIFY dirty)
|
||||
|
||||
Q_PROPERTY(float r1MaxRangeFront READ r1MaxRangeFront WRITE setR1MaxRangeFront NOTIFY dirty)
|
||||
Q_PROPERTY(float r2MaxRangeFront READ r2MaxRangeFront WRITE setR2MaxRangeFront NOTIFY dirty)
|
||||
Q_PROPERTY(float r3MaxRangeFront READ r3MaxRangeFront WRITE setR3MaxRangeFront NOTIFY dirty)
|
||||
|
||||
Q_PROPERTY(float r1SpeedDownBack READ r1SpeedDownBack WRITE setR1SpeedDownBack NOTIFY dirty)
|
||||
Q_PROPERTY(float r2SpeedDownBack READ r2SpeedDownBack WRITE setR2SpeedDownBack NOTIFY dirty)
|
||||
Q_PROPERTY(float r3SpeedDownBack READ r3SpeedDownBack WRITE setR3SpeedDownBack NOTIFY dirty)
|
||||
|
||||
Q_PROPERTY(float r1SpeedDownFront READ r1SpeedDownFront WRITE setR1SpeedDownFront NOTIFY dirty)
|
||||
Q_PROPERTY(float r2SpeedDownFront READ r2SpeedDownFront WRITE setR2SpeedDownFront NOTIFY dirty)
|
||||
Q_PROPERTY(float r3SpeedDownFront READ r3SpeedDownFront WRITE setR3SpeedDownFront NOTIFY dirty)
|
||||
|
||||
Q_PROPERTY(float r1SpeedUpBack READ r1SpeedUpBack WRITE setR1SpeedUpBack NOTIFY dirty)
|
||||
Q_PROPERTY(float r2SpeedUpBack READ r2SpeedUpBack WRITE setR2SpeedUpBack NOTIFY dirty)
|
||||
Q_PROPERTY(float r3SpeedUpBack READ r3SpeedUpBack WRITE setR3SpeedUpBack NOTIFY dirty)
|
||||
|
||||
Q_PROPERTY(float r1SpeedUpFront READ r1SpeedUpFront WRITE setR1SpeedUpFront NOTIFY dirty)
|
||||
Q_PROPERTY(float r2SpeedUpFront READ r2SpeedUpFront WRITE setR2SpeedUpFront NOTIFY dirty)
|
||||
Q_PROPERTY(float r3SpeedUpFront READ r3SpeedUpFront WRITE setR3SpeedUpFront NOTIFY dirty)*/
|
||||
|
||||
public:
|
||||
|
||||
bool regulateViewRanges() const { return data.regulateViewRanges; }
|
||||
void setRegulateViewRanges(bool use) { data.regulateViewRanges = use; emit dirty(); }
|
||||
|
||||
float r1Timing() const { return dataExport.timings[workload::Region::R1]; }
|
||||
float r2Timing() const { return dataExport.timings[workload::Region::R2]; }
|
||||
float r3Timing() const { return dataExport.timings[workload::Region::R3]; }
|
||||
|
||||
float r1RangeBack() const { return dataExport.ranges[workload::Region::R1].x; }
|
||||
float r2RangeBack() const { return dataExport.ranges[workload::Region::R2].x; }
|
||||
float r3RangeBack() const { return dataExport.ranges[workload::Region::R3].x; }
|
||||
|
||||
float r1RangeFront() const { return dataExport.ranges[workload::Region::R1].y; }
|
||||
float r2RangeFront() const { return dataExport.ranges[workload::Region::R2].y; }
|
||||
float r3RangeFront() const { return dataExport.ranges[workload::Region::R3].y; }
|
||||
|
||||
struct Data {
|
||||
bool regulateViewRanges{ true };
|
||||
} data;
|
||||
|
||||
struct DataExport {
|
||||
static const int SIZE{ workload::Region::NUM_VIEW_REGIONS };
|
||||
float timings[SIZE];
|
||||
glm::vec2 ranges[SIZE];
|
||||
} dataExport;
|
||||
|
||||
void emitDirty() { emit dirty(); }
|
||||
signals:
|
||||
void dirty();
|
||||
};
|
||||
|
||||
struct Regulator {
|
||||
using Timing_ns = std::chrono::nanoseconds;
|
||||
Timing_ns _budget{ std::chrono::milliseconds(2) };
|
||||
glm::vec2 _minRange{ 2.0f, 5.0f };
|
||||
glm::vec2 _maxRange{ 50.0f, 100.0f };
|
||||
|
||||
glm::vec2 _speedDown{ 0.2f };
|
||||
glm::vec2 _speedUp{ 0.1f };
|
||||
|
||||
|
||||
Regulator() {}
|
||||
Regulator(const Timing_ns& budget_ns, const glm::vec2& minRange, const glm::vec2& maxRange, const glm::vec2& speedDown, const glm::vec2& speedUp) :
|
||||
_budget(budget_ns), _minRange(minRange), _maxRange(maxRange), _speedDown(speedDown), _speedUp(speedUp) {}
|
||||
|
||||
glm::vec2 run(const Timing_ns& regulationDuration, const Timing_ns& measured, const glm::vec2& current);
|
||||
};
|
||||
|
||||
class ControlViews {
|
||||
public:
|
||||
using Config = ControlViewsConfig;
|
||||
using Input = workload::VaryingSet2<workload::Views, workload::Timings>;
|
||||
using Output = workload::Views;
|
||||
using JobModel = workload::Job::ModelIO<ControlViews, Input, Output, Config>;
|
||||
|
||||
ControlViews();
|
||||
|
||||
void configure(const Config& config);
|
||||
void run(const workload::WorkloadContextPointer& runContext, const Input& inputs, Output& outputs);
|
||||
|
||||
std::array<glm::vec2, workload::Region::NUM_VIEW_REGIONS> regionBackFronts;
|
||||
std::array<Regulator, workload::Region::NUM_VIEW_REGIONS> regionRegulators;
|
||||
|
||||
void regulateViews(workload::Views& views, const workload::Timings& timings);
|
||||
|
||||
protected:
|
||||
Config::Data _data;
|
||||
Config::DataExport _dataExport;
|
||||
};
|
||||
|
||||
#endif // hifi_GameWorkload_h
|
||||
|
|
|
@ -103,6 +103,7 @@ namespace workload {
|
|||
Q_OBJECT
|
||||
Q_PROPERTY(bool regulateViewRanges READ regulateViewRanges WRITE setRegulateViewRanges NOTIFY dirty)
|
||||
|
||||
|
||||
Q_PROPERTY(float r1Timing READ r1Timing NOTIFY dirty)
|
||||
Q_PROPERTY(float r2Timing READ r2Timing NOTIFY dirty)
|
||||
Q_PROPERTY(float r3Timing READ r3Timing NOTIFY dirty)
|
||||
|
@ -164,6 +165,7 @@ namespace workload {
|
|||
float r2RangeFront() const { return dataExport.ranges[workload::Region::R2].y; }
|
||||
float r3RangeFront() const { return dataExport.ranges[workload::Region::R3].y; }
|
||||
|
||||
|
||||
struct Data {
|
||||
bool regulateViewRanges{ true };
|
||||
} data;
|
||||
|
@ -172,9 +174,14 @@ namespace workload {
|
|||
static const int SIZE{ workload::Region::NUM_VIEW_REGIONS };
|
||||
float timings[SIZE];
|
||||
glm::vec2 ranges[SIZE];
|
||||
QVector<qreal> _timings { 6, 2.0 };
|
||||
|
||||
} dataExport;
|
||||
|
||||
void emitDirty() { emit dirty(); }
|
||||
|
||||
public slots:
|
||||
Q_INVOKABLE QVector<qreal> getTimings() const { return dataExport._timings; }
|
||||
signals:
|
||||
void dirty();
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue