mirror of
https://github.com/overte-org/overte.git
synced 2025-04-19 12:23:24 +02:00
Merge pull request #13560 from danteruiz/fix-parent-grab-and-flickering
fix parent grab dropping and cullig flickering when flying at high velocities
This commit is contained in:
commit
42daa33d11
8 changed files with 42 additions and 26 deletions
|
@ -363,12 +363,18 @@ bool EntityRenderer::needsRenderUpdateFromEntity(const EntityItemPointer& entity
|
|||
return false;
|
||||
}
|
||||
|
||||
void EntityRenderer::updateModelTransform() {
|
||||
void EntityRenderer::updateModelTransformAndBound() {
|
||||
bool success = false;
|
||||
auto newModelTransform = _entity->getTransformToCenter(success);
|
||||
if (success) {
|
||||
_modelTransform = newModelTransform;
|
||||
}
|
||||
|
||||
success = false;
|
||||
auto bound = _entity->getAABox(success);
|
||||
if (success) {
|
||||
_bound = bound;
|
||||
}
|
||||
}
|
||||
|
||||
void EntityRenderer::doRenderUpdateSynchronous(const ScenePointer& scene, Transaction& transaction, const EntityItemPointer& entity) {
|
||||
|
@ -380,15 +386,7 @@ void EntityRenderer::doRenderUpdateSynchronous(const ScenePointer& scene, Transa
|
|||
}
|
||||
_prevIsTransparent = transparent;
|
||||
|
||||
bool success = false;
|
||||
auto bound = entity->getAABox(success);
|
||||
if (success) {
|
||||
_bound = bound;
|
||||
}
|
||||
auto newModelTransform = entity->getTransformToCenter(success);
|
||||
if (success) {
|
||||
_modelTransform = newModelTransform;
|
||||
}
|
||||
updateModelTransformAndBound();
|
||||
|
||||
_moving = entity->isMovingRelativeToParent();
|
||||
_visible = entity->getVisible();
|
||||
|
|
|
@ -97,7 +97,7 @@ protected:
|
|||
virtual void doRender(RenderArgs* args) = 0;
|
||||
|
||||
bool isFading() const { return _isFading; }
|
||||
void updateModelTransform();
|
||||
void updateModelTransformAndBound();
|
||||
virtual bool isTransparent() const { return _isFading ? Interpolate::calculateFadeRatio(_fadeStartTime) < 1.0f : false; }
|
||||
inline bool isValidRenderItem() const { return _renderItemID != Item::INVALID_ITEM_ID; }
|
||||
|
||||
|
|
|
@ -126,7 +126,7 @@ void ParticleEffectEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePoi
|
|||
void* key = (void*)this;
|
||||
AbstractViewStateInterface::instance()->pushPostUpdateLambda(key, [this] () {
|
||||
withWriteLock([&] {
|
||||
updateModelTransform();
|
||||
updateModelTransformAndBound();
|
||||
_renderTransform = getModelTransform();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -106,10 +106,8 @@ void ShapeEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& sce
|
|||
_position = entity->getWorldPosition();
|
||||
_dimensions = entity->getScaledDimensions();
|
||||
_orientation = entity->getWorldOrientation();
|
||||
bool success = false;
|
||||
auto newModelTransform = entity->getTransformToCenter(success);
|
||||
_renderTransform = success ? newModelTransform : getModelTransform();
|
||||
|
||||
updateModelTransformAndBound();
|
||||
_renderTransform = getModelTransform();
|
||||
if (_shape == entity::Sphere) {
|
||||
_renderTransform.postScale(SPHERE_ENTITY_SCALE);
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ void TextEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scen
|
|||
AbstractViewStateInterface::instance()->pushPostUpdateLambda(key, [this, entity] () {
|
||||
withWriteLock([&] {
|
||||
_dimensions = entity->getScaledDimensions();
|
||||
updateModelTransform();
|
||||
updateModelTransformAndBound();
|
||||
_renderTransform = getModelTransform();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -206,7 +206,7 @@ void WebEntityRenderer::doRenderUpdateSynchronousTyped(const ScenePointer& scene
|
|||
|
||||
glm::vec2 windowSize = getWindowSize(entity);
|
||||
_webSurface->resize(QSize(windowSize.x, windowSize.y));
|
||||
updateModelTransform();
|
||||
updateModelTransformAndBound();
|
||||
_renderTransform = getModelTransform();
|
||||
_renderTransform.postScale(entity->getScaledDimensions());
|
||||
});
|
||||
|
|
|
@ -11,7 +11,8 @@
|
|||
TRIGGER_OFF_VALUE, makeDispatcherModuleParameters, entityIsGrabbable, makeRunningValues, NEAR_GRAB_RADIUS,
|
||||
findGroupParent, Vec3, cloneEntity, entityIsCloneable, propsAreCloneDynamic, HAPTIC_PULSE_STRENGTH,
|
||||
HAPTIC_PULSE_DURATION, BUMPER_ON_VALUE, findHandChildEntities, TEAR_AWAY_DISTANCE, MSECS_PER_SEC, TEAR_AWAY_CHECK_TIME,
|
||||
TEAR_AWAY_COUNT, distanceBetweenPointAndEntityBoundingBox, print, Uuid, highlightTargetEntity, unhighlightTargetEntity
|
||||
TEAR_AWAY_COUNT, distanceBetweenPointAndEntityBoundingBox, print, Uuid, highlightTargetEntity, unhighlightTargetEntity,
|
||||
distanceBetweenEntityLocalPositionAndBoundingBox
|
||||
*/
|
||||
|
||||
Script.include("/~/system/libraries/controllerDispatcherUtils.js");
|
||||
|
@ -172,12 +173,9 @@ Script.include("/~/system/libraries/cloneEntityUtils.js");
|
|||
if (now - this.lastUnequipCheckTime > MSECS_PER_SEC * TEAR_AWAY_CHECK_TIME) {
|
||||
this.lastUnequipCheckTime = now;
|
||||
if (props.parentID === MyAvatar.SELF_ID) {
|
||||
var sensorScaleFactor = MyAvatar.sensorToWorldScale;
|
||||
var handPosition = controllerData.controllerLocations[this.hand].position;
|
||||
var dist = distanceBetweenPointAndEntityBoundingBox(handPosition, props);
|
||||
var distance = Vec3.distance(props.position, handPosition);
|
||||
if ((dist > TEAR_AWAY_DISTANCE) ||
|
||||
(distance > NEAR_GRAB_RADIUS * sensorScaleFactor)) {
|
||||
var tearAwayDistance = TEAR_AWAY_DISTANCE * MyAvatar.sensorToWorldScale;
|
||||
var distance = distanceBetweenEntityLocalPositionAndBoundingBox(props);
|
||||
if (distance > tearAwayDistance) {
|
||||
this.autoUnequipCounter++;
|
||||
} else {
|
||||
this.autoUnequipCounter = 0;
|
||||
|
|
|
@ -59,6 +59,7 @@
|
|||
highlightTargetEntity:true,
|
||||
clearHighlightedEntities:true,
|
||||
unhighlightTargetEntity:true
|
||||
distanceBetweenEntityLocalPositionAndBoundingBox: true
|
||||
*/
|
||||
|
||||
MSECS_PER_SEC = 1000.0;
|
||||
|
@ -130,7 +131,9 @@ DISPATCHER_PROPERTIES = [
|
|||
"type",
|
||||
"href",
|
||||
"cloneable",
|
||||
"cloneDynamic"
|
||||
"cloneDynamic",
|
||||
"localPosition",
|
||||
"localRotation"
|
||||
];
|
||||
|
||||
// priority -- a lower priority means the module will be asked sooner than one with a higher priority in a given update step
|
||||
|
@ -413,6 +416,25 @@ findHandChildEntities = function(hand) {
|
|||
});
|
||||
};
|
||||
|
||||
distanceBetweenEntityLocalPositionAndBoundingBox = function(entityProps) {
|
||||
var localPoint = entityProps.localPosition;
|
||||
var entityXform = new Xform(entityProps.rotation, entityProps.position);
|
||||
var minOffset = Vec3.multiplyVbyV(entityProps.registrationPoint, entityProps.dimensions);
|
||||
var maxOffset = Vec3.multiplyVbyV(Vec3.subtract(ONE_VEC, entityProps.registrationPoint), entityProps.dimensions);
|
||||
var localMin = Vec3.subtract(entityXform.trans, minOffset);
|
||||
var localMax = Vec3.sum(entityXform.trans, maxOffset);
|
||||
|
||||
var v = {x: localPoint.x, y: localPoint.y, z: localPoint.z};
|
||||
v.x = Math.max(v.x, localMin.x);
|
||||
v.x = Math.min(v.x, localMax.x);
|
||||
v.y = Math.max(v.y, localMin.y);
|
||||
v.y = Math.min(v.y, localMax.y);
|
||||
v.z = Math.max(v.z, localMin.z);
|
||||
v.z = Math.min(v.z, localMax.z);
|
||||
|
||||
return Vec3.distance(v, localPoint);
|
||||
};
|
||||
|
||||
distanceBetweenPointAndEntityBoundingBox = function(point, entityProps) {
|
||||
var entityXform = new Xform(entityProps.rotation, entityProps.position);
|
||||
var localPoint = entityXform.inv().xformPoint(point);
|
||||
|
|
Loading…
Reference in a new issue