mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 13:49:12 +02:00
Merge pull request #15880 from AndrewMeadows/fix-safe-landing-redux
BUGZ-863: wait for objects to be added to physics before completing SafeLanding
This commit is contained in:
commit
8ce64d95ab
14 changed files with 84 additions and 58 deletions
|
@ -201,6 +201,7 @@ void OtherAvatar::computeShapeLOD() {
|
||||||
break;
|
break;
|
||||||
case workload::Region::UNKNOWN:
|
case workload::Region::UNKNOWN:
|
||||||
case workload::Region::INVALID:
|
case workload::Region::INVALID:
|
||||||
|
case workload::Region::R4:
|
||||||
case workload::Region::R3:
|
case workload::Region::R3:
|
||||||
default:
|
default:
|
||||||
newLOD = BodyLOD::Sphere;
|
newLOD = BodyLOD::Sphere;
|
||||||
|
|
|
@ -203,8 +203,22 @@ bool SafeLanding::isEntityPhysicsReady(const EntityItemPointer& entity) {
|
||||||
if (hasAABox && downloadedCollisionTypes.count(modelEntity->getShapeType()) != 0) {
|
if (hasAABox && downloadedCollisionTypes.count(modelEntity->getShapeType()) != 0) {
|
||||||
auto space = _entityTreeRenderer->getWorkloadSpace();
|
auto space = _entityTreeRenderer->getWorkloadSpace();
|
||||||
uint8_t region = space ? space->getRegion(entity->getSpaceIndex()) : (uint8_t)workload::Region::INVALID;
|
uint8_t region = space ? space->getRegion(entity->getSpaceIndex()) : (uint8_t)workload::Region::INVALID;
|
||||||
bool shouldBePhysical = region < workload::Region::R3 && entity->shouldBePhysical();
|
|
||||||
return (!shouldBePhysical || entity->isInPhysicsSimulation() || modelEntity->computeShapeFailedToLoad());
|
// Note: the meanings of the workload regions are:
|
||||||
|
// R1 = in physics simulation and willing to own simulation
|
||||||
|
// R2 = in physics simulation but does NOT want to own simulation
|
||||||
|
// R3 = not in physics simulation but kinematically animated when velocities are non-zero
|
||||||
|
// R4 = sorted by workload and found to be outside R3
|
||||||
|
// UNKNOWN = known to workload but not yet sorted
|
||||||
|
// INVALID = not known to workload
|
||||||
|
// So any entity sorted into R3 or R4 is definitelyNotPhysical
|
||||||
|
|
||||||
|
bool definitelyNotPhysical = region == workload::Region::R3 ||
|
||||||
|
region == workload::Region::R4 ||
|
||||||
|
!entity->shouldBePhysical() ||
|
||||||
|
modelEntity->unableToLoadCollisionShape();
|
||||||
|
bool definitelyPhysical = entity->isInPhysicsSimulation();
|
||||||
|
return definitelyNotPhysical || definitelyPhysical;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -282,27 +282,26 @@ bool RenderableModelEntityItem::findDetailedParabolaIntersection(const glm::vec3
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderableModelEntityItem::fetchCollisionGeometryResource() {
|
void RenderableModelEntityItem::fetchCollisionGeometryResource() {
|
||||||
_compoundShapeResource = DependencyManager::get<ModelCache>()->getCollisionGeometryResource(getCollisionShapeURL());
|
_collisionGeometryResource = DependencyManager::get<ModelCache>()->getCollisionGeometryResource(getCollisionShapeURL());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RenderableModelEntityItem::computeShapeFailedToLoad() {
|
bool RenderableModelEntityItem::unableToLoadCollisionShape() {
|
||||||
if (!_compoundShapeResource) {
|
if (!_collisionGeometryResource) {
|
||||||
fetchCollisionGeometryResource();
|
fetchCollisionGeometryResource();
|
||||||
}
|
}
|
||||||
|
return (_collisionGeometryResource && _collisionGeometryResource->isFailed());
|
||||||
return (_compoundShapeResource && _compoundShapeResource->isFailed());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderableModelEntityItem::setShapeType(ShapeType type) {
|
void RenderableModelEntityItem::setShapeType(ShapeType type) {
|
||||||
ModelEntityItem::setShapeType(type);
|
ModelEntityItem::setShapeType(type);
|
||||||
auto shapeType = getShapeType();
|
auto shapeType = getShapeType();
|
||||||
if (shapeType == SHAPE_TYPE_COMPOUND || shapeType == SHAPE_TYPE_SIMPLE_COMPOUND) {
|
if (shapeType == SHAPE_TYPE_COMPOUND || shapeType == SHAPE_TYPE_SIMPLE_COMPOUND) {
|
||||||
if (!_compoundShapeResource && !getCollisionShapeURL().isEmpty()) {
|
if (!_collisionGeometryResource && !getCollisionShapeURL().isEmpty()) {
|
||||||
fetchCollisionGeometryResource();
|
fetchCollisionGeometryResource();
|
||||||
}
|
}
|
||||||
} else if (_compoundShapeResource && !getCompoundShapeURL().isEmpty()) {
|
} else if (_collisionGeometryResource && !getCompoundShapeURL().isEmpty()) {
|
||||||
// the compoundURL has been set but the shapeType does not agree
|
// the compoundURL has been set but the shapeType does not agree
|
||||||
_compoundShapeResource.reset();
|
_collisionGeometryResource.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -333,11 +332,11 @@ bool RenderableModelEntityItem::isReadyToComputeShape() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (model->isLoaded()) {
|
if (model->isLoaded()) {
|
||||||
if (!shapeURL.isEmpty() && !_compoundShapeResource) {
|
if (!shapeURL.isEmpty() && !_collisionGeometryResource) {
|
||||||
const_cast<RenderableModelEntityItem*>(this)->fetchCollisionGeometryResource();
|
const_cast<RenderableModelEntityItem*>(this)->fetchCollisionGeometryResource();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_compoundShapeResource && _compoundShapeResource->isLoaded()) {
|
if (_collisionGeometryResource && _collisionGeometryResource->isLoaded()) {
|
||||||
// we have both URLs AND both geometries AND they are both fully loaded.
|
// we have both URLs AND both geometries AND they are both fully loaded.
|
||||||
if (_needsInitialSimulation) {
|
if (_needsInitialSimulation) {
|
||||||
// the _model's offset will be wrong until _needsInitialSimulation is false
|
// the _model's offset will be wrong until _needsInitialSimulation is false
|
||||||
|
@ -368,7 +367,7 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& shapeInfo) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == SHAPE_TYPE_COMPOUND) {
|
if (type == SHAPE_TYPE_COMPOUND) {
|
||||||
if (!_compoundShapeResource || !_compoundShapeResource->isLoaded()) {
|
if (!_collisionGeometryResource || !_collisionGeometryResource->isLoaded()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -376,8 +375,8 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& shapeInfo) {
|
||||||
|
|
||||||
// should never fall in here when collision model not fully loaded
|
// should never fall in here when collision model not fully loaded
|
||||||
// TODO: assert that all geometries exist and are loaded
|
// TODO: assert that all geometries exist and are loaded
|
||||||
//assert(_model && _model->isLoaded() && _compoundShapeResource && _compoundShapeResource->isLoaded());
|
//assert(_model && _model->isLoaded() && _collisionGeometryResource && _collisionGeometryResource->isLoaded());
|
||||||
const HFMModel& collisionGeometry = _compoundShapeResource->getHFMModel();
|
const HFMModel& collisionGeometry = _collisionGeometryResource->getHFMModel();
|
||||||
|
|
||||||
ShapeInfo::PointCollection& pointCollection = shapeInfo.getPointCollection();
|
ShapeInfo::PointCollection& pointCollection = shapeInfo.getPointCollection();
|
||||||
pointCollection.clear();
|
pointCollection.clear();
|
||||||
|
@ -499,7 +498,7 @@ void RenderableModelEntityItem::computeShapeInfo(ShapeInfo& shapeInfo) {
|
||||||
|
|
||||||
std::vector<std::shared_ptr<const graphics::Mesh>> meshes;
|
std::vector<std::shared_ptr<const graphics::Mesh>> meshes;
|
||||||
if (type == SHAPE_TYPE_SIMPLE_COMPOUND) {
|
if (type == SHAPE_TYPE_SIMPLE_COMPOUND) {
|
||||||
auto& hfmMeshes = _compoundShapeResource->getHFMModel().meshes;
|
auto& hfmMeshes = _collisionGeometryResource->getHFMModel().meshes;
|
||||||
meshes.reserve(hfmMeshes.size());
|
meshes.reserve(hfmMeshes.size());
|
||||||
for (auto& hfmMesh : hfmMeshes) {
|
for (auto& hfmMesh : hfmMeshes) {
|
||||||
meshes.push_back(hfmMesh._mesh);
|
meshes.push_back(hfmMesh._mesh);
|
||||||
|
@ -727,10 +726,10 @@ int RenderableModelEntityItem::avatarJointIndex(int modelJointIndex) {
|
||||||
|
|
||||||
bool RenderableModelEntityItem::contains(const glm::vec3& point) const {
|
bool RenderableModelEntityItem::contains(const glm::vec3& point) const {
|
||||||
auto model = getModel();
|
auto model = getModel();
|
||||||
if (EntityItem::contains(point) && model && _compoundShapeResource && _compoundShapeResource->isLoaded()) {
|
if (EntityItem::contains(point) && model && _collisionGeometryResource && _collisionGeometryResource->isLoaded()) {
|
||||||
glm::mat4 worldToHFMMatrix = model->getWorldToHFMMatrix();
|
glm::mat4 worldToHFMMatrix = model->getWorldToHFMMatrix();
|
||||||
glm::vec3 hfmPoint = worldToHFMMatrix * glm::vec4(point, 1.0f);
|
glm::vec3 hfmPoint = worldToHFMMatrix * glm::vec4(point, 1.0f);
|
||||||
return _compoundShapeResource->getHFMModel().convexHullContains(hfmPoint);
|
return _collisionGeometryResource->getHFMModel().convexHullContains(hfmPoint);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -79,7 +79,7 @@ public:
|
||||||
|
|
||||||
virtual bool isReadyToComputeShape() const override;
|
virtual bool isReadyToComputeShape() const override;
|
||||||
virtual void computeShapeInfo(ShapeInfo& shapeInfo) override;
|
virtual void computeShapeInfo(ShapeInfo& shapeInfo) override;
|
||||||
bool computeShapeFailedToLoad();
|
bool unableToLoadCollisionShape();
|
||||||
|
|
||||||
virtual bool contains(const glm::vec3& point) const override;
|
virtual bool contains(const glm::vec3& point) const override;
|
||||||
void stopModelOverrideIfNoParent();
|
void stopModelOverrideIfNoParent();
|
||||||
|
@ -120,7 +120,7 @@ private:
|
||||||
bool readyToAnimate() const;
|
bool readyToAnimate() const;
|
||||||
void fetchCollisionGeometryResource();
|
void fetchCollisionGeometryResource();
|
||||||
|
|
||||||
GeometryResource::Pointer _compoundShapeResource;
|
GeometryResource::Pointer _collisionGeometryResource;
|
||||||
std::vector<int> _jointMap;
|
std::vector<int> _jointMap;
|
||||||
QVariantMap _originalTextures;
|
QVariantMap _originalTextures;
|
||||||
bool _jointMapCompleted { false };
|
bool _jointMapCompleted { false };
|
||||||
|
|
|
@ -49,9 +49,9 @@ void PhysicalEntitySimulation::addEntityInternal(EntityItemPointer entity) {
|
||||||
assert(entity);
|
assert(entity);
|
||||||
assert(!entity->isDead());
|
assert(!entity->isDead());
|
||||||
uint8_t region = _space->getRegion(entity->getSpaceIndex());
|
uint8_t region = _space->getRegion(entity->getSpaceIndex());
|
||||||
bool shouldBePhysical = region < workload::Region::R3 && entity->shouldBePhysical();
|
bool maybeShouldBePhysical = (region < workload::Region::R3 || region == workload::Region::UNKNOWN) && entity->shouldBePhysical();
|
||||||
bool canBeKinematic = region <= workload::Region::R3;
|
bool canBeKinematic = region <= workload::Region::R3;
|
||||||
if (shouldBePhysical) {
|
if (maybeShouldBePhysical) {
|
||||||
EntityMotionState* motionState = static_cast<EntityMotionState*>(entity->getPhysicsInfo());
|
EntityMotionState* motionState = static_cast<EntityMotionState*>(entity->getPhysicsInfo());
|
||||||
if (motionState) {
|
if (motionState) {
|
||||||
motionState->setRegion(region);
|
motionState->setRegion(region);
|
||||||
|
@ -330,6 +330,18 @@ void PhysicalEntitySimulation::buildMotionStatesForEntitiesThatNeedThem() {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint8_t region = _space->getRegion(entity->getSpaceIndex());
|
||||||
|
if (region == workload::Region::UNKNOWN) {
|
||||||
|
// the workload hasn't categorized it yet --> skip for later
|
||||||
|
++entityItr;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (region > workload::Region::R2) {
|
||||||
|
// not in physical zone --> remove from list
|
||||||
|
entityItr = _entitiesToAddToPhysics.erase(entityItr);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if (entity->isReadyToComputeShape()) {
|
if (entity->isReadyToComputeShape()) {
|
||||||
ShapeRequest shapeRequest(entity);
|
ShapeRequest shapeRequest(entity);
|
||||||
ShapeRequests::iterator requestItr = _shapeRequests.find(shapeRequest);
|
ShapeRequests::iterator requestItr = _shapeRequests.find(shapeRequest);
|
||||||
|
|
|
@ -18,17 +18,17 @@ public:
|
||||||
using Type = uint8_t;
|
using Type = uint8_t;
|
||||||
|
|
||||||
enum Name : uint8_t {
|
enum Name : uint8_t {
|
||||||
R1 = 0,
|
R1 = 0, // R1 = in physics simulation and client will bid for simulation ownership
|
||||||
R2,
|
R2, // R2 = in physics simulation but client prefers to NOT have simulation ownership
|
||||||
R3,
|
R3, // R3 = are NOT in physics simulation but yes kinematically animated when velocities are non-zero
|
||||||
UNKNOWN,
|
R4, // R4 = known to workload but outside R3, not in physics, not animated if moving
|
||||||
INVALID,
|
UNKNOWN, // UNKNOWN = known to workload but unsorted
|
||||||
|
INVALID, // INVALID = not known to workload
|
||||||
};
|
};
|
||||||
|
|
||||||
static const uint8_t NUM_CLASSIFICATIONS = 4;
|
static constexpr uint32_t NUM_KNOWN_REGIONS = uint32_t(Region::R4 - Region::R1 + 1); // R1 through R4 inclusive
|
||||||
static const uint8_t NUM_TRANSITIONS = NUM_CLASSIFICATIONS * (NUM_CLASSIFICATIONS - 1);
|
static constexpr uint32_t NUM_TRACKED_REGIONS = uint32_t(Region::R3 - Region::R1 + 1); // R1 through R3 inclusive
|
||||||
|
static const uint8_t NUM_REGION_TRANSITIONS = NUM_KNOWN_REGIONS * (NUM_KNOWN_REGIONS - 1);
|
||||||
static const uint8_t NUM_VIEW_REGIONS = (NUM_CLASSIFICATIONS - 1);
|
|
||||||
|
|
||||||
static uint8_t computeTransitionIndex(uint8_t prevIndex, uint8_t newIndex);
|
static uint8_t computeTransitionIndex(uint8_t prevIndex, uint8_t newIndex);
|
||||||
|
|
||||||
|
@ -62,13 +62,13 @@ inline uint8_t Region::computeTransitionIndex(uint8_t prevIndex, uint8_t newInde
|
||||||
// 3 | | | | |
|
// 3 | | | | |
|
||||||
// | 9 | 10 | 11 | -1 |
|
// | 9 | 10 | 11 | -1 |
|
||||||
// +-------+-------+-------+-------+
|
// +-------+-------+-------+-------+
|
||||||
uint8_t p = prevIndex + Region::NUM_CLASSIFICATIONS * newIndex;
|
uint8_t p = prevIndex + Region::NUM_KNOWN_REGIONS * newIndex;
|
||||||
if (0 == (p % (Region::NUM_CLASSIFICATIONS + 1))) {
|
if (0 == (p % (Region::NUM_KNOWN_REGIONS + 1))) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
return p - (1 + p / (Region::NUM_CLASSIFICATIONS + 1));
|
return p - (1 + p / (Region::NUM_KNOWN_REGIONS + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace workload
|
} // namespace workload
|
||||||
|
|
||||||
#endif // hifi_workload_Region_h
|
#endif // hifi_workload_Region_h
|
||||||
|
|
|
@ -28,7 +28,9 @@ void RegionState::run(const workload::WorkloadContextPointer& renderContext, con
|
||||||
// ...
|
// ...
|
||||||
// inputs[2N] = vector of ids exiting region N
|
// inputs[2N] = vector of ids exiting region N
|
||||||
// inputs[2N + 1] = vector of ids entering region N
|
// inputs[2N + 1] = vector of ids entering region N
|
||||||
assert(inputs.size() == 2 * Region::UNKNOWN);
|
//
|
||||||
|
// But we only pass inputs for R1 through R3
|
||||||
|
assert(inputs.size() == 2 * RegionState::NUM_REGIONS_TRACKED);
|
||||||
|
|
||||||
// The id's in each vector are sorted in ascending order
|
// The id's in each vector are sorted in ascending order
|
||||||
// because the source vectors are scanned in ascending order.
|
// because the source vectors are scanned in ascending order.
|
||||||
|
|
|
@ -53,9 +53,7 @@ namespace workload {
|
||||||
using Inputs = IndexVectors;
|
using Inputs = IndexVectors;
|
||||||
using JobModel = workload::Job::ModelI<RegionState, Inputs, Config>;
|
using JobModel = workload::Job::ModelI<RegionState, Inputs, Config>;
|
||||||
|
|
||||||
RegionState() {
|
RegionState() { _state.resize(workload::Region::NUM_TRACKED_REGIONS); }
|
||||||
_state.resize(Region::UNKNOWN);
|
|
||||||
}
|
|
||||||
|
|
||||||
void configure(const Config& config);
|
void configure(const Config& config);
|
||||||
void run(const workload::WorkloadContextPointer& renderContext, const Inputs& inputs);
|
void run(const workload::WorkloadContextPointer& renderContext, const Inputs& inputs);
|
||||||
|
|
|
@ -33,15 +33,15 @@ void RegionTracker::run(const WorkloadContextPointer& context, Outputs& outputs)
|
||||||
//Changes changes;
|
//Changes changes;
|
||||||
space->categorizeAndGetChanges(outChanges);
|
space->categorizeAndGetChanges(outChanges);
|
||||||
|
|
||||||
// use exit/enter lists for each region less than Region::UNKNOWN
|
// use exit/enter lists for each region less than Region::R4
|
||||||
outRegionChanges.resize(2 * (workload::Region::NUM_CLASSIFICATIONS - 1));
|
outRegionChanges.resize(2 * workload::Region::NUM_TRACKED_REGIONS);
|
||||||
for (uint32_t i = 0; i < outChanges.size(); ++i) {
|
for (uint32_t i = 0; i < outChanges.size(); ++i) {
|
||||||
Space::Change& change = outChanges[i];
|
Space::Change& change = outChanges[i];
|
||||||
if (change.prevRegion < Region::UNKNOWN) {
|
if (change.prevRegion < Region::R4) {
|
||||||
// EXIT list index = 2 * regionIndex
|
// EXIT list index = 2 * regionIndex
|
||||||
outRegionChanges[2 * change.prevRegion].push_back(change.proxyId);
|
outRegionChanges[2 * change.prevRegion].push_back(change.proxyId);
|
||||||
}
|
}
|
||||||
if (change.region < Region::UNKNOWN) {
|
if (change.region < Region::R4) {
|
||||||
// ENTER list index = 2 * regionIndex + 1
|
// ENTER list index = 2 * regionIndex + 1
|
||||||
outRegionChanges[2 * change.region + 1].push_back(change.proxyId);
|
outRegionChanges[2 * change.region + 1].push_back(change.proxyId);
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,7 +99,7 @@ void Space::categorizeAndGetChanges(std::vector<Space::Change>& changes) {
|
||||||
if (proxy.region < Region::INVALID) {
|
if (proxy.region < Region::INVALID) {
|
||||||
glm::vec3 proxyCenter = glm::vec3(proxy.sphere);
|
glm::vec3 proxyCenter = glm::vec3(proxy.sphere);
|
||||||
float proxyRadius = proxy.sphere.w;
|
float proxyRadius = proxy.sphere.w;
|
||||||
uint8_t region = Region::UNKNOWN;
|
uint8_t region = Region::R4;
|
||||||
for (uint32_t j = 0; j < numViews; ++j) {
|
for (uint32_t j = 0; j < numViews; ++j) {
|
||||||
auto& view = _views[j];
|
auto& view = _views[j];
|
||||||
// for each 'view' we need only increment 'k' below the current value of 'region'
|
// for each 'view' we need only increment 'k' below the current value of 'region'
|
||||||
|
|
|
@ -42,11 +42,11 @@ Sphere View::evalRegionSphere(const View& view, float originRadius, float maxDis
|
||||||
}
|
}
|
||||||
|
|
||||||
void View::updateRegionsDefault(View& view) {
|
void View::updateRegionsDefault(View& view) {
|
||||||
std::vector<float> config(Region::NUM_VIEW_REGIONS * 2, 0.0f);
|
std::vector<float> config(Region::NUM_TRACKED_REGIONS * 2, 0.0f);
|
||||||
|
|
||||||
float refFar = 10.0f;
|
float refFar = 10.0f;
|
||||||
float refClose = 2.0f;
|
float refClose = 2.0f;
|
||||||
for (int i = 0; i < Region::NUM_VIEW_REGIONS; i++) {
|
for (int i = 0; i < (int)Region::NUM_TRACKED_REGIONS; i++) {
|
||||||
float weight = i + 1.0f;
|
float weight = i + 1.0f;
|
||||||
config[i * 2] = refClose;
|
config[i * 2] = refClose;
|
||||||
config[i * 2 + 1] = refFar * weight;
|
config[i * 2 + 1] = refFar * weight;
|
||||||
|
@ -56,13 +56,13 @@ void View::updateRegionsDefault(View& view) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void View::updateRegionsFromBackFronts(View& view) {
|
void View::updateRegionsFromBackFronts(View& view) {
|
||||||
for (int i = 0; i < Region::NUM_VIEW_REGIONS; i++) {
|
for (int i = 0; i < (int)Region::NUM_TRACKED_REGIONS; i++) {
|
||||||
view.regions[i] = evalRegionSphere(view, view.regionBackFronts[i].x, view.regionBackFronts[i].y);
|
view.regions[i] = evalRegionSphere(view, view.regionBackFronts[i].x, view.regionBackFronts[i].y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void View::updateRegionsFromBackFrontDistances(View& view, const float* configDistances) {
|
void View::updateRegionsFromBackFrontDistances(View& view, const float* configDistances) {
|
||||||
for (int i = 0; i < Region::NUM_VIEW_REGIONS; i++) {
|
for (int i = 0; i < (int)Region::NUM_TRACKED_REGIONS; i++) {
|
||||||
view.regionBackFronts[i] = glm::vec2(configDistances[i * 2], configDistances[i * 2 + 1]);
|
view.regionBackFronts[i] = glm::vec2(configDistances[i * 2], configDistances[i * 2 + 1]);
|
||||||
}
|
}
|
||||||
updateRegionsFromBackFronts(view);
|
updateRegionsFromBackFronts(view);
|
||||||
|
|
|
@ -48,10 +48,10 @@ public:
|
||||||
float originRadius{ 0.5f };
|
float originRadius{ 0.5f };
|
||||||
|
|
||||||
// N regions distances
|
// N regions distances
|
||||||
glm::vec2 regionBackFronts[Region::NUM_VIEW_REGIONS + 1];
|
glm::vec2 regionBackFronts[Region::NUM_TRACKED_REGIONS];
|
||||||
|
|
||||||
// N regions spheres
|
// N regions spheres
|
||||||
Sphere regions[Region::NUM_VIEW_REGIONS];
|
Sphere regions[Region::NUM_TRACKED_REGIONS];
|
||||||
|
|
||||||
// Set fov properties from angle
|
// Set fov properties from angle
|
||||||
void setFov(float angleRad);
|
void setFov(float angleRad);
|
||||||
|
|
|
@ -82,7 +82,7 @@ void SetupViews::run(const WorkloadContextPointer& renderContext, const Input& i
|
||||||
|
|
||||||
|
|
||||||
ControlViews::ControlViews() {
|
ControlViews::ControlViews() {
|
||||||
for (int32_t i = 0; i < workload::Region::NUM_VIEW_REGIONS; i++) {
|
for (uint32_t i = 0; i < workload::Region::NUM_TRACKED_REGIONS; i++) {
|
||||||
regionBackFronts[i] = MIN_VIEW_BACK_FRONTS[i];
|
regionBackFronts[i] = MIN_VIEW_BACK_FRONTS[i];
|
||||||
regionRegulators[i] = Regulator(std::chrono::milliseconds(2), MIN_VIEW_BACK_FRONTS[i], MAX_VIEW_BACK_FRONTS[i], glm::vec2(RELATIVE_STEP_DOWN), glm::vec2(RELATIVE_STEP_UP));
|
regionRegulators[i] = Regulator(std::chrono::milliseconds(2), MIN_VIEW_BACK_FRONTS[i], MAX_VIEW_BACK_FRONTS[i], glm::vec2(RELATIVE_STEP_DOWN), glm::vec2(RELATIVE_STEP_UP));
|
||||||
}
|
}
|
||||||
|
@ -166,7 +166,7 @@ glm::vec2 Regulator::clamp(const glm::vec2& backFront) const {
|
||||||
|
|
||||||
void ControlViews::regulateViews(workload::Views& outViews, const workload::Timings& timings) {
|
void ControlViews::regulateViews(workload::Views& outViews, const workload::Timings& timings) {
|
||||||
for (auto& outView : outViews) {
|
for (auto& outView : outViews) {
|
||||||
for (int32_t r = 0; r < workload::Region::NUM_VIEW_REGIONS; r++) {
|
for (uint32_t r = 0; r < workload::Region::NUM_TRACKED_REGIONS; r++) {
|
||||||
outView.regionBackFronts[r] = regionBackFronts[r];
|
outView.regionBackFronts[r] = regionBackFronts[r];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -198,13 +198,13 @@ void ControlViews::enforceRegionContainment() {
|
||||||
// and each region should never exceed its min/max limits
|
// and each region should never exceed its min/max limits
|
||||||
const glm::vec2 MIN_REGION_GAP = { 1.0f, 2.0f };
|
const glm::vec2 MIN_REGION_GAP = { 1.0f, 2.0f };
|
||||||
// enforce outside --> in
|
// enforce outside --> in
|
||||||
for (int32_t i = workload::Region::NUM_VIEW_REGIONS - 2; i >= 0; --i) {
|
for (int32_t i = (int32_t)workload::Region::NUM_TRACKED_REGIONS - 2; i >= 0; --i) {
|
||||||
int32_t j = i + 1;
|
int32_t j = i + 1;
|
||||||
regionBackFronts[i] = regionRegulators[i].clamp(glm::min(regionBackFronts[i], regionBackFronts[j] - MIN_REGION_GAP));
|
regionBackFronts[i] = regionRegulators[i].clamp(glm::min(regionBackFronts[i], regionBackFronts[j] - MIN_REGION_GAP));
|
||||||
}
|
}
|
||||||
// enforce inside --> out
|
// enforce inside --> out
|
||||||
for (int32_t i = 1; i < workload::Region::NUM_VIEW_REGIONS; ++i) {
|
for (uint32_t i = 1; i < workload::Region::NUM_TRACKED_REGIONS; ++i) {
|
||||||
int32_t j = i - 1;
|
uint32_t j = i - 1;
|
||||||
regionBackFronts[i] = regionRegulators[i].clamp(glm::max(regionBackFronts[i], regionBackFronts[j] + MIN_REGION_GAP));
|
regionBackFronts[i] = regionRegulators[i].clamp(glm::max(regionBackFronts[i], regionBackFronts[j] + MIN_REGION_GAP));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -196,7 +196,7 @@ namespace workload {
|
||||||
} data;
|
} data;
|
||||||
|
|
||||||
struct DataExport {
|
struct DataExport {
|
||||||
static const int SIZE{ workload::Region::NUM_VIEW_REGIONS };
|
static const int SIZE{ workload::Region::NUM_TRACKED_REGIONS };
|
||||||
float timings[SIZE];
|
float timings[SIZE];
|
||||||
glm::vec2 ranges[SIZE];
|
glm::vec2 ranges[SIZE];
|
||||||
QList<qreal> _timings { 6, 2.0 };
|
QList<qreal> _timings { 6, 2.0 };
|
||||||
|
@ -252,8 +252,8 @@ namespace workload {
|
||||||
void configure(const Config& config);
|
void configure(const Config& config);
|
||||||
void run(const workload::WorkloadContextPointer& runContext, const Input& inputs, Output& outputs);
|
void run(const workload::WorkloadContextPointer& runContext, const Input& inputs, Output& outputs);
|
||||||
|
|
||||||
std::array<glm::vec2, workload::Region::NUM_VIEW_REGIONS> regionBackFronts;
|
std::array<glm::vec2, workload::Region::NUM_TRACKED_REGIONS> regionBackFronts;
|
||||||
std::array<Regulator, workload::Region::NUM_VIEW_REGIONS> regionRegulators;
|
std::array<Regulator, workload::Region::NUM_TRACKED_REGIONS> regionRegulators;
|
||||||
|
|
||||||
void regulateViews(workload::Views& views, const workload::Timings& timings);
|
void regulateViews(workload::Views& views, const workload::Timings& timings);
|
||||||
void enforceRegionContainment();
|
void enforceRegionContainment();
|
||||||
|
|
Loading…
Reference in a new issue